From bb2ed3a2926384df063e476d10613fa310cd7ffa Mon Sep 17 00:00:00 2001 From: Kjetil Orbekk Date: Sun, 1 Jan 2023 11:52:28 -0500 Subject: Add Table to be used with db schema --- server/tests/table_test.rs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 server/tests/table_test.rs (limited to 'server/tests/table_test.rs') 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) -> 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(()) +} -- cgit v1.2.3