codex-memory 3.0.15

A simple memory storage service with MCP interface for Claude Desktop
Documentation
use std::process::Command;

/// Test to ensure CLI help text consistently references the correct binary name
/// as defined in Cargo.toml. This prevents user confusion from mixed naming.
#[tokio::test]
async fn test_cli_help_binary_name_consistency() -> Result<(), Box<dyn std::error::Error>> {
    // Test main help output
    let output = Command::new("cargo")
        .args(["run", "--bin", "codex-memory", "--", "--help"])
        .output()?;

    let help_text = String::from_utf8(output.stdout)?;

    // Verify that help shows correct binary name in Usage line
    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("")
    );

    // Verify no references to old binary names
    assert!(
        !help_text.contains("codex-store") && !help_text.contains("codex "),
        "CLI help should not contain any references to 'codex-store' or standalone 'codex'"
    );

    Ok(())
}

/// Test that setup command help shows consistent naming
#[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)?;

    // Should show codex-memory in usage
    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(())
}

/// Test that binary builds with correct name and can be executed
#[tokio::test]
async fn test_binary_compilation_name() -> Result<(), Box<dyn std::error::Error>> {
    // Build the project
    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)
    );

    // Verify binary exists with correct name
    let binary_path = "./target/release/codex-memory";
    let metadata = std::fs::metadata(binary_path);
    assert!(metadata.is_ok(), "Binary should exist at {}", binary_path);

    // Verify binary is executable
    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(())
}