mod common;
use common::{init, test_client};
#[tokio::test]
async fn test_api_test() {
init();
let client = skip_if_no_client!(test_client());
let result = client.api().test().await;
match result {
Ok(response) => {
println!("✓ api.test: ok={}", response.ok());
}
Err(e) => {
panic!("api.test failed unexpectedly: {}", e);
}
}
}
#[tokio::test]
async fn test_api_test_with_args() {
init();
let client = skip_if_no_client!(test_client());
let mut args = std::collections::HashMap::new();
args.insert("foo".to_string(), "bar".to_string());
args.insert("hello".to_string(), "world".to_string());
let result = client.api().test_with_args(args).await;
match result {
Ok(response) => {
println!("✓ api.test (with args): ok={}", response.ok());
}
Err(e) => {
println!("✓ api.test (with args): {}", e);
}
}
}
#[tokio::test]
async fn test_bots_info() {
init();
let client = skip_if_no_client!(test_client());
let auth = client.auth().test().await.expect("Failed to get auth info");
if let Some(bot_id) = auth.bot_id {
let result = client.bots().info(&bot_id).await;
match result {
Ok(response) => {
println!(
"✓ bots.info: {} ({})",
response.bot.name.unwrap_or_default(),
response.bot.id
);
}
Err(e) => {
println!("✓ bots.info: {} (may need bot token)", e);
}
}
} else {
println!("✓ bots.info: skipped (no bot_id in auth response, not a bot token)");
}
}
#[tokio::test]
async fn test_bots_info_invalid() {
init();
let client = skip_if_no_client!(test_client());
let result = client.bots().info("B00000000").await;
match result {
Ok(_) => {
println!("✓ bots.info (invalid): unexpectedly succeeded");
}
Err(e) => {
println!("✓ bots.info (invalid): correctly failed with {}", e);
}
}
}