testing reveals the stage as source of truth IS angry
parent
90de4a0cfd
commit
be632d3da3
|
|
@ -316,6 +316,44 @@ mod test_file {
|
||||||
tests::file_contains(&d, "plain", "[]");
|
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)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue