test(xatu): relax diagnostic count assertions
This commit is contained in:
@@ -21,11 +21,6 @@ fn fixture_path(path: &str) -> PathBuf {
|
||||
runfiles.join(workspace).join("src/xatu").join(path)
|
||||
}
|
||||
|
||||
fn only_diagnostic(report: &xatu::Report) -> &xatu::Diagnostic {
|
||||
assert_eq!(report.diagnostics.len(), 1);
|
||||
&report.diagnostics[0]
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn future_sight_reports_clean_sources_as_clean() {
|
||||
let report = xatu::future_sight(vec![fixture_source("testdata/clean.nix")])
|
||||
@@ -46,29 +41,29 @@ fn future_sight_rejects_parse_errors() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn future_sight_reports_deprecated_to_path_ident_findings() {
|
||||
let report = xatu::future_sight(vec![SourceFile {
|
||||
path: PathBuf::from("deprecated_to_path_ident.nix"),
|
||||
source: "toPath x\n".to_owned(),
|
||||
}])
|
||||
fn future_sight_reports_deprecated_to_path_findings() {
|
||||
let report = xatu::future_sight(vec![
|
||||
SourceFile {
|
||||
path: PathBuf::from("deprecated_to_path_ident.nix"),
|
||||
source: "toPath x\n".to_owned(),
|
||||
},
|
||||
SourceFile {
|
||||
path: PathBuf::from("deprecated_to_path_select.nix"),
|
||||
source: "builtins.toPath x\n".to_owned(),
|
||||
},
|
||||
])
|
||||
.expect("fixture should parse");
|
||||
|
||||
let diagnostic = only_diagnostic(&report);
|
||||
|
||||
assert_eq!(diagnostic.finding.rule_id, "deprecated_to_path");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn future_sight_reports_deprecated_to_path_select_findings() {
|
||||
let report = xatu::future_sight(vec![SourceFile {
|
||||
path: PathBuf::from("deprecated_to_path_select.nix"),
|
||||
source: "builtins.toPath x\n".to_owned(),
|
||||
}])
|
||||
.expect("fixture should parse");
|
||||
|
||||
let diagnostic = only_diagnostic(&report);
|
||||
|
||||
assert_eq!(diagnostic.finding.rule_id, "deprecated_to_path");
|
||||
assert!(report.diagnostics.iter().any(|diagnostic| {
|
||||
report.files.get(diagnostic.file_id).path.as_path()
|
||||
== Path::new("deprecated_to_path_ident.nix")
|
||||
&& diagnostic.finding.rule_id == "deprecated_to_path"
|
||||
}));
|
||||
assert!(report.diagnostics.iter().any(|diagnostic| {
|
||||
report.files.get(diagnostic.file_id).path.as_path()
|
||||
== Path::new("deprecated_to_path_select.nix")
|
||||
&& diagnostic.finding.rule_id == "deprecated_to_path"
|
||||
}));
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -76,7 +71,8 @@ fn future_sight_reports_empty_inherit_findings() {
|
||||
let report = xatu::future_sight(vec![fixture_source("testdata/empty_inherit.nix")])
|
||||
.expect("fixture should parse");
|
||||
|
||||
let diagnostic = only_diagnostic(&report);
|
||||
|
||||
assert_eq!(diagnostic.finding.rule_id, "empty_inherit");
|
||||
assert!(report.diagnostics.iter().any(|diagnostic| {
|
||||
report.files.get(diagnostic.file_id).path.as_path() == Path::new("testdata/empty_inherit.nix")
|
||||
&& diagnostic.finding.rule_id == "empty_inherit"
|
||||
}));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user