use assert_cmd::{cargo_bin, Command};
use predicates::prelude::*;
use std::fs;
use tempfile::TempDir;
#[test]
fn test_no_matches_shows_simple_message() {
let temp_dir = TempDir::new().unwrap();
let mut cmd = Command::new(cargo_bin!("cs"));
cmd.arg("nonexistent text")
.current_dir(temp_dir.path())
.assert()
.success() .stdout(predicate::str::contains("No matches found"));
}
#[test]
fn test_yaml_parse_error_is_handled_gracefully() {
let temp_dir = TempDir::new().unwrap();
let yaml_path = temp_dir.path().join("invalid.yml");
fs::write(&yaml_path, "key: [invalid yaml structure test").unwrap();
let mut cmd = Command::new(cargo_bin!("cs"));
cmd.arg("--verbose") .arg("test")
.current_dir(temp_dir.path())
.assert()
.success() .stdout(predicate::str::contains("test")); }
#[test]
fn test_json_parse_error_is_handled_gracefully() {
let temp_dir = TempDir::new().unwrap();
let json_path = temp_dir.path().join("invalid.json");
fs::write(&json_path, "{ key: 'invalid json test' }").unwrap();
let mut cmd = Command::new(cargo_bin!("cs"));
cmd.arg("--verbose") .arg("test")
.current_dir(temp_dir.path())
.assert()
.success() .stdout(predicate::str::contains("test")); }