diff --git a/crates/odin-daemon/src/main.rs b/crates/odin-daemon/src/main.rs index b19eb48..ff75b2c 100644 --- a/crates/odin-daemon/src/main.rs +++ b/crates/odin-daemon/src/main.rs @@ -3012,12 +3012,37 @@ mod tests { assert_ne!(second.0, first.0, "one write once the interval passed"); assert_eq!(odin.file_records()?, odin.working_set()); - odin.timers.last_flush = None; + // The write itself starts the next interval: a change right after it + // waits. + provider_put(&odin, "ghostlight.doc.v1", "doc-late", vec![1])?; odin.pass()?; assert_eq!(file_identity(&odin.store)?, second, "and only one"); Ok(()) } + /// A correlation for an incarnation Idunn no longer projects is found + /// through the correlations Odin holds, and the refresh pass withdraws it. + #[test] + fn a_correlation_whose_incarnation_is_no_longer_projected_is_withdrawn() -> Result<()> { + let mut odin = activated_odin()?; + odin.pass()?; + let candidate = project_candidate_incarnation(&odin)?; + odin.state.borrow().refresh_all_correlations()?; + let correlations = || odin.stored_keys(OdinRuntimeTopologyCorrelationRecord::TYPE); + assert!(correlations()?.contains(&candidate.key())); + + odin.tamper_projection(|entries| { + entries + .into_iter() + .filter(|entry| entry.key != candidate.key()) + .collect() + })?; + odin.state.borrow().refresh_all_correlations()?; + assert!(!correlations()?.contains(&candidate.key())); + assert_eq!(correlations()?.len(), 1, "Odin's own stays"); + Ok(()) + } + /// An interval in which nothing changed writes nothing, however often the /// write is due. With nothing to write the write step reads nothing /// either, not even the lease: it is due on every pass until something