// Auto-generated tests for {{cli_name}} - DestructiveOps Category
// Generated by cli-testing-specialist v1.1.0
use assert_cmd::Command;
use predicates::prelude::*;
use std::fs;
use tempfile::TempDir;
/// Test: Delete operation requires confirmation
#[test]
fn test_delete_requires_confirmation() {
let temp_dir = TempDir::new().unwrap();
let test_file = temp_dir.path().join("test.txt");
fs::write(&test_file, "test content").unwrap();
let mut cmd = Command::cargo_bin("{{cli_name}}").unwrap();
cmd.arg("delete")
.arg(test_file.to_str().unwrap())
.write_stdin("n\n") // Reject confirmation
.assert();
// File should still exist after rejecting confirmation
assert!(test_file.exists(), "File should not be deleted when confirmation is rejected");
}
/// Test: Force flag bypasses confirmation
#[test]
fn test_force_flag_bypasses_confirmation() {
let temp_dir = TempDir::new().unwrap();
let test_file = temp_dir.path().join("test.txt");
fs::write(&test_file, "test content").unwrap();
let mut cmd = Command::cargo_bin("{{cli_name}}").unwrap();
cmd.arg("delete")
.arg("--force")
.arg(test_file.to_str().unwrap())
.assert();
// Behavior depends on whether CLI supports --force flag
}
/// Test: Overwrite operation shows warning
#[test]
fn test_overwrite_warning() {
let temp_dir = TempDir::new().unwrap();
let existing_file = temp_dir.path().join("existing.txt");
fs::write(&existing_file, "original content").unwrap();
let mut cmd = Command::cargo_bin("{{cli_name}}").unwrap();
cmd.arg("write")
.arg(existing_file.to_str().unwrap())
.write_stdin("n\n") // Reject overwrite
.assert();
// Original content should be preserved
let content = fs::read_to_string(&existing_file).unwrap();
assert_eq!(content, "original content", "File should not be overwritten when rejected");
}
/// Test: Dry-run mode prevents actual changes
#[test]
fn test_dry_run_mode() {
let temp_dir = TempDir::new().unwrap();
let test_file = temp_dir.path().join("test.txt");
fs::write(&test_file, "test content").unwrap();
let mut cmd = Command::cargo_bin("{{cli_name}}").unwrap();
cmd.arg("delete")
.arg("--dry-run")
.arg(test_file.to_str().unwrap())
.assert()
.stdout(predicate::str::contains("Would delete").or(predicate::str::contains("dry-run")));
// File should still exist in dry-run mode
assert!(test_file.exists(), "File should not be deleted in dry-run mode");
}
/// Test: Batch operation prompts for confirmation
#[test]
fn test_batch_operation_confirmation() {
let temp_dir = TempDir::new().unwrap();
let mut cmd = Command::cargo_bin("{{cli_name}}").unwrap();
cmd.arg("delete")
.arg("--all")
.write_stdin("n\n") // Reject batch operation
.assert();
// Behavior depends on CLI's batch operation implementation
}