fix(test): read the turn store through events_from and rustfmt the delete tests
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.
This commit is contained in:
1 parent
994df09c8f
commit
cfb3178346
2 files changed
+29
-10
No files matched your search
@@ -427,13 +427,15 @@ mod tests {
|
|||||||
store.forget("interactive:web").expect("forgets");
|
store.forget("interactive:web").expect("forgets");
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
store.events("interactive:web").expect("reads"),
|
store
|
||||||
|
.events_from("interactive:web", -1, usize::MAX)
|
||||||
|
.expect("reads"),
|
||||||
vec![],
|
vec![],
|
||||||
"the deleted key's stream is gone"
|
"the deleted key's stream is gone"
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
store.events("task:2").expect("reads"),
|
store.events_from("task:2", -1, usize::MAX).expect("reads"),
|
||||||
vec![text_delta("c")],
|
vec![(0, text_delta("c"))],
|
||||||
"another key's stream is untouched"
|
"another key's stream is untouched"
|
||||||
);
|
);
|
||||||
// The stream starts over: a re-created key replays nothing from
|
// The stream starts over: a re-created key replays nothing from
|
||||||
@@ -442,8 +444,10 @@ mod tests {
|
|||||||
.append("interactive:web", &[text_delta("fresh")])
|
.append("interactive:web", &[text_delta("fresh")])
|
||||||
.expect("appends");
|
.expect("appends");
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
store.events("interactive:web").expect("reads"),
|
store
|
||||||
vec![text_delta("fresh")],
|
.events_from("interactive:web", -1, usize::MAX)
|
||||||
|
.expect("reads"),
|
||||||
|
vec![(0, text_delta("fresh"))],
|
||||||
"the re-created stream starts empty"
|
"the re-created stream starts empty"
|
||||||
);
|
);
|
||||||
// A key with no rows is not an error.
|
// A key with no rows is not an error.
|
||||||
|
|||||||
@@ -3312,7 +3312,10 @@ async fn inventory(client: &reqwest::Client, base: &str) -> Vec<Value> {
|
|||||||
/// a chat that streams nothing from before.
|
/// a chat that streams nothing from before.
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn deleting_a_session_drops_the_record_and_its_history() {
|
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 dir = tempfile::tempdir().expect("tempdir");
|
||||||
let daemon = Daemon::build(
|
let daemon = Daemon::build(
|
||||||
&config(&dir, None),
|
&config(&dir, None),
|
||||||
@@ -3365,7 +3368,10 @@ async fn deleting_a_session_drops_the_record_and_its_history() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Gone from the inventory...
|
// 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.
|
// ...and gone from the store, so the create precondition holds again.
|
||||||
let recreated = client
|
let recreated = client
|
||||||
@@ -3374,7 +3380,11 @@ async fn deleting_a_session_drops_the_record_and_its_history() {
|
|||||||
.send()
|
.send()
|
||||||
.await
|
.await
|
||||||
.expect("the second create posts");
|
.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
|
// The re-created key replays nothing from before: its stream opens
|
||||||
// with the new turn only — one user message, the new reply, and no
|
// 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);
|
assert_eq!(unknown.status(), 404);
|
||||||
let body: Value = unknown.json().await.expect("the body parses");
|
let body: Value = unknown.json().await.expect("the body parses");
|
||||||
assert!(
|
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}"
|
"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.
|
// deployment — deletes on the same route.
|
||||||
let store = SqliteStore::open(&db).expect("the store opens");
|
let store = SqliteStore::open(&db).expect("the store opens");
|
||||||
let forge = ResourceKey::from("github:acme/widgets#7");
|
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
|
let deleted = client
|
||||||
.delete(format!("{base}/v1/sessions/github%3Aacme%2Fwidgets%237"))
|
.delete(format!("{base}/v1/sessions/github%3Aacme%2Fwidgets%237"))
|
||||||
.send()
|
.send()
|
||||||
|
|||||||
Reference in new issue
Block a user