use crate::boot::*;
use crate::fake::ScriptedRunner;
use crate::testing::test_paths;
#[tokio::test]
async fn an_unreadable_dog_defaults_store_refuses_the_boot_and_names_the_file() {
let _guard = SIGNAL_TEST_LOCK.lock().await;
let dir = tempfile::tempdir().unwrap();
let paths = test_paths(&dir);
init_dirs(&paths).unwrap();
std::fs::write(&paths.dog_defaults, "{ not json").unwrap();
let refused = boot_with_idle_sweep(
ScriptedRunner::new(vec![]),
paths.clone(),
BootOptions::default(),
)
.await;
let Err(BootError::DogDefaults { path, .. }) = refused else {
panic!("expected the boot to be refused over the store");
};
assert_eq!(path, paths.dog_defaults);
}
#[tokio::test]
async fn a_second_boot_reports_the_running_daemon_before_the_dog_defaults_store() {
let _guard = SIGNAL_TEST_LOCK.lock().await;
let dir = tempfile::tempdir().unwrap();
let paths = test_paths(&dir);
init_dirs(&paths).unwrap();
let _held = PidfileLock::acquire(&paths).unwrap();
std::fs::write(&paths.dog_defaults, "{ not json").unwrap();
let refused = boot_with_idle_sweep(
ScriptedRunner::new(vec![]),
paths.clone(),
BootOptions::default(),
)
.await;
assert!(
matches!(refused, Err(BootError::AlreadyRunning { .. })),
"expected AlreadyRunning"
);
}