From 4f4e6133acbad44554d44ab9df88035e4d9ceff0 Mon Sep 17 00:00:00 2001 From: Daniel Karzel Date: Tue, 19 Oct 2021 17:44:03 +1100 Subject: [PATCH] Failing test --- daemon/src/db.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/daemon/src/db.rs b/daemon/src/db.rs index 8b1874f..99792a4 100644 --- a/daemon/src/db.rs +++ b/daemon/src/db.rs @@ -704,6 +704,21 @@ mod tests { assert_eq!(vec![cfd_1, cfd_2], cfds_from_db); } + #[tokio::test] + async fn test_insert_order_without_cfd_associates_with_correct_cfd() { + let mut conn = setup_test_db().await; + + // Insert an order without a CFD + let _order_1 = Order::dummy().insert(&mut conn).await; + + // Insert a CFD (this also inserts an order) + let cfd_1 = Cfd::dummy().insert(&mut conn).await; + + let all_cfds = load_all_cfds(&mut conn).await.unwrap(); + + assert_eq!(all_cfds, vec![cfd_1]); + } + // test more data; test will add 100 cfds to the database, with each // having a random number of random updates. Final results are deterministic. #[tokio::test]