Skip to main content

observe

Function observe 

Source
pub fn observe(
    deployment: &str,
    base: &str,
    identity: &str,
    expected: &str,
    fetch: &dyn Fetch,
    git: &dyn Ancestry,
    at: SystemTime,
) -> Observation
Expand description

Probes base once and judges the result against expected, returning the record. Writes nothing: append is what keeps it.

use majordomus_cli::served::{observe, Ancestry, Fetch, Fetched, ServedVerdict};
use std::time::SystemTime;
struct Nothing;
impl Fetch for Nothing {
    fn fetch(&self, _: &str) -> Fetched { Fetched::Unreachable("no route".into()) }
}
struct Any;
impl Ancestry for Any {
    fn has(&self, _: &str) -> Option<bool> { Some(true) }
    fn contains(&self, _: &str, _: &str) -> Option<bool> { Some(true) }
}
let o = observe("pages", "https://s", "build.json", &"a".repeat(40), &Nothing, &Any,
                SystemTime::UNIX_EPOCH);
assert_eq!(o.judgement.verdict, ServedVerdict::Unreachable);
assert!(o.served.is_none());