use std::process::Command;
#[tokio::test]
async fn test_cli_help_binary_name_consistency() -> Result<(), Box<dyn std::error::Error>> {
let output = Command::new("cargo")
.args(["run", "--bin", "codex-memory", "--", "--help"])
.output()?;
let help_text = String::from_utf8(output.stdout)?;
assert!(
help_text.contains("Usage: codex-memory"),
"CLI help should show 'Usage: codex-memory', found: {}",
help_text
.lines()
.find(|l| l.contains("Usage:"))
.unwrap_or("")
);
assert!(
!help_text.contains("codex-store") && !help_text.contains("codex "),
"CLI help should not contain any references to 'codex-store' or standalone 'codex'"
);
Ok(())
}
#[tokio::test]
async fn test_setup_command_help_consistency() -> Result<(), Box<dyn std::error::Error>> {
let output = Command::new("cargo")
.args(["run", "--bin", "codex-memory", "--", "setup", "--help"])
.output()?;
let help_text = String::from_utf8(output.stdout)?;
assert!(
help_text.contains("Usage: codex-memory setup"),
"Setup help should show 'Usage: codex-memory setup', found: {}",
help_text
.lines()
.find(|l| l.contains("Usage:"))
.unwrap_or("")
);
Ok(())
}
#[tokio::test]
async fn test_binary_compilation_name() -> Result<(), Box<dyn std::error::Error>> {
let build_output = Command::new("cargo")
.args(["build", "--release"])
.output()?;
assert!(
build_output.status.success(),
"Build should succeed: {}",
String::from_utf8_lossy(&build_output.stderr)
);
let binary_path = "./target/release/codex-memory";
let metadata = std::fs::metadata(binary_path);
assert!(metadata.is_ok(), "Binary should exist at {}", binary_path);
let exec_output = Command::new(binary_path).args(["--version"]).output()?;
assert!(
exec_output.status.success(),
"Binary should be executable and respond to --version"
);
let version_text = String::from_utf8(exec_output.stdout)?;
assert!(
version_text.contains("codex-memory"),
"Version output should contain 'codex-memory', got: {}",
version_text
);
Ok(())
}