use super::{parse_enabled, spawn_if_enabled};
#[test]
fn parse_enabled_defaults_on_and_honours_the_off_switch() {
assert!(parse_enabled(None), "unset must enable the sweep");
assert!(parse_enabled(Some("1")));
assert!(parse_enabled(Some("true")));
assert!(
parse_enabled(Some("")),
"an empty value is not an off switch"
);
for off in ["0", "false", "off", "no", " OFF ", "False"] {
assert!(!parse_enabled(Some(off)), "`{off}` must disable the sweep");
}
}
#[tokio::test]
#[serial_test::serial]
async fn spawn_if_enabled_is_a_noop_when_disabled() {
let dir = tempfile::tempdir().expect("scratch framework root");
let state = std::sync::Arc::new(crate::daemon::state::DaemonState::with_root(
dir.path().to_path_buf(),
));
unsafe { std::env::set_var(super::ENV_ENABLED, "0") };
spawn_if_enabled(state);
unsafe { std::env::remove_var(super::ENV_ENABLED) };
assert!(
!crate::daemon::services::sweep_status::HYGIENE.is_running(),
"a disabled sweep must not start a pass"
);
}