test(xy): auto-start + stop/start lifecycle

This commit is contained in:
2026-05-25 12:05:28 +02:00
parent 48d63a0549
commit 434828c14e
+31
View File
@@ -0,0 +1,31 @@
mod common;
use common::*;
#[tokio::test]
async fn auto_starts_on_boot_then_stop_and_start() {
let xy = xy_bin();
let sleeper = sleep_server_bin();
let mut h = Harness::new();
h.write_server("alpha", sleeper.to_str().unwrap(), 19_001, "always");
h.start_daemon(&xy).await;
let mut last_stdout = String::new();
for _ in 0..40 {
let (_c, out, _e) = h.run_cli(&xy, &["list"]).await;
last_stdout = out;
if last_stdout.contains("alpha") && last_stdout.contains("running") {
break;
}
tokio::time::sleep(std::time::Duration::from_millis(100)).await;
}
assert!(last_stdout.contains("alpha"), "stdout: {last_stdout}");
assert!(last_stdout.contains("running"), "stdout: {last_stdout}");
let (code, out, _e) = h.run_cli(&xy, &["stop", "alpha"]).await;
assert_eq!(code, 0);
assert!(out.contains("stopped: alpha"), "stdout: {out}");
let (code, out, _e) = h.run_cli(&xy, &["start", "alpha"]).await;
assert_eq!(code, 0);
assert!(out.contains("started: alpha"), "stdout: {out}");
}