use std::sync::Arc;
use fauna_api::authentification;
use fauna_api::tickets::{self, TicketDraft, TicketRoom};
const ROUTE: &str = "http://localhost:32862";
#[tokio::test]
#[ignore = "needs the local Fauna stack on :32862"]
async fn signs_in_and_joins_a_live_room() {
fauna_api::set_route(ROUTE);
let token = authentification::authorize("premium@faunakit.com", "password")
.await
.expect("seeded premium account signs in");
let credentials = authentification::authorize_token(&token)
.await
.expect("token resolves to credentials");
assert_eq!(credentials.email, "premium@faunakit.com");
assert_eq!(credentials.token, token);
let ticket = tickets::create(
&credentials,
&TicketDraft {
title: Some("Rust SDK live test".to_string()),
source: Some("api/rust".to_string()),
description: Some("Created by api/rust tests/live.rs".to_string()),
},
)
.await
.expect("ticket created");
let (room, me) = TicketRoom::connect(&credentials, &ticket.id, Some(Arc::new(())))
.await
.expect("joins the ticket room");
assert_eq!(room.ticket().id, ticket.id);
assert_eq!(me.profile().email, credentials.email);
assert_eq!(room.id(), me.room().id());
room.disconnect();
assert!(room.get_presences().is_empty());
}