diff options
author | Kjetil Orbekk <kj@orbekk.com> | 2023-01-01 11:52:28 -0500 |
---|---|---|
committer | Kjetil Orbekk <kj@orbekk.com> | 2023-01-01 11:52:28 -0500 |
commit | bb2ed3a2926384df063e476d10613fa310cd7ffa (patch) | |
tree | cc9c6ea4979eef3850d78cd0b1390dfbccb5921b /server/tests/table_test.rs | |
parent | 1e3014a777805d3dcb691ee6ebe59c62f58f8222 (diff) |
Add Table to be used with db schema
Diffstat (limited to 'server/tests/table_test.rs')
-rw-r--r-- | server/tests/table_test.rs | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/server/tests/table_test.rs b/server/tests/table_test.rs new file mode 100644 index 0000000..4d80f32 --- /dev/null +++ b/server/tests/table_test.rs @@ -0,0 +1,26 @@ +use protocol::{card::{Rank, Suit}, bridge_engine::TableState}; +use server::table::{Table, InMemoryTable}; + +mod common; + +async fn table_basic_test(table: Box<dyn Table>) -> 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(()) +} |