test(xatu): cover nested let ordering

This commit is contained in:
2026-09-26 19:55:27 -04:00
parent 64f1f35088
commit 591b3c76e4
2 changed files with 15 additions and 10 deletions

View File

@@ -1,10 +1,17 @@
let
second = 2;
second = first;
first = 1;
nested = let
nestedFirst = first;
nestedSecond = nestedFirst;
in {
result = nestedSecond;
};
in {
package = package;
from = pkgs.from;
url = https://example.com;
firstField = first;
secondField = second;
nestedField = nested;
}

View File

@@ -42,17 +42,15 @@ fn xatu_rejects_invalid_source() -> googletest::Result<()> {
}
#[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()?;
expect_that!(
report
.diagnostics
.iter()
.map(|diagnostic| diagnostic.finding.rule_id)
.collect::<Vec<_>>(),
contains(eq(&"let_order"))
);
let let_order_count = report
.diagnostics
.iter()
.filter(|diagnostic| diagnostic.finding.rule_id == "let_order")
.count();
expect_that!(let_order_count, eq(4));
Ok(())
}