test(xatu): cover nested let ordering
This commit is contained in:
9
src/xatu/testdata/lint_findings.nix
vendored
9
src/xatu/testdata/lint_findings.nix
vendored
@@ -1,10 +1,17 @@
|
|||||||
let
|
let
|
||||||
second = 2;
|
second = first;
|
||||||
first = 1;
|
first = 1;
|
||||||
|
nested = let
|
||||||
|
nestedFirst = first;
|
||||||
|
nestedSecond = nestedFirst;
|
||||||
|
in {
|
||||||
|
result = nestedSecond;
|
||||||
|
};
|
||||||
in {
|
in {
|
||||||
package = package;
|
package = package;
|
||||||
from = pkgs.from;
|
from = pkgs.from;
|
||||||
url = https://example.com;
|
url = https://example.com;
|
||||||
firstField = first;
|
firstField = first;
|
||||||
secondField = second;
|
secondField = second;
|
||||||
|
nestedField = nested;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,17 +42,15 @@ fn xatu_rejects_invalid_source() -> googletest::Result<()> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[gtest]
|
#[gtest]
|
||||||
fn xatu_reports_out_of_order_let_binding() -> googletest::Result<()> {
|
fn xatu_reports_out_of_order_let_bindings() -> googletest::Result<()> {
|
||||||
let report = xatu::future_sight(vec![fixture_source("testdata/lint_findings.nix")?]).or_fail()?;
|
let report = xatu::future_sight(vec![fixture_source("testdata/lint_findings.nix")?]).or_fail()?;
|
||||||
|
|
||||||
expect_that!(
|
let let_order_count = report
|
||||||
report
|
.diagnostics
|
||||||
.diagnostics
|
.iter()
|
||||||
.iter()
|
.filter(|diagnostic| diagnostic.finding.rule_id == "let_order")
|
||||||
.map(|diagnostic| diagnostic.finding.rule_id)
|
.count();
|
||||||
.collect::<Vec<_>>(),
|
expect_that!(let_order_count, eq(4));
|
||||||
contains(eq(&"let_order"))
|
|
||||||
);
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user