mod common;
use common::{init, test_client};
#[tokio::test]
async fn test_calls_add_info_end() {
init();
let client = skip_if_no_client!(test_client());
let timestamp = std::time::SystemTime::now()
.duration_since(std::time::UNIX_EPOCH)
.unwrap()
.as_millis();
let external_id = format!("test-call-{}", timestamp);
let add_result = client
.calls()
.add(&external_id, "https://example.com/join-call")
.await;
match add_result {
Ok(response) => {
let call_id = response.call.id.clone();
println!("✓ calls.add: created call {}", call_id);
let info_result = client.calls().info(&call_id).await;
match info_result {
Ok(info) => {
println!(
"✓ calls.info: {} (external: {})",
info.call.id, info.call.external_unique_id
);
}
Err(e) => {
println!("✗ calls.info: {}", e);
}
}
let end_result = client.calls().end(&call_id).await;
match end_result {
Ok(_) => {
println!("✓ calls.end: ended call {}", call_id);
}
Err(e) => {
println!("✗ calls.end: {}", e);
}
}
}
Err(e) => {
println!("✓ calls.add: {} (may require calls:write scope)", e);
}
}
}
#[tokio::test]
async fn test_calls_update() {
init();
let client = skip_if_no_client!(test_client());
let timestamp = std::time::SystemTime::now()
.duration_since(std::time::UNIX_EPOCH)
.unwrap()
.as_millis();
let external_id = format!("test-call-update-{}", timestamp);
let add_result = client
.calls()
.add(&external_id, "https://example.com/join")
.await;
match add_result {
Ok(response) => {
let call_id = response.call.id.clone();
let update_result = client
.calls()
.update(&call_id, Some("Updated Test Call"), None)
.await;
match update_result {
Ok(updated) => {
println!("✓ calls.update: title = {:?}", updated.call.title);
}
Err(e) => {
println!("✗ calls.update: {}", e);
}
}
let _ = client.calls().end(&call_id).await;
}
Err(e) => {
println!("✓ calls.update: Skipped (couldn't create call: {})", e);
}
}
}
#[tokio::test]
async fn test_calls_participants() {
init();
let client = skip_if_no_client!(test_client());
let timestamp = std::time::SystemTime::now()
.duration_since(std::time::UNIX_EPOCH)
.unwrap()
.as_millis();
let external_id = format!("test-call-participants-{}", timestamp);
let add_result = client
.calls()
.add(&external_id, "https://example.com/join")
.await;
match add_result {
Ok(response) => {
let call_id = response.call.id.clone();
println!("Created call {} for participant tests", call_id);
let auth_result = client.auth().test().await;
if let Ok(auth) = auth_result {
let user_id = auth.user_id;
let add_participant_result =
client.calls().participants_add(&call_id, &[&user_id]).await;
match add_participant_result {
Ok(_) => {
println!("✓ calls.participants.add: added user {}", user_id);
let remove_result = client
.calls()
.participants_remove(&call_id, &[&user_id])
.await;
match remove_result {
Ok(_) => {
println!("✓ calls.participants.remove: removed user {}", user_id);
}
Err(e) => {
println!("✗ calls.participants.remove: {}", e);
}
}
}
Err(e) => {
println!(
"✓ calls.participants.add: {} (may require specific scopes)",
e
);
}
}
}
let _ = client.calls().end(&call_id).await;
}
Err(e) => {
println!(
"✓ calls.participants: Skipped (couldn't create call: {})",
e
);
}
}
}