From cfb31783460b278c8874501ee4d823a64449d7e2 Mon Sep 17 00:00:00 2001 From: kosmos Date: Wed, 11 Nov 2026 16:44:58 +0000 Subject: [PATCH] fix(test): read the turn store through events_from and rustfmt the delete tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The forget test called `TurnStore::events`, which no longer exists — the store reads through `events_from(key, after, limit)`, so the assertion now spells the `(seq, event)` pairs it actually returns. The new assertions were also wider than rustfmt allows, here and in the http/rsd delete tests; `cargo fmt --all` reformatted them. --- crates/rhema-claw/src/turn_store.rs | 14 +++++++++----- crates/rhema-claw/tests/http.rs | 25 ++++++++++++++++++++----- 2 files changed, 29 insertions(+), 10 deletions(-) diff --git a/crates/rhema-claw/src/turn_store.rs b/crates/rhema-claw/src/turn_store.rs index 73b6e6e..3354812 100644 --- a/crates/rhema-claw/src/turn_store.rs +++ b/crates/rhema-claw/src/turn_store.rs @@ -427,13 +427,15 @@ mod tests { store.forget("interactive:web").expect("forgets"); assert_eq!( - store.events("interactive:web").expect("reads"), + store + .events_from("interactive:web", -1, usize::MAX) + .expect("reads"), vec![], "the deleted key's stream is gone" ); assert_eq!( - store.events("task:2").expect("reads"), - vec![text_delta("c")], + store.events_from("task:2", -1, usize::MAX).expect("reads"), + vec![(0, text_delta("c"))], "another key's stream is untouched" ); // The stream starts over: a re-created key replays nothing from @@ -442,8 +444,10 @@ mod tests { .append("interactive:web", &[text_delta("fresh")]) .expect("appends"); assert_eq!( - store.events("interactive:web").expect("reads"), - vec![text_delta("fresh")], + store + .events_from("interactive:web", -1, usize::MAX) + .expect("reads"), + vec![(0, text_delta("fresh"))], "the re-created stream starts empty" ); // A key with no rows is not an error. diff --git a/crates/rhema-claw/tests/http.rs b/crates/rhema-claw/tests/http.rs index 29172b6..7dc41c7 100644 --- a/crates/rhema-claw/tests/http.rs +++ b/crates/rhema-claw/tests/http.rs @@ -3312,7 +3312,10 @@ async fn inventory(client: &reqwest::Client, base: &str) -> Vec { /// a chat that streams nothing from before. #[tokio::test] async fn deleting_a_session_drops_the_record_and_its_history() { - let provider = Arc::new(MockProvider::new([reply("first words"), reply("second words")])); + let provider = Arc::new(MockProvider::new([ + reply("first words"), + reply("second words"), + ])); let dir = tempfile::tempdir().expect("tempdir"); let daemon = Daemon::build( &config(&dir, None), @@ -3365,7 +3368,10 @@ async fn deleting_a_session_drops_the_record_and_its_history() { ); // Gone from the inventory... - assert!(inventory(&client, &base).await.is_empty(), "the key is gone"); + assert!( + inventory(&client, &base).await.is_empty(), + "the key is gone" + ); // ...and gone from the store, so the create precondition holds again. let recreated = client @@ -3374,7 +3380,11 @@ async fn deleting_a_session_drops_the_record_and_its_history() { .send() .await .expect("the second create posts"); - assert_eq!(recreated.status(), 201, "a deleted key can be created again"); + assert_eq!( + recreated.status(), + 201, + "a deleted key can be created again" + ); // The re-created key replays nothing from before: its stream opens // with the new turn only — one user message, the new reply, and no @@ -3429,7 +3439,10 @@ async fn deleting_an_unknown_session_is_a_404_and_any_key_deletes() { assert_eq!(unknown.status(), 404); let body: Value = unknown.json().await.expect("the body parses"); assert!( - body["error"].as_str().expect("an error").contains("interactive:nope"), + body["error"] + .as_str() + .expect("an error") + .contains("interactive:nope"), "the refusal names the key: {body}" ); @@ -3437,7 +3450,9 @@ async fn deleting_an_unknown_session_is_a_404_and_any_key_deletes() { // deployment — deletes on the same route. let store = SqliteStore::open(&db).expect("the store opens"); let forge = ResourceKey::from("github:acme/widgets#7"); - store.save(rhema_rsd::KeyRecord::fresh(forge.clone(), 1), None).expect("the row seeds"); + store + .save(rhema_rsd::KeyRecord::fresh(forge.clone(), 1), None) + .expect("the row seeds"); let deleted = client .delete(format!("{base}/v1/sessions/github%3Aacme%2Fwidgets%237")) .send()