When using the sorted_redaction it seems to be important to place the sorting redactions at the end which I did not expect to matter. Also using [] as the selector instead of . also seems to fix the issue in the example below but does not seem to work if the redacted key value pair is nested somewhere deeper.
Reproduction steps
// insta = { version = "1.41.1", features = ["json", "redactions"] }
// rand = "*"
// serde_json = "*"
#[test]
fn insta_sorting_bug() {
use insta::assert_json_snapshot;
use rand::random;
use serde_json::json;
let json = json!([
{
"a": random::<bool>(),
"z": 1,
},
{
"a": random::<bool>(),
"z": 2,
}
]);
// Inconsistent
assert_json_snapshot!(json, {
"." => insta::sorted_redaction(),
"[].a" => "[redacted]",
});
// Consistent
// assert_json_snapshot!(json, {
// "[].a" => "[redacted]",
// "." => insta::sorted_redaction(),
// });
// Consistent for this case but not for more deeply nested redacted values
// assert_json_snapshot!(json, {
// "[]" => insta::sorted_redaction(),
// "[].a" => "[redacted]",
// });
}
Insta Version
1.41.1
rustc Version
1.81
What did you expect?
Redaction order to not be important or its importance mentioned in the docs of sorted_redaction.
What happened?
When using the
sorted_redaction
it seems to be important to place the sorting redactions at the end which I did not expect to matter. Also using[]
as the selector instead of.
also seems to fix the issue in the example below but does not seem to work if the redacted key value pair is nested somewhere deeper.Reproduction steps
Insta Version
1.41.1
rustc Version
1.81
What did you expect?
Redaction order to not be important or its importance mentioned in the docs of
sorted_redaction
.