mod common;
use common::Sandbox;
use std::net::TcpListener;
#[test]
fn init_rejects_an_unknown_flag_and_plants_no_store() {
let c = Sandbox::new_empty("init-bogus");
let (out, code) = c.run(&["init", "--bogus"]);
assert_eq!(code, 2, "{out}");
assert!(out.contains("--bogus"), "{out}");
assert!(
!c.0.join(".vivac").exists(),
"it planted a tree before noticing the flag:\n{out}"
);
}
#[test]
fn hooks_rejects_an_unknown_flag_and_prints_nothing() {
let c = Sandbox::new_seeded("hooks-bogus");
let (out, code) = c.run(&["hooks", "--bogus"]);
assert_eq!(code, 2, "{out}");
assert!(out.contains("--bogus"), "{out}");
assert!(
!out.contains("Paste this into"),
"it printed the hooks anyway:\n{out}"
);
}
#[test]
fn mcp_rejects_an_unknown_flag_without_waiting_on_standard_input() {
let c = Sandbox::new_empty("mcp-bogus");
let (out, code) = c.run(&["mcp", "--bogus"]);
assert_eq!(code, 2, "{out}");
assert!(out.contains("--bogus"), "{out}");
}
#[test]
fn web_rejects_an_unknown_flag_without_binding_a_port() {
let c = Sandbox::new_empty("web-bogus");
let port = {
let listener = TcpListener::bind(("127.0.0.1", 0)).unwrap();
listener.local_addr().unwrap().port()
};
let (out, code) = c.run(&["web", "--port", &port.to_string(), "--no-open", "--bogus"]);
assert_eq!(code, 2, "{out}");
assert!(out.contains("--bogus"), "{out}");
assert!(
TcpListener::bind(("127.0.0.1", port)).is_ok(),
"something is still holding the port:\n{out}"
);
}