diff --git a/src/xatu/BUILD b/src/xatu/BUILD index 0bc0330..9624c64 100644 --- a/src/xatu/BUILD +++ b/src/xatu/BUILD @@ -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", diff --git a/src/xatu/xatu_test.rs b/src/xatu/xatu_test.rs new file mode 100644 index 0000000..43a73de --- /dev/null +++ b/src/xatu/xatu_test.rs @@ -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); +}