test(xatu): use fixture files

This commit is contained in:
2026-09-18 23:13:09 -04:00
parent 06152a012e
commit a2ae2e1500
4 changed files with 15 additions and 3 deletions

View File

@@ -27,6 +27,10 @@ rust_test(
rust_test(
name = "xatu_test",
srcs = ["xatu_test.rs"],
compile_data = [
"testdata/clean.nix",
"testdata/empty_inherit.nix",
],
deps = [":xatu_lib"],
)

1
src/xatu/testdata/clean.nix vendored Normal file
View File

@@ -0,0 +1 @@
{ inherit foo; }

1
src/xatu/testdata/empty_inherit.nix vendored Normal file
View File

@@ -0,0 +1 @@
{ inherit; }

View File

@@ -12,8 +12,11 @@ fn source_file(path: &str, source: &str) -> SourceFile {
#[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; }"),
source_file("clean.nix", include_str!("testdata/clean.nix")),
source_file(
"empty_inherit.nix",
include_str!("testdata/empty_inherit.nix"),
),
])
.expect("sources should parse");
@@ -21,6 +24,9 @@ fn future_sight_reports_empty_inherit_findings() {
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!(
PathBuf::from("empty_inherit.nix"),
report.files.get(diagnostic.file_id).path,
);
assert_eq!("empty_inherit", diagnostic.finding.rule_id);
}