test(xatu): cover future sight findings
This commit is contained in:
@@ -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
26
src/xatu/xatu_test.rs
Normal 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);
|
||||
}
|
||||
Reference in New Issue
Block a user