mirror of
https://github.com/Canner/WrenAI.git
synced 2026-10-16 06:57:43 +08:00
test(context-loader): pin the answer, not only that both sides agree
The dangling-edge-source case discarded the downstream set it was handed and asserted only that the two implementations matched. Two implementations that both regressed to treating an undeclared source as a leaf would agree on an empty result, and the case would have gone on passing with the property it exists to pin gone. The assertion goes before the agreement check rather than after it, which is the part worth keeping in mind: a one-sided regression trips agreement first, so an assertion placed after it never runs and cannot report what it was for. The per-kind case gets the same treatment for readability. That one is explicitness rather than a gap — its severity assertion already fails when the target stops being reached, because an empty set is classified as none.
This commit is contained in:
@@ -205,8 +205,17 @@ fn every_kind_classifies_the_same_on_both_sides() {
|
||||
"{kind:?} downstream should be {expected_label}"
|
||||
);
|
||||
assert_eq!(ours.severity.label(), expected_label);
|
||||
// Pin the set as well, for the same reason and in the same order: the severity above is
|
||||
// only meaningful because `target` is what the seed reaches, so a case that stopped
|
||||
// reaching it would assert nothing while still passing.
|
||||
assert_eq!(
|
||||
ours.downstream,
|
||||
vec!["target".to_string()],
|
||||
"{kind:?} case must actually reach its target"
|
||||
);
|
||||
// ...and that the framework still agrees while it computes its own copy.
|
||||
assert_agrees_on(&graph, "model:root");
|
||||
let downstream = assert_agrees_on(&graph, "model:root");
|
||||
assert_eq!(downstream, ours.downstream);
|
||||
assert_agrees_everywhere(&graph);
|
||||
}
|
||||
}
|
||||
@@ -277,7 +286,25 @@ fn a_dangling_edge_source_agrees_too() {
|
||||
nodes: vec![node("dashboard:sales", LineageKind::Dashboard)],
|
||||
edges: vec![edge("model:missing", "dashboard:sales")],
|
||||
};
|
||||
assert_agrees_on(&graph, "model:missing");
|
||||
// Pin the answer *before* checking agreement, deliberately. Agreement alone is not enough:
|
||||
// if both sides ever treated an undeclared source as a leaf they would agree on an empty
|
||||
// result and this case would pass while the property it exists to pin had gone. Asserting the
|
||||
// value first also keeps it from being shadowed — a one-sided regression would otherwise trip
|
||||
// the agreement check and this assertion would never run.
|
||||
let ours = ImpactGraph::from(&graph).impact("model:missing");
|
||||
assert_eq!(
|
||||
ours.downstream,
|
||||
vec!["dashboard:sales".to_string()],
|
||||
"an undeclared seed's edges are still followed"
|
||||
);
|
||||
assert_eq!(
|
||||
ours.severity,
|
||||
Severity::Semantic,
|
||||
"and the dashboard it reaches still sets the class"
|
||||
);
|
||||
|
||||
let downstream = assert_agrees_on(&graph, "model:missing");
|
||||
assert_eq!(downstream, ours.downstream);
|
||||
assert_agrees_everywhere(&graph);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user