Skip to main content

observe_generation

Function observe_generation 

Source
pub fn observe_generation(root: &Path) -> GenerationObservation
Expand description

The generation record scripts/pages current left, and HEAD’s tree to judge it against. Git is asked only when there is a record to judge.

use majordomus_cli::environment::preflight::{observe_generation, GenerationObservation, GENERATION_RECORD};
let dir = tempfile::tempdir().unwrap();
assert_eq!(observe_generation(dir.path()), GenerationObservation::Absent);
let path = dir.path().join(GENERATION_RECORD);
std::fs::create_dir_all(path.parent().unwrap()).unwrap();
std::fs::write(&path, r#"{"schema": 9, "at": "t", "outcome": "pass"}"#).unwrap();
assert!(matches!(observe_generation(dir.path()), GenerationObservation::Unreadable(_)));