testing reveals the stage as source of truth IS angry

master
Bel LaPointe 2025-11-11 17:31:44 -07:00
parent 90de4a0cfd
commit be632d3da3
1 changed files with 38 additions and 0 deletions

View File

@ -316,6 +316,44 @@ mod test_file {
tests::file_contains(&d, "plain", "[]");
});
}
#[test]
fn test_file_deletion_to_persist() {
tests::with_dir(|d| {
tests::write_file(&d, "plain", "- initial\n- 1");
tests::write_file(
&d,
".plain.host_a",
r#"
{"ts":1, "patch":{"op":"replace", "path":"", "value": ["initial"]}}
{"ts":3, "patch":{"op":"add", "path":"/-", "value": {"k":"v"}}}
"#,
);
tests::write_file(
&d,
".plain.host_b",
r#"
{"ts":2, "patch":{"op":"add", "path":"/-", "value": 1}}
"#,
);
let f = File::new(&d.path().join("plain").to_str().unwrap().to_string());
assert_eq!(3, f.events().unwrap().0.len());
assert_eq!(2, f.stage().unwrap().len());
tests::file_contains(&d, "plain", "- initial\n- 1");
f.persist_stage().unwrap();
assert_eq!(4, f.events().unwrap().0.len());
assert_eq!(2, f.stage().unwrap().len());
tests::file_contains(&d, "plain", "- initial\n- 1");
f.stage_persisted().unwrap();
assert_eq!(4, f.events().unwrap().0.len());
assert_eq!(2, f.stage().unwrap().len());
tests::file_contains(&d, "plain", "- initial\n- 1");
});
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]