//! `bxctl audit verify` says which files in `audit/` it did not read: a file that looks like a //! log but is not named as one is ignored by `brokerd` too, and "ok" must not seem to cover it. use std::path::PathBuf; fn home(tag: &str) -> PathBuf { let dir = std::env::temp_dir().join(format!("bx-verify-skip-{tag}-{}", std::process::id())); let _ = std::fs::remove_dir_all(&dir); std::fs::create_dir_all(dir.join("audit")).unwrap(); let fixture = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("../proto/tests/fixtures/audit/good"); for entry in std::fs::read_dir(fixture).unwrap() { let entry = entry.unwrap(); std::fs::copy(entry.path(), dir.join("audit").join(entry.file_name())).unwrap(); } dir } #[test] fn a_stray_jsonl_file_is_named_and_the_log_still_verifies() { let dir = home("stray"); std::fs::write(dir.join("audit/2026-0x-19.jsonl"), "x\n").unwrap(); std::fs::write(dir.join("audit/notes.txt"), "not a log\n").unwrap(); let mut out = Vec::new(); let ok = bxctl::verify::run(&dir, &mut out).unwrap(); let text = String::from_utf8(out).unwrap(); assert!(ok, "{text}"); assert!(text.starts_with("audit: ok, 10 records"), "{text}"); assert!( text.contains("not an audit log file, not checked: 2026-0x-19.jsonl"), "{text}" ); assert!( !text.contains("notes.txt"), "only files that look like logs: {text}" ); let _ = std::fs::remove_dir_all(&dir); }