use super::*;
use std::sync::Arc;
use std::sync::atomic::{AtomicU32, Ordering};
#[tokio::test]
async fn notify_spawn_delivers_pid_before_wait() {
let captured = Arc::new(AtomicU32::new(0));
let captured_clone = captured.clone();
let hook: OnSpawnHook = Arc::new(move |pid| {
captured_clone.store(pid, Ordering::SeqCst);
});
let mut cmd = Command::new("true");
CommonAgentState::run_interactive_command_with_hook(&mut cmd, "Test", Some(&hook))
.await
.expect("`true` must exit 0");
let pid = captured.load(Ordering::SeqCst);
assert!(pid > 0, "expected a non-zero child pid, got {pid}");
}
#[tokio::test]
async fn notify_spawn_without_hook_is_noop() {
let mut cmd = Command::new("true");
CommonAgentState::run_interactive_command_with_hook(&mut cmd, "Test", None)
.await
.expect("`true` must exit 0");
}
#[tokio::test]
async fn legacy_two_arg_signature_still_works() {
let mut cmd = Command::new("true");
CommonAgentState::run_interactive_command(&mut cmd, "Test")
.await
.expect("`true` must exit 0");
}