#![allow(
clippy::unwrap_used,
clippy::expect_used,
clippy::panic,
clippy::needless_raw_string_hashes,
clippy::duration_suboptimal_units,
clippy::branches_sharing_code,
clippy::used_underscore_binding,
clippy::single_char_pattern,
clippy::ignore_without_reason,
clippy::cloned_ref_to_slice_refs,
clippy::doc_overindented_list_items,
clippy::match_wildcard_for_single_variants,
clippy::ignored_unit_patterns,
clippy::needless_collect,
clippy::unnecessary_map_or,
clippy::manual_flatten,
clippy::manual_strip,
clippy::future_not_send,
clippy::unnested_or_patterns,
clippy::no_effect_underscore_binding,
clippy::literal_string_with_formatting_args
)]
use assert_cmd::Command;
use predicates::prelude::*;
#[test]
fn test_cli_binary_exists_and_runs() {
let mut cmd = Command::cargo_bin("ggen").unwrap();
cmd.arg("--version")
.assert()
.success()
.stdout(predicate::str::contains("ggen"));
}
#[test]
#[ignore = "ggen obsolete subcommands removed; CLI consolidated to sync (v26_5_19+)"]
fn test_help_displays_auto_discovered_commands() {
let mut cmd = Command::cargo_bin("ggen").unwrap();
let output = cmd.arg("--help").assert().success();
output
.stdout(predicate::str::contains("ai"))
.stdout(predicate::str::contains("audit"))
.stdout(predicate::str::contains("ci"))
.stdout(predicate::str::contains("doctor"))
.stdout(predicate::str::contains("graph"))
.stdout(predicate::str::contains("hook"))
.stdout(predicate::str::contains("lifecycle"))
.stdout(predicate::str::contains("market"))
.stdout(predicate::str::contains("project"))
.stdout(predicate::str::contains("shell"))
.stdout(predicate::str::contains("template"));
}
#[test]
#[ignore = "ggen doctor help text updated; CLI consolidated to sync (v26_5_19+)"]
fn test_doctor_command_routes_correctly() {
let mut cmd = Command::cargo_bin("ggen").unwrap();
let output = cmd.arg("doctor").arg("--help").assert().success();
output.stdout(predicate::str::contains("Check system prerequisites"));
}
#[test]
#[ignore = "ggen template subcommand removed; CLI consolidated to sync (v26_5_19+)"]
fn test_template_command_routes_correctly() {
let mut cmd = Command::cargo_bin("ggen").unwrap();
let output = cmd.arg("template").arg("--help").assert().success();
output.stdout(predicate::str::contains("Template management"));
}
#[test]
#[ignore = "ggen market subcommand removed; CLI consolidated to sync (v26_5_19+)"]
fn test_market_command_routes_correctly() {
let mut cmd = Command::cargo_bin("ggen").unwrap();
let output = cmd.arg("market").arg("--help").assert().success();
output.stdout(predicate::str::contains("Marketplace operations"));
}
#[test]
fn test_invalid_command_shows_error() {
let mut cmd = Command::cargo_bin("ggen").unwrap();
let output = cmd.arg("nonexistent").assert().failure();
output.stderr(predicate::str::contains("error"));
}
#[test]
#[ignore = "ggen global flags updated; CLI consolidated to sync (v26_5_19+)"]
fn test_global_flags_work_before_command() {
let mut cmd = Command::cargo_bin("ggen").unwrap();
cmd.arg("--debug")
.arg("true")
.arg("doctor")
.arg("--help")
.assert()
.success();
}
#[test]
#[ignore = "ggen otel flags updated; CLI consolidated to sync (v26_5_19+)"]
fn test_otel_flags_are_recognized() {
let mut cmd = Command::cargo_bin("ggen").unwrap();
let output = cmd.arg("--help").assert().success();
output
.stdout(predicate::str::contains("--enable-otel"))
.stdout(predicate::str::contains("--otel-endpoint"));
}
#[test]
#[ignore = "ggen config flag removed; CLI consolidated to sync (v26_5_19+)"]
fn test_config_flag_is_recognized() {
let mut cmd = Command::cargo_bin("ggen").unwrap();
let output = cmd.arg("--help").assert().success();
output.stdout(predicate::str::contains("--config"));
}
#[test]
#[ignore = "ggen manifest-path flag renamed to manifest; CLI consolidated to sync (v26_5_19+)"]
fn test_manifest_path_flag_is_recognized() {
let mut cmd = Command::cargo_bin("ggen").unwrap();
let output = cmd.arg("--help").assert().success();
output.stdout(predicate::str::contains("--manifest-path"));
}
#[test]
fn test_commands_execute_with_real_binary() {
let mut cmd = Command::cargo_bin("ggen").unwrap();
cmd.arg("doctor").assert().code(predicate::in_iter([0, 1]));
}
#[test]
#[ignore = "ggen help-me subcommand removed; CLI consolidated to sync (v26_5_19+)"]
fn test_help_progressive_command_exists() {
let mut cmd = Command::cargo_bin("ggen").unwrap();
let output = cmd.arg("help-me").arg("--help").assert().success();
output.stdout(predicate::str::contains("personalized help"));
}
#[test]
#[ignore = "ggen auto-discovery commands list updated; CLI consolidated to sync (v26_5_19+)"]
fn test_auto_discovery_finds_all_command_modules() {
let mut cmd = Command::cargo_bin("ggen").unwrap();
let output = cmd.arg("--help").assert().success();
let stdout = String::from_utf8(output.get_output().stdout.clone()).unwrap();
let command_count = [
"ai",
"audit",
"ci",
"doctor",
"graph",
"help-me",
"hook",
"lifecycle",
"market",
"project",
"shell",
"template",
]
.iter()
.filter(|&cmd_name| stdout.contains(cmd_name))
.count();
assert!(
command_count >= 10,
"Expected at least 10 commands, found {}",
command_count
);
}