still unsure about triggered vs snapshot time...
parent
a5553d75f4
commit
7da6aa8ae9
|
|
@ -354,12 +354,7 @@ mod test_file {
|
|||
"{:?}",
|
||||
f.events().unwrap().snapshot().unwrap(),
|
||||
);
|
||||
assert_eq!(
|
||||
8,
|
||||
f.events().unwrap().0.len(),
|
||||
"{:?}",
|
||||
f.events().unwrap().0
|
||||
);
|
||||
assert_eq!(8, f.events().unwrap().0.len(), "{:?}", f.events().unwrap());
|
||||
assert_eq!(0, f.stage().unwrap().len(), "{:?}", f.stage().unwrap());
|
||||
tests::file_contains(&d, "plain", "[]");
|
||||
});
|
||||
|
|
@ -443,12 +438,7 @@ mod test_file {
|
|||
tests::file_contains(&d, "plain", "new");
|
||||
|
||||
f.stage_persisted().unwrap();
|
||||
assert_eq!(
|
||||
8,
|
||||
f.events().unwrap().0.len(),
|
||||
"{:?}",
|
||||
f.events().unwrap().0
|
||||
);
|
||||
assert_eq!(8, f.events().unwrap().0.len(), "{:?}", f.events().unwrap());
|
||||
assert_eq!(3, f.stage().unwrap().len(), "{:?}", f.stage().unwrap());
|
||||
tests::file_contains(&d, "plain", "new");
|
||||
tests::file_contains(&d, "plain", "old");
|
||||
|
|
@ -467,30 +457,15 @@ mod test_file {
|
|||
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!(1, f.events().unwrap().0.len(), "{:?}", f.events().unwrap());
|
||||
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!(1, f.events().unwrap().0.len(), "{:?}", f.events().unwrap());
|
||||
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!(1, f.events().unwrap().0.len(), "{:?}", f.events().unwrap());
|
||||
assert_eq!(0, f.stage().unwrap().len(), "{:?}", f.stage());
|
||||
});
|
||||
}
|
||||
|
|
@ -504,45 +479,24 @@ mod test_file {
|
|||
".plain.host",
|
||||
format!(
|
||||
r#"
|
||||
{{"ts":1, "op":"Add", "task": "stage"}}
|
||||
{{"ts":2, "op":"Snapshot", "task": null, "tasks": ["removed", "old"]}}
|
||||
{{"ts":3, "op":"Add", "task": "scheduled add for after snapshot"}}
|
||||
{{"ts":2, "op":"Snapshot", "task": null, "tasks": ["removed"]}}
|
||||
"#,
|
||||
//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());
|
||||
assert_eq!(2, f.events().unwrap().0.len(), "{:?}", f.events().unwrap());
|
||||
assert_eq!(1, 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());
|
||||
assert_eq!(4, f.events().unwrap().0.len(), "{:?}", f.events().unwrap());
|
||||
assert_eq!(1, 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());
|
||||
assert_eq!(5, f.events().unwrap().0.len(), "{:?}", f.events().unwrap());
|
||||
assert_eq!(2, f.stage().unwrap().len(), "{:?}", f.stage());
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -557,12 +511,7 @@ mod test_file {
|
|||
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!(1, f.events().unwrap().0.len(), "{:?}", f.events().unwrap());
|
||||
assert_eq!(0, f.stage().unwrap().len(), "{:?}", f.stage());
|
||||
|
||||
f.persist_stage().unwrap();
|
||||
|
|
@ -570,7 +519,7 @@ mod test_file {
|
|||
1,
|
||||
f.events().unwrap().0.len(),
|
||||
"events after 1 add scheduled: {:?}",
|
||||
f.events().unwrap().0
|
||||
f.events().unwrap()
|
||||
);
|
||||
assert_eq!(
|
||||
1,
|
||||
|
|
@ -587,12 +536,7 @@ mod test_file {
|
|||
);
|
||||
|
||||
f.stage_persisted().unwrap();
|
||||
assert_eq!(
|
||||
2,
|
||||
f.events().unwrap().0.len(),
|
||||
"{:?}",
|
||||
f.events().unwrap().0
|
||||
);
|
||||
assert_eq!(2, f.events().unwrap().0.len(), "{:?}", f.events().unwrap());
|
||||
assert_eq!(1, f.stage().unwrap().len(), "{:?}", f.stage());
|
||||
});
|
||||
}
|
||||
|
|
@ -801,9 +745,19 @@ mod test_task {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
#[derive(Clone)]
|
||||
struct Events(Vec<Delta>);
|
||||
|
||||
impl std::fmt::Debug for Events {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
let mut arr = vec![];
|
||||
for i in self.0.iter() {
|
||||
arr.push(format!("{:?}", i.clone()));
|
||||
}
|
||||
write!(f, "[\n {}\n]", arr.join("\n "))
|
||||
}
|
||||
}
|
||||
|
||||
impl Events {
|
||||
pub fn new(file: &String) -> Result<Events, String> {
|
||||
let logs = match std::fs::read_dir(Self::dir(&file)) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue