Skip to content

Commit bfbb99f

Browse files
committed
fix(filter): When checking unordered arrays, check normalized values
We fixed this for the ordered case in #358 but missed the unordered case.
1 parent 764b80c commit bfbb99f

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

crates/snapbox/src/filter/pattern.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ fn normalize_value_to_unordered_redactions(
272272
*act = normalize_str_to_unordered_redactions(act, exp, substitutions);
273273
}
274274
(Array(act), Array(exp)) => {
275-
*act = normalize_array_to_unordered_redactions(act, exp);
275+
*act = normalize_array_to_unordered_redactions(act, exp, substitutions);
276276
}
277277
(Object(act), Object(exp)) => {
278278
let has_key_wildcard =
@@ -301,6 +301,7 @@ fn normalize_value_to_unordered_redactions(
301301
fn normalize_array_to_unordered_redactions(
302302
actual: &[serde_json::Value],
303303
expected: &[serde_json::Value],
304+
substitutions: &Redactions,
304305
) -> Vec<serde_json::Value> {
305306
if actual == expected {
306307
return actual.to_owned();
@@ -317,7 +318,13 @@ fn normalize_array_to_unordered_redactions(
317318
elided = true;
318319
} else {
319320
actual_values.retain(|actual_value| {
320-
if !matched && actual_value == expected_value {
321+
let mut normalized_actual_value = actual_value.clone();
322+
normalize_value_to_unordered_redactions(
323+
&mut normalized_actual_value,
324+
expected_value,
325+
substitutions,
326+
);
327+
if !matched && normalized_actual_value == *expected_value {
321328
matched = true;
322329
false
323330
} else {

0 commit comments

Comments
 (0)