From a771e71bd6d43f3fc652d77c330465f014068059 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Wed, 30 Sep 2026 22:59:52 +0200 Subject: [PATCH] Rust test: pin the cargo-mutants survivors in the catalog lay-back - The fixture gains an older entry listing the id ahead of the one that owns it, and the whole-store write carries the record under the registered type a Rust cache's pull gives it, not the entry's name. Kills the own-id lookup flip and the ||-to-&& flip in the entry filter. - A store path that cannot be read (a directory) is an error, not an empty store (the NotFound guard had no test). Co-Authored-By: Claude Opus 5.5 --- packages/cultcache-rs/src/lib.rs | 40 +++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/packages/cultcache-rs/src/lib.rs b/packages/cultcache-rs/src/lib.rs index 82c8b50a..e8936fce 100644 --- a/packages/cultcache-rs/src/lib.rs +++ b/packages/cultcache-rs/src/lib.rs @@ -4985,14 +4985,31 @@ mod tests { stored_at: "2026-09-30T00:00:00Z".into(), schema_id: Some("tests.other".into()), }; + // An older entry that lists the id: the entry that owns the id is the one laid back. + let lister = PersistedSchemaCatalogEntry( + "sha256:older".into(), + "tests.note".into(), + "tests.note_v6".into(), + "sha256:older".into(), + String::new(), + vec!["sha256:older".into(), "sha256:csharp".into()], + Vec::new(), + ); for whole_store in [false, true] { let temp = tempfile::tempdir()?; let path = temp.path().join("store.msgpack"); let record = PersistedRecord("a".into(), "sha256:csharp".into(), "2026-09-30T00:00:00Z".into(), b"one".to_vec()); - std::fs::write(&path, rmp_serde::to_vec(&PersistedStoreSnapshot("cultcache.store.v1".into(), vec![held.clone()], vec![record]))?)?; + std::fs::write( + &path, + rmp_serde::to_vec(&PersistedStoreSnapshot("cultcache.store.v1".into(), vec![lister.clone(), held.clone()], vec![record]))?, + )?; let mut store = SingleFileMessagePackBackingStore::new(&path); if whole_store { + // As a Rust cache holds it after a pull: under the registered type that reads the schema by name. let mut entries = store.pull_all()?; + for entry in &mut entries { + entry.r#type = "tests.rust_note".into(); + } entries.push(own.clone()); store.push_all(&entries, PushAllOptions::default())?; } else { @@ -5007,6 +5024,27 @@ mod tests { Ok(()) } + // Only a file that is not there is an empty store; any other failure to read it is an error, so a write never replaces a + // file it could not read. + #[test] + fn a_store_path_that_cannot_be_read_is_an_error_not_an_empty_store() -> Result<()> { + let temp = tempfile::tempdir()?; + let path = temp.path().join("store.msgpack"); + std::fs::create_dir(&path)?; + let mut store = SingleFileMessagePackBackingStore::new(&path); + assert!(store.pull_all().is_err(), "a directory is not an empty store"); + let own = CultCacheEnvelope { + key: "b".into(), + r#type: "tests.other".into(), + payload: b"two".to_vec(), + stored_at: "2026-09-30T00:00:00Z".into(), + schema_id: Some("tests.other".into()), + }; + assert!(store.push(&own).is_err()); + assert!(path.is_dir(), "the path is left as it was"); + Ok(()) + } + fn store_file(path: &std::path::Path, catalog: &[(&str, &str)], records: &[(&str, &str, Vec)]) -> Result<()> { let snapshot = PersistedStoreSnapshot( "cultcache.store.v1".to_string(),