Skip to main content

projection_state

Function projection_state 

Source
pub fn projection_state(root: &Path) -> ProjectionState
Expand description

How PROJECTION stands against MANIFEST: compared as versions, so that a projection behind the manifest — what a bump leaves until the derivation runs — is told apart from one ahead of it or unrelated to it, which no derivation ever writes.

use majordomus_cli::release::version::{projection_state, ProjectionState, MANIFEST, PROJECTION};
let dir = tempfile::tempdir().unwrap();
let root = dir.path();
assert_eq!(projection_state(root), ProjectionState::NotHere);
std::fs::create_dir_all(root.join("apps/majordomus-cli")).unwrap();
std::fs::create_dir_all(root.join("share")).unwrap();
std::fs::write(root.join(MANIFEST), "[package]\nversion = \"0.9.0\"\n").unwrap();
// raised and not yet derived: stale, which a derivation fixes
std::fs::write(root.join(PROJECTION), "version=0.8.0\n").unwrap();
assert!(matches!(projection_state(root), ProjectionState::Stale { .. }));
// a version the manifest never declared: nothing derives that
std::fs::write(root.join(PROJECTION), "version=1.0.0\n").unwrap();
assert!(matches!(projection_state(root), ProjectionState::Disagrees { .. }));
std::fs::write(root.join(PROJECTION), "version=0.9.0\n").unwrap();
assert_eq!(projection_state(root), ProjectionState::Current);