use crate::args::Args; use crate::server::start_server; use crate::test::bot_client::{ClientEndResult, RunMode}; use crate::test::{bot_client, TestPort}; use crate::utils::network_utils::wait_for_port; use std::error::Error; use tokio::task; async fn play_random(port: TestPort) -> Result> { bot_client::BotClient::new(port.as_url()) .with_run_mode(RunMode::Random) .run_client() .await } #[tokio::test] async fn four_games() { let _ = env_logger::builder().is_test(true).try_init(); let local_set = task::LocalSet::new(); local_set .run_until(async move { task::spawn_local(start_server(Args::for_test(TestPort::RandomModeFourGames))); wait_for_port(TestPort::RandomModeFourGames.port()).await; let mut fut = vec![]; for _ in 0..4 { fut.push(task::spawn_local(play_random( TestPort::RandomModeFourGames, ))); } for handle in fut { let res = handle.await.unwrap().unwrap(); assert!(matches!(res, ClientEndResult::Finished { .. })); } }) .await; }