Skip to content

Commit

Permalink
get fancy with redactions
Browse files Browse the repository at this point in the history
Signed-off-by: simonsan <[email protected]>
  • Loading branch information
simonsan committed Mar 13, 2024
1 parent 80c03a1 commit 3f51f3b
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 7 deletions.
15 changes: 14 additions & 1 deletion crates/core/tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,21 @@ fn insta_summary_redaction() -> Settings {
let mut settings = insta::Settings::clone_current();

settings.add_redaction(".tree", "[tree_id]");
settings.add_redaction(".program_version", "[version]");
settings.add_dynamic_redaction(".program_version", |val, _| {
val.resolve_inner()
.as_str()
.map_or("[program_version]".to_string(), |v| {
v.replace(env!("CARGO_PKG_VERSION"), "[rustic_core_version]")
})
});
settings.add_redaction(".time", "[time]");
settings.add_dynamic_redaction(".parent", |val, _| {
if val.is_nil() {
"[none]".to_string()
} else {
"[some]".to_string()
}
});
settings.add_redaction(".tags", "[tags]");
settings.add_redaction(".id", "[id]");
settings.add_redaction(".summary.backup_start", "[backup_start]");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ expression: TestSummary(&first_snapshot)
---
TestSummary(SnapshotFile(
time: "[time]",
program_version: "[version]",
program_version: "rustic [rustic_core_version]",
tree: "[tree_id]",
paths: StringList([
"test",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ expression: TestSummary(&second_snapshot)
---
TestSummary(SnapshotFile(
time: "[time]",
program_version: "[version]",
parent: Some(Id("1e1c441c94bb94db891589deac182ac69d2cf2c8a434081e5608515553833cd1")),
program_version: "rustic [rustic_core_version]",
parent: "[some]",
tree: "[tree_id]",
paths: StringList([
"test",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ expression: TestSummary(&snap_dry_run)
---
TestSummary(SnapshotFile(
time: "[time]",
program_version: "[version]",
program_version: "rustic [rustic_core_version]",
tree: "[tree_id]",
paths: StringList([
"test",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ expression: TestSummary(&snap_dry_run)
---
TestSummary(SnapshotFile(
time: "[time]",
program_version: "[version]",
parent: Some(Id("f25b23c13b9c895d57d6017d466abe317b57b5db280c996d86ea1fe4db423743")),
program_version: "rustic [rustic_core_version]",
parent: "[some]",
tree: "[tree_id]",
paths: StringList([
"test",
Expand Down

0 comments on commit 3f51f3b

Please sign in to comment.