test(xatu): cover parse failures

This commit is contained in:
2026-09-18 23:19:17 -04:00
parent 6beb4db1e5
commit 7e6ddafe03
3 changed files with 20 additions and 3 deletions

View File

@@ -1,5 +1,6 @@
use std::path::PathBuf;
use status::Code;
use xatu::SourceFile;
fn source_file(path: &str, source: &str) -> SourceFile {
@@ -15,7 +16,7 @@ fn future_sight_reports_clean_sources_as_clean() {
"clean.nix",
include_str!("testdata/clean.nix"),
)])
.expect("source should parse");
.expect("fixture should parse");
assert!(report.is_clean());
}
@@ -26,7 +27,7 @@ fn future_sight_reports_empty_inherit_findings() {
"empty_inherit.nix",
include_str!("testdata/empty_inherit.nix"),
)])
.expect("source should parse");
.expect("fixture should parse");
assert_eq!(1, report.diagnostics.len());
@@ -37,3 +38,14 @@ fn future_sight_reports_empty_inherit_findings() {
);
assert_eq!("empty_inherit", diagnostic.finding.rule_id);
}
#[test]
fn future_sight_rejects_parse_errors() {
let error = xatu::future_sight(vec![source_file(
"invalid.nix",
include_str!("testdata/invalid.nix"),
)])
.expect_err("fixture should fail to parse");
assert_eq!(Code::FailedPrecondition, error.code());
}