Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions tests/cli_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,44 @@ fn test_run_agent_locally_description_absent() {
the run subcommand now queues ADO builds. Got:\n{stdout}"
);
}

/// Guard that lifecycle subcommands (`list`, `disable`, `remove`, `status`) each
/// appear as a named entry in the top-level Commands section of `ado-aw --help`.
///
/// Checking only within the Commands section (between "Commands:" and "Options:")
/// prevents false-positives from description prose that incidentally contains
/// one of these common words.
///
/// This replaces four per-file one-word `stdout.contains()` tests that
/// unnecessarily spawned `ado-aw --help` four times and made no attempt to
/// isolate the Commands section.
#[test]
fn test_lifecycle_subcommands_appear_in_top_level_help_commands_section() {
let binary_path = PathBuf::from(env!("CARGO_BIN_EXE_ado-aw"));
let output = std::process::Command::new(&binary_path)
.arg("--help")
.output()
.expect("Failed to run ado-aw --help");

assert!(output.status.success(), "--help should succeed");
let stdout = String::from_utf8_lossy(&output.stdout);
let lower = stdout.to_lowercase();

let commands_start = lower
.find("commands:")
.expect("top-level --help should contain a 'Commands:' section");
let options_start = lower
.find("options:")
.expect("top-level --help should contain an 'Options:' section");
let commands_block = &lower[commands_start..options_start];

for cmd in ["list", "disable", "remove", "status"] {
// Each lifecycle subcommand must appear as a command-line entry
// (indented two spaces before the name) in the Commands section.
assert!(
commands_block.contains(&format!(" {cmd}")),
"Expected '{cmd}' to be listed in the Commands section of `ado-aw --help`; \
commands block was:\n{commands_block}"
);
}
}
14 changes: 0 additions & 14 deletions tests/disable_integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,3 @@ fn disable_help_describes_command() {
);
}
}

#[test]
fn disable_is_listed_in_top_level_help() {
let output = std::process::Command::new(binary())
.arg("--help")
.output()
.expect("Failed to run ado-aw --help");
assert!(output.status.success(), "--help should exit 0");
let stdout = String::from_utf8_lossy(&output.stdout);
assert!(
stdout.contains("disable"),
"Top-level --help should mention the disable subcommand, got:\n{stdout}"
);
}
14 changes: 0 additions & 14 deletions tests/list_integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,3 @@ fn list_help_describes_command() {
);
}
}

#[test]
fn list_is_in_top_level_help() {
let output = std::process::Command::new(binary())
.arg("--help")
.output()
.expect("Failed to run ado-aw --help");
assert!(output.status.success(), "--help should exit 0");
let stdout = String::from_utf8_lossy(&output.stdout);
assert!(
stdout.contains("list"),
"Top-level --help should mention the list subcommand, got:\n{stdout}"
);
}
14 changes: 0 additions & 14 deletions tests/remove_integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,3 @@ fn remove_help_describes_command() {
);
}
}

#[test]
fn remove_is_listed_in_top_level_help() {
let output = std::process::Command::new(binary())
.arg("--help")
.output()
.expect("Failed to run ado-aw --help");
assert!(output.status.success(), "--help should exit 0");
let stdout = String::from_utf8_lossy(&output.stdout);
assert!(
stdout.contains("remove"),
"Top-level --help should mention the remove subcommand, got:\n{stdout}"
);
}
14 changes: 0 additions & 14 deletions tests/status_integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,3 @@ fn status_help_describes_command() {
);
}
}

#[test]
fn status_is_in_top_level_help() {
let output = std::process::Command::new(binary())
.arg("--help")
.output()
.expect("Failed to run ado-aw --help");
assert!(output.status.success(), "--help should exit 0");
let stdout = String::from_utf8_lossy(&output.stdout);
assert!(
stdout.contains("status"),
"Top-level --help should mention the status subcommand, got:\n{stdout}"
);
}