Files
dirigent/crates/dirigent_fermata/tests/cli_check.rs
T
2026-05-08 01:59:04 +02:00

53 lines
1.5 KiB
Rust

use assert_cmd::Command;
use predicates::prelude::*;
use std::fs;
#[test]
fn check_blocks_botignore_match() {
let tmp = tempfile::tempdir().unwrap();
fs::write(tmp.path().join(".botignore"), ".env\n").unwrap();
let target = tmp.path().join(".env");
fs::write(&target, "").unwrap();
Command::cargo_bin("fermata")
.unwrap()
.args(["check", "--op", "read", target.to_str().unwrap()])
.assert()
.failure()
.code(1)
.stdout(predicate::str::contains(".env"));
}
#[test]
fn check_allows_unmatched() {
let tmp = tempfile::tempdir().unwrap();
fs::write(tmp.path().join(".botignore"), ".env\n").unwrap();
let target = tmp.path().join("src.rs");
fs::write(&target, "").unwrap();
Command::cargo_bin("fermata")
.unwrap()
.args(["check", "--op", "read", target.to_str().unwrap()])
.assert()
.success();
}
#[test]
fn check_emits_json_with_flag() {
let tmp = tempfile::tempdir().unwrap();
fs::write(tmp.path().join(".botignore"), ".env\n").unwrap();
let target = tmp.path().join(".env");
fs::write(&target, "").unwrap();
let out = Command::cargo_bin("fermata")
.unwrap()
.args(["check", "--op", "read", "--json", target.to_str().unwrap()])
.assert()
.failure()
.get_output()
.stdout
.clone();
let v: serde_json::Value = serde_json::from_slice(&out).unwrap();
assert_eq!(v["kind"], "deny");
}