use assert_cmd::prelude::*; use predicates::prelude::*; use std::fs::File; use std::io::Write; use std::process::Command; use tempfile::TempDir; #[test] fn test_basic_cli_run() { let mut cmd = Command::new(env!("CARGO_BIN_EXE_sized")); cmd.arg("--version") .assert() .success() .stdout(predicate::str::contains("sized 0.2.0")); } #[test] fn test_run_on_directory() { let temp_dir = TempDir::new().unwrap(); let file_path = temp_dir.path().join("test_file.txt"); File::create(&file_path) .unwrap() .write_all(b"Hello") .unwrap(); let mut cmd = Command::new(env!("CARGO_BIN_EXE_sized")); cmd.arg(temp_dir.path()) .assert() .success() .stdout(predicate::str::contains("test_file.txt")); // Basic check } #[test] fn test_json_output() { let temp_dir = TempDir::new().unwrap(); let file_path = temp_dir.path().join("data.json"); File::create(&file_path).unwrap().write_all(b"{}").unwrap(); let mut cmd = Command::new(env!("CARGO_BIN_EXE_sized")); cmd.arg(temp_dir.path()) .arg("--format") .arg("json") .assert() .success() .stdout(predicate::str::contains("\"entry_type\":\"File\"")) .stdout(predicate::str::contains("\"path\":")); }