This commit is contained in:
47
tests/cli_tests.rs
Normal file
47
tests/cli_tests.rs
Normal file
@@ -0,0 +1,47 @@
|
||||
use assert_cmd::Command;
|
||||
use std::path::PathBuf;
|
||||
|
||||
#[test]
|
||||
fn test_cli_help() {
|
||||
let mut cmd = Command::cargo_bin("techdebt-tracker-cli").unwrap();
|
||||
cmd.arg("--help")
|
||||
.assert()
|
||||
.success();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_cli_version() {
|
||||
let mut cmd = Command::cargo_bin("techdebt-tracker-cli").unwrap();
|
||||
cmd.arg("--version")
|
||||
.assert()
|
||||
.success();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_init_command() {
|
||||
let temp_dir = tempfile::tempdir().unwrap();
|
||||
let temp_path = temp_dir.path().to_path_buf();
|
||||
|
||||
let mut cmd = Command::cargo_bin("techdebt-tracker-cli").unwrap();
|
||||
cmd.arg("init")
|
||||
.arg("--path")
|
||||
.arg(&temp_path)
|
||||
.assert()
|
||||
.success();
|
||||
|
||||
let config_path = temp_path.join("techdebt.yaml");
|
||||
assert!(config_path.exists());
|
||||
|
||||
let content = std::fs::read_to_string(&config_path).unwrap();
|
||||
assert!(content.contains("patterns:"));
|
||||
assert!(content.contains("languages:"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_analyze_command_nonexistent_path() {
|
||||
let mut cmd = Command::cargo_bin("techdebt-tracker-cli").unwrap();
|
||||
cmd.arg("analyze")
|
||||
.arg("/nonexistent/path")
|
||||
.assert()
|
||||
.failure();
|
||||
}
|
||||
Reference in New Issue
Block a user