mirror of
https://github.com/szymon-jozef/checkers.git
synced 2026-10-27 19:20:44 +01:00
test: integration test for server and bot
This commit is contained in:
33
tests/integration.rs
Normal file
33
tests/integration.rs
Normal file
@@ -0,0 +1,33 @@
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use tokio::time::Duration;
|
||||
|
||||
use checkers::{
|
||||
network::server::Server,
|
||||
super_advanced_ai::{Bot, BotDificulty},
|
||||
};
|
||||
|
||||
#[tokio::test]
|
||||
async fn game_integration() {
|
||||
tokio::spawn(async move {
|
||||
let mut server = Server::new().await;
|
||||
server.start().await;
|
||||
server.update().await;
|
||||
});
|
||||
|
||||
tokio::time::sleep(Duration::from_secs(2)).await; // wait for the server to run
|
||||
|
||||
let bot1_handle = tokio::spawn(async move {
|
||||
let bot1 = Bot::new(BotDificulty::Easy).await;
|
||||
bot1.game_loop().await;
|
||||
});
|
||||
|
||||
let bot2_handle = tokio::spawn(async move {
|
||||
let bot2 = Bot::new(BotDificulty::Easy).await;
|
||||
bot2.game_loop().await;
|
||||
});
|
||||
|
||||
bot1_handle.await.unwrap();
|
||||
bot2_handle.await.unwrap();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user