use protocol::bridge_engine::TableState; use rand::{thread_rng, Rng}; use server::table::{Table, InMemoryTable, DbTable}; mod common; async fn table_basic_test(table: Box) -> Result<(), anyhow::Error> { assert!(matches!(table.state(), TableState::Unknown)); let mut table = table.new_deal().await?; assert!(matches!(table.state(), TableState::Game(_))); while matches!(table.state(), TableState::Game(_)) { table = server::table::advance_play(table).await?; } assert!(matches!(table.state(), TableState::Result(_))); table = table.new_deal().await?; assert!(matches!(table.state(), TableState::Game(_))); Ok(()) } #[tokio::test] #[ignore] async fn in_memory_table() -> Result<(), anyhow::Error> { common::test_setup(); table_basic_test(Box::new(InMemoryTable::new())).await?; Ok(()) } #[tokio::test] #[ignore] async fn db_table() -> Result<(), anyhow::Error> { let db = common::TestDb::new().await; table_basic_test(Box::new(DbTable::new(db.db().clone()))).await?; Ok(()) } #[tokio::test] #[ignore] async fn db_table_persistence() -> Result<(), anyhow::Error> { let db = common::TestDb::new().await; let mut table = Box::new(DbTable::new(db.db().clone())); for i in 0..(thread_rng().gen_range(0..200)) { todo!() } Ok(()) }