-
-
Notifications
You must be signed in to change notification settings - Fork 110
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow
debug
expressions in redaction macros
It's can be a bit confusing when some macros have features which others don't have. So this adds debug expressions to the redaction macros. (Though they do get quite long; possibly we want to recommend something like `description` in place of `debug` throughout?)
- Loading branch information
Showing
6 changed files
with
94 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
source: src/test.rs | ||
expression: "&User {\n id: 42,\n username: \"john_doe\".to_string(),\n email: Email(\"[email protected]\".to_string()),\n extra: \"\".to_string(),\n }" | ||
--- | ||
id: "[id]" | ||
username: john_doe | ||
email: john@example.com | ||
extra: "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
source: src/test.rs | ||
expression: "&User {\n id: 42,\n username: \"john_doe\".to_string(),\n email: Email(\"[email protected]\".to_string()),\n extra: \"\".to_string(),\n }" | ||
--- | ||
id: "[id]" | ||
username: john_doe | ||
email: john@example.com | ||
extra: "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
source: tests/test_redaction.rs | ||
assertion_line: 78 | ||
expression: "&user" | ||
--- | ||
id: "[id]" | ||
username: john_doe | ||
email: [email protected] | ||
extra: "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
source: tests/test_redaction.rs | ||
expression: "&User {\n id: 42,\n username: \"john_doe\".to_string(),\n email: Email(\"[email protected]\".to_string()),\n extra: \"\".to_string(),\n }" | ||
--- | ||
id: "[id]" | ||
username: john_doe | ||
email: john@example.com | ||
extra: "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,6 +56,44 @@ fn test_with_random_value() { | |
}); | ||
} | ||
|
||
#[cfg(feature = "yaml")] | ||
#[test] | ||
fn test_name_expr() { | ||
let user = User { | ||
id: 42, | ||
username: "john_doe".to_string(), | ||
email: Email("[email protected]".to_string()), | ||
extra: "".to_string(), | ||
}; | ||
|
||
// unnamed | ||
assert_yaml_snapshot!( | ||
&user, | ||
match .. { | ||
".id" => "[id]", | ||
} | ||
); | ||
|
||
// named, no debug expr | ||
assert_yaml_snapshot!( | ||
"name", | ||
&user, | ||
match .. { | ||
".id" => "[id]", | ||
} | ||
); | ||
|
||
// named, debug expr | ||
assert_yaml_snapshot!( | ||
"name", | ||
&user, | ||
"debug expr", | ||
match .. { | ||
".id" => "[id]", | ||
} | ||
); | ||
} | ||
|
||
#[cfg(feature = "yaml")] | ||
#[test] | ||
fn test_with_random_value_inline_callback() { | ||
|