Rust: a zero-byte store file is rewritten as an empty v1 store
Soul's mutant deleting the empty-file arm of write_all_unlocked survived: no test rewrote a zero-byte file. Without the arm the empty file reaches store_header and is refused as truncated. The test pushes onto a zero-byte file and expects a v1 store holding the pushed record. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
ea1bd6a797
commit
0be33c1198
1 changed files with 13 additions and 0 deletions
|
|
@ -4876,6 +4876,19 @@ mod tests {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
// A zero-byte file is an empty store with no header, not a truncated one: a rewrite writes it v1.
|
||||
#[test]
|
||||
fn push_all_rewrites_a_zero_byte_file_as_v1() -> Result<()> {
|
||||
let temp = tempfile::tempdir()?;
|
||||
let path = temp.path().join("store.msgpack");
|
||||
std::fs::write(&path, [])?;
|
||||
let mut store = SingleFileMessagePackBackingStore::new(&path);
|
||||
store.push_all(&[snapshot_envelope("x", b"one")], PushAllOptions::default())?;
|
||||
assert_eq!(store_header(&std::fs::read(&path)?, true)?.as_deref(), Some(STORE_FORMAT_V1));
|
||||
assert_eq!(store.pull_all()?.len(), 1);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_rewrite_of_a_v1_store_stays_v1() -> Result<()> {
|
||||
assert_eq!(
|
||||
|
|
|
|||
Loading…
Reference in a new issue