test(xatu): cover future sight findings

This commit is contained in:
2026-09-18 23:10:43 -04:00
parent 1fa3962fed
commit 06152a012e
2 changed files with 32 additions and 0 deletions

View File

@@ -24,6 +24,12 @@ rust_test(
deps = [":xatu_lib"],
)
rust_test(
name = "xatu_test",
srcs = ["xatu_test.rs"],
deps = [":xatu_lib"],
)
rust_binary(
name = "xatu",
crate_name = "xatu_cli",

26
src/xatu/xatu_test.rs Normal file
View File

@@ -0,0 +1,26 @@
use std::path::PathBuf;
use xatu::SourceFile;
fn source_file(path: &str, source: &str) -> SourceFile {
SourceFile {
path: PathBuf::from(path),
source: source.to_owned(),
}
}
#[test]
fn future_sight_reports_empty_inherit_findings() {
let report = xatu::future_sight(vec![
source_file("clean.nix", "{ inherit foo; }"),
source_file("empty.nix", "{ inherit; }"),
])
.expect("sources should parse");
assert!(!report.is_clean());
assert_eq!(1, report.diagnostics.len());
let diagnostic = &report.diagnostics[0];
assert_eq!(PathBuf::from("empty.nix"), report.files.get(diagnostic.file_id).path);
assert_eq!("empty_inherit", diagnostic.finding.rule_id);
}