test(xatu): use fixture files
This commit is contained in:
@@ -27,6 +27,10 @@ rust_test(
|
|||||||
rust_test(
|
rust_test(
|
||||||
name = "xatu_test",
|
name = "xatu_test",
|
||||||
srcs = ["xatu_test.rs"],
|
srcs = ["xatu_test.rs"],
|
||||||
|
compile_data = [
|
||||||
|
"testdata/clean.nix",
|
||||||
|
"testdata/empty_inherit.nix",
|
||||||
|
],
|
||||||
deps = [":xatu_lib"],
|
deps = [":xatu_lib"],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
1
src/xatu/testdata/clean.nix
vendored
Normal file
1
src/xatu/testdata/clean.nix
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
{ inherit foo; }
|
||||||
1
src/xatu/testdata/empty_inherit.nix
vendored
Normal file
1
src/xatu/testdata/empty_inherit.nix
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
{ inherit; }
|
||||||
@@ -12,8 +12,11 @@ fn source_file(path: &str, source: &str) -> SourceFile {
|
|||||||
#[test]
|
#[test]
|
||||||
fn future_sight_reports_empty_inherit_findings() {
|
fn future_sight_reports_empty_inherit_findings() {
|
||||||
let report = xatu::future_sight(vec![
|
let report = xatu::future_sight(vec![
|
||||||
source_file("clean.nix", "{ inherit foo; }"),
|
source_file("clean.nix", include_str!("testdata/clean.nix")),
|
||||||
source_file("empty.nix", "{ inherit; }"),
|
source_file(
|
||||||
|
"empty_inherit.nix",
|
||||||
|
include_str!("testdata/empty_inherit.nix"),
|
||||||
|
),
|
||||||
])
|
])
|
||||||
.expect("sources should parse");
|
.expect("sources should parse");
|
||||||
|
|
||||||
@@ -21,6 +24,9 @@ fn future_sight_reports_empty_inherit_findings() {
|
|||||||
assert_eq!(1, report.diagnostics.len());
|
assert_eq!(1, report.diagnostics.len());
|
||||||
|
|
||||||
let diagnostic = &report.diagnostics[0];
|
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);
|
assert_eq!("empty_inherit", diagnostic.finding.rule_id);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user