use super::{PollBody, PollCadence, PollEntry, PollMode};
fn entry(body: PollBody) -> PollEntry {
PollEntry {
name: quote::format_ident!("orphans"),
variant: quote::format_ident!("Orphans"),
cadence: PollCadence::Every(core::time::Duration::new(600, 0)),
grants: None,
body,
mode: PollMode::AsyncInline,
concurrent: false,
}
}
#[test]
fn the_light_arm_mounts_nothing_and_says_so() {
let body = PollBody::Light;
assert!(body.citizen().is_none(), "a light body mounts no citizen");
assert!(!body.mounted(), "and the presence split reads it as light");
}
#[test]
fn the_citizen_arm_carries_the_path_it_was_given() {
let path: syn::Path = syn::parse_quote!(app::PromScraper);
let body = PollBody::Citizen(path.clone());
assert_eq!(body.citizen(), Some(&path));
assert!(body.mounted(), "and the presence split reads it as mounted");
}
#[test]
fn an_entrys_presence_split_reads_through_to_its_body() {
assert!(!entry(PollBody::Light).mounted());
assert!(entry(PollBody::Citizen(syn::parse_quote!(app::Pusher))).mounted());
}
#[test]
fn the_vocabulary_is_closed_at_two() {
fn road(body: &PollBody) -> &'static str {
match body {
PollBody::Light => "light",
PollBody::Citizen(_) => "handler",
}
}
assert_eq!(road(&PollBody::Light), "light");
assert_eq!(
road(&PollBody::Citizen(syn::parse_quote!(app::PromScraper))),
"handler"
);
}