use assert_cmd::Command; use predicates::prelude::*; use std::fs; use tempfile::TempDir; #[test] fn test_cli_help() { let mut cmd = Command::cargo_bin("quicommit").unwrap(); cmd.arg("--help"); cmd.assert() .success() .stdout(predicate::str::contains("QuiCommit")); } #[test] fn test_version() { let mut cmd = Command::cargo_bin("quicommit").unwrap(); cmd.arg("--version"); cmd.assert() .success() .stdout(predicate::str::contains("0.1.0")); } #[test] fn test_config_show() { let temp_dir = TempDir::new().unwrap(); let config_dir = temp_dir.path().join("config"); fs::create_dir(&config_dir).unwrap(); let mut cmd = Command::cargo_bin("quicommit").unwrap(); cmd.env("QUICOMMIT_CONFIG", config_dir.join("config.toml")) .arg("config") .arg("show"); cmd.assert().success(); } #[test] fn test_profile_list_empty() { let temp_dir = TempDir::new().unwrap(); let mut cmd = Command::cargo_bin("quicommit").unwrap(); cmd.env("QUICOMMIT_CONFIG", temp_dir.path().join("config.toml")) .arg("profile") .arg("list"); cmd.assert() .success() .stdout(predicate::str::contains("No profiles configured")); } #[test] fn test_init_quick() { let temp_dir = TempDir::new().unwrap(); let mut cmd = Command::cargo_bin("quicommit").unwrap(); cmd.env("QUICOMMIT_CONFIG", temp_dir.path().join("config.toml")) .arg("init") .arg("--yes"); cmd.assert() .success() .stdout(predicate::str::contains("initialized successfully")); }