forge
Explore
Log in

Don't you dare go Hollow

📅 prove a settled booking goes with its slot

Browse files at this commit

04b3469a216c2f4c6f7473dcdbc0f274106cbf41Ahmet Kaan GümüşParent: 2202807
  • test
    • 📅 prove a settled booking goes with its slot
Show full message
test: 📅 prove a settled booking goes with its slot

`delete_free` cascades `DELETE appointment WHERE slot IN $slots` inside
the slot delete's own transaction, but both existing tests stopped at the
204 — the cascade itself was never asserted. A booking left pointing at a
deleted slot is a dangling link every read of it has to survive.

The count is read from the database rather than off the response: a 204
was never proof the second statement ran. It passes, so the cascade
holds today; this is the forcing function that keeps it holding.
tests/integration.rsmodified+10 -0
@@ -17472,6 +17472,16 @@ async fn slot_delete_waits_for_the_booking_to_settle() {
17472 );17472 );
17473 let res = send(&app, "DELETE", &uri, Some(&ali), None).await;17473 let res = send(&app, "DELETE", &uri, Some(&ali), None).await;
17474 assert_eq!(res.status, StatusCode::NO_CONTENT, "{}", res.body);17474 assert_eq!(res.status, StatusCode::NO_CONTENT, "{}", res.body);
17475+ // The settled booking goes with the slot, in the same transaction — it is
17476+ // history of a meeting that no longer exists, and a row left pointing at a
17477+ // deleted slot is a dangling link every read of it has to survive. The
17478+ // `204` alone never proved the cascade ran, so the count is read from the
17479+ // database (`pay_row_count` is this file's plain table count).
17480+ assert_eq!(
17481+ pay_row_count(&db, "appointment").await,
17482+ 0,
17483+ "the cancelled booking {booking} outlived its slot"
17484+ );
17475 assert_eq!(17485 assert_eq!(
17476 send(&app, "DELETE", &uri, Some(&ali), None).await.status,17486 send(&app, "DELETE", &uri, Some(&ali), None).await.status,
17477 StatusCode::NOT_FOUND17487 StatusCode::NOT_FOUND