WIP test add-scheduled, snapshot, scheduled-due

This commit is contained in:
Bel LaPointe
2025-12-01 18:26:41 -07:00
parent 0a7e6873a3
commit fe8a55b4c1
2 changed files with 52 additions and 0 deletions

View File

@@ -490,6 +490,57 @@ mod test_file {
});
}
#[test]
fn test_schedule_date_future_with_snapshot_between_scheduled_and_fired() {
tests::with_dir(|d| {
tests::write_file(&d, "plain", "- stage");
tests::write_file(
&d,
".plain.host",
format!(
r#"
{{"ts":1, "op":"Add", "task": "stage"}}
{{"ts":2, "op":"Snapshot", "task": null, "tasks": ["removed", "old"]}}
"#,
Delta::now_time() + 50,
)
.as_str(),
);
let f = File::new(&d.path().join("plain").to_str().unwrap().to_string());
let mut m = serde_yaml::Mapping::new();
m.insert("schedule".into(), "2036-01-02".into());
let task = Task(serde_yaml::Value::Mapping(m));
f.append(Delta::add(task)).unwrap();
assert_eq!(
1,
f.events().unwrap().0.len(),
"{:?}",
f.events().unwrap().0
);
assert_eq!(0, f.stage().unwrap().len(), "{:?}", f.stage());
f.persist_stage().unwrap();
assert_eq!(
1,
f.events().unwrap().0.len(),
"{:?}",
f.events().unwrap().0
);
assert_eq!(0, f.stage().unwrap().len(), "{:?}", f.stage());
f.stage_persisted().unwrap();
assert_eq!(
1,
f.events().unwrap().0.len(),
"{:?}",
f.events().unwrap().0
);
assert_eq!(0, f.stage().unwrap().len(), "{:?}", f.stage());
});
}
#[test]
fn test_schedule_date_past() {
tests::with_dir(|d| {