use std::path::Path;
use std::fs;
#[test]
fn test_scan_size_native() {
let test_dir = Path::new("/tmp/sweep-test");
if !test_dir.exists() {
println!("SKIP: /tmp/sweep-test not found. Create test data first.");
return;
}
let output = std::process::Command::new(env!("CARGO_BIN_EXE_sweep"))
.args(["recommend", "--json"])
.output()
.expect("Failed to run sweep");
let stdout = String::from_utf8_lossy(&output.stdout);
assert!(stdout.contains("recommendations"), "JSON output should contain recommendations");
assert!(stdout.contains("total_reclaimable"), "JSON output should contain total_reclaimable");
println!("recommend --json output:\n{}", stdout);
}
#[test]
fn test_timeline_no_cache() {
let output = std::process::Command::new(env!("CARGO_BIN_EXE_sweep"))
.args(["timeline", "--json"])
.output()
.expect("Failed to run sweep");
let stdout = String::from_utf8_lossy(&output.stdout);
assert!(stdout.contains("changes"), "Timeline JSON should have changes field");
println!("timeline --json output:\n{}", stdout);
}
#[test]
fn test_history_json_empty() {
let output = std::process::Command::new(env!("CARGO_BIN_EXE_sweep"))
.args(["history", "--json"])
.output()
.expect("Failed to run sweep");
let stdout = String::from_utf8_lossy(&output.stdout);
assert!(stdout.starts_with('['), "History JSON should be an array, got: {}", stdout);
println!("history --json output:\n{}", stdout);
}
#[test]
fn test_help_shows_new_commands() {
let output = std::process::Command::new(env!("CARGO_BIN_EXE_sweep"))
.args(["--help"])
.output()
.expect("Failed to run sweep");
let stdout = String::from_utf8_lossy(&output.stdout);
assert!(stdout.contains("timeline"), "--help should list timeline command");
assert!(stdout.contains("recommend"), "--help should list recommend command");
assert!(stdout.contains("--json"), "--help should list --json flag");
assert!(stdout.contains("--force"), "--help should list --force flag");
println!("--help output:\n{}", stdout);
}
#[test]
fn test_version() {
let output = std::process::Command::new(env!("CARGO_BIN_EXE_sweep"))
.args(["--version"])
.output()
.expect("Failed to run sweep");
let stdout = String::from_utf8_lossy(&output.stdout);
assert!(stdout.contains("0.3.1"), "Version should be 0.3.1, got: {}", stdout);
}