From 48737e0c8a10702a6125de0af590d53b8de64044 Mon Sep 17 00:00:00 2001 From: 123kupola Date: Thu, 25 Jun 2026 23:25:56 +0200 Subject: [PATCH] test(daemon): add default_agent_args unit tests for pi/zot harness MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Three unit tests for the autospawn contract function that determines whether a spawned agent gets rpc-args (zot) or self-driving JSON args (pi / everything else): - default_agent_args_zot_gets_rpc — basename 'zot' → ["rpc"] - default_agent_args_pi_gets_mode_json — basename 'pi' → ["--mode","json"] - default_agent_args_unknown_gets_mode_json — safe default for unknown harnesses (sample-pi-agent.py, colibri-test-agent) Also covers path-prefixed variants (/usr/local/bin/zot, /usr/local/bin/pi) to verify basename extraction works through the spawner pipeline. This closes the untested gap: if someone adds a third harness or changes the basename check, these tests catch the pi-path regression before it reaches the operator who flips from zot to pi. workspace green (0 failures). --- crates/colibri-daemon/src/socket.rs | 35 +++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/crates/colibri-daemon/src/socket.rs b/crates/colibri-daemon/src/socket.rs index fd3d5db..850ec35 100644 --- a/crates/colibri-daemon/src/socket.rs +++ b/crates/colibri-daemon/src/socket.rs @@ -1360,4 +1360,39 @@ mod tests { assert!(path.exists(), "live socket must not be removed"); let _ = std::fs::remove_dir_all(&dir); } + + #[test] + fn default_agent_args_zot_gets_rpc() { + assert_eq!(super::default_agent_args("zot"), vec!["rpc"]); + assert_eq!( + super::default_agent_args("/usr/local/bin/zot"), + vec!["rpc"], + "basename extraction must work for path-prefixed zot" + ); + } + + #[test] + fn default_agent_args_pi_gets_mode_json() { + assert_eq!(super::default_agent_args("pi"), vec!["--mode", "json"]); + assert_eq!( + super::default_agent_args("/usr/local/bin/pi"), + vec!["--mode", "json"], + "basename extraction must work for path-prefixed pi" + ); + } + + #[test] + fn default_agent_args_unknown_gets_mode_json() { + // Any binary that isn't zot gets the self-driving JSON mode. + // This is the safe default — unknown harnesses are assumed to be + // pi-compatible (--mode json), not zot-compatible (rpc). + assert_eq!( + super::default_agent_args("sample-pi-agent.py"), + vec!["--mode", "json"] + ); + assert_eq!( + super::default_agent_args("colibri-test-agent"), + vec!["--mode", "json"] + ); + } }