fauna-api 1.0.861

The Fauna SDK for Rust: accounts, Drive, groups, calendar, chats, payments, Parrot and live rooms.
Documentation
// Routes are process-wide statics, so every case runs in order inside one test.

#[test]
fn set_route_matches_the_typescript_split_rules() {
    assert_eq!(fauna_api::get_url(), "https://api.faunakit.com:443");
    assert_eq!(fauna_api::get_route(), "api.faunakit.com:443");

    fauna_api::set_route("http://localhost:32862");
    assert_eq!(fauna_api::get_url(), "http://localhost:32862");
    assert_eq!(fauna_api::get_ip(), "localhost");
    assert_eq!(fauna_api::get_port(), 32862);

    // No port keeps the previous one, like the TypeScript SDK.
    fauna_api::set_route("https://example.com");
    assert_eq!(fauna_api::get_url(), "https://example.com:32862");

    // No scheme keeps the previous prefix.
    fauna_api::set_route("127.0.0.1:4000");
    assert_eq!(fauna_api::get_url(), "https://127.0.0.1:4000");
    assert_eq!(fauna_api::get_route(), "127.0.0.1:4000");
}

#[test]
fn production_keeps_its_own_route() {
    fauna_api::private::production::set_route("http://localhost:9000");
    assert_eq!(
        fauna_api::private::production::get_url(),
        "http://localhost:9000"
    );
    assert_ne!(fauna_api::get_url(), "http://localhost:9000");
}

#[test]
fn parrot_keeps_its_own_route() {
    fauna_api::parrot::set_route("http://localhost:9100");
    assert_eq!(fauna_api::parrot::get_url(), "http://localhost:9100");
    assert_eq!(fauna_api::parrot::get_route(), "localhost:9100");
    assert_ne!(fauna_api::get_url(), "http://localhost:9100");
}

#[tokio::test]
async fn throttling_promise_keeps_task_order() {
    let tasks: Vec<_> = (0..10u64)
        .map(|index| {
            move || async move {
                tokio::time::sleep(std::time::Duration::from_millis(10 - index)).await;
                index
            }
        })
        .collect();
    assert_eq!(
        fauna_api::throttling_promise(tasks, 3).await,
        (0..10).collect::<Vec<_>>()
    );

    let none: Vec<fn() -> std::future::Ready<u8>> = vec![|| std::future::ready(1)];
    assert!(fauna_api::throttling_promise(none, 0).await.is_empty());
}