// Tests for mecha10_cli::handlers::clean

use mecha10_cli::handlers::clean::*;

#[test]
fn test_clean_args() {
    let args = CleanArgs {
        all: true,
        release: false,
        logs: true,
    };

    assert!(args.all);
    assert!(!args.release);
    assert!(args.logs);
}

#[test]
fn test_clean_args_minimal() {
    let args = CleanArgs {
        all: false,
        release: false,
        logs: false,
    };

    assert!(!args.all);
    assert!(!args.release);
    assert!(!args.logs);
}

#[tokio::test]
async fn test_clean_packages() -> Result<()> {
    use tempfile::TempDir;

    // Create temporary directory structure
    let temp = TempDir::new()?;
    let packages_dir = temp.path().join("target/packages");
    tokio::fs::create_dir_all(&packages_dir).await?;

    // Create test .tar.gz files
    tokio::fs::write(packages_dir.join("test-1.0.0.tar.gz"), "test").await?;
    tokio::fs::write(packages_dir.join("test-1.0.1.tar.gz"), "test").await?;

    assert!(packages_dir.join("test-1.0.0.tar.gz").exists());
    assert!(packages_dir.join("test-1.0.1.tar.gz").exists());

    // Clean packages (this would need to be adapted to work with temp dir)
    // For now, just verify the directory structure was created
    assert!(packages_dir.exists());

    Ok(())
}
