forked from mitsuhiko/insta
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix some broken tests and add them to the make command (mitsuhiko#97)
- Loading branch information
Showing
8 changed files
with
23 additions
and
40 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 |
---|---|---|
@@ -1,8 +1,8 @@ | ||
--- | ||
source: tests/test_redaction.rs | ||
expression: "&User{id: Uuid::new_v4(),\n username: \"john_doe\".to_string(),\n email: Email(\"[email protected]\".to_string()),\n extra: \"\".to_string(),}" | ||
expression: "&User{id: 23,\n username: \"john_doe\".to_string(),\n email: Email(\"[email protected]\".to_string()),\n extra: \"\".to_string(),}" | ||
--- | ||
id: "[uuid]" | ||
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 |
---|---|---|
@@ -1,9 +1,9 @@ | ||
--- | ||
source: tests/test_redaction.rs | ||
expression: "&User{id: Uuid::new_v4(),\n username: \"jason_doe\".to_string(),\n email: Email(\"[email protected]\".to_string()),\n extra: \"ssn goes here\".to_string(),}" | ||
expression: "&User{id: 9999,\n username: \"jason_doe\".to_string(),\n email: Email(\"[email protected]\".to_string()),\n extra: \"ssn goes here\".to_string(),}" | ||
--- | ||
{ | ||
"id": "[uuid]", | ||
"id": "[id]", | ||
"username": "jason_doe", | ||
"email": "[email protected]", | ||
"extra": "[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 |
---|---|---|
@@ -1,9 +1,9 @@ | ||
--- | ||
source: tests/test_redaction.rs | ||
expression: "&User{id: Uuid::new_v4(),\n username: \"jason_doe\".to_string(),\n email: Email(\"[email protected]\".to_string()),\n extra: \"ssn goes here\".to_string(),}" | ||
expression: "&User{id: 122,\n username: \"jason_doe\".to_string(),\n email: Email(\"[email protected]\".to_string()),\n extra: \"ssn goes here\".to_string(),}" | ||
--- | ||
{ | ||
"id": "[uuid]", | ||
"id": "[id]", | ||
"username": "jason_doe", | ||
"email": "[email protected]", | ||
"extra": "[extra]" | ||
|
4 changes: 2 additions & 2 deletions
4
tests/snapshots/test_redaction__user_json_settings_callback.snap
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 |
---|---|---|
@@ -1,9 +1,9 @@ | ||
--- | ||
source: tests/test_redaction.rs | ||
expression: "&User{id: Uuid::new_v4(),\n username: \"jason_doe\".to_string(),\n email: Email(\"[email protected]\".to_string()),\n extra: \"extra here\".to_string(),}" | ||
expression: "&User{id: 1234,\n username: \"jason_doe\".to_string(),\n email: Email(\"[email protected]\".to_string()),\n extra: \"extra here\".to_string(),}" | ||
--- | ||
{ | ||
"id": "[uuid]", | ||
"id": "[id]", | ||
"username": "jason_doe", | ||
"email": "[email protected]", | ||
"extra": "extra here" | ||
|
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 |
---|---|---|
@@ -1,11 +1,9 @@ | ||
--- | ||
created: "2019-02-01T13:47:54.698182Z" | ||
creator: insta@0.6.0 | ||
source: tests/test_redaction.rs | ||
expression: "&User{id: Uuid::new_v4(),\n username: \"john_ron\".to_string(),\n email: Email(\"[email protected]\".to_string()),\n extra: \"\".to_string(),}" | ||
expression: "&User{id: 53,\n username: \"john_ron\".to_string(),\n email: Email(\"[email protected]\".to_string()),\n extra: \"\".to_string(),}" | ||
--- | ||
User( | ||
id: "[uuid]", | ||
id: "[id]", | ||
username: "john_ron", | ||
email: Email("[email protected]"), | ||
extra: "", | ||
|
4 changes: 2 additions & 2 deletions
4
tests/snapshots/test_redaction__with_random_value_json_settings2.snap
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 |
---|---|---|
@@ -1,9 +1,9 @@ | ||
--- | ||
source: tests/test_redaction.rs | ||
expression: "&User{id: Uuid::new_v4(),\n username: \"jason_doe\".to_string(),\n email: Email(\"[email protected]\".to_string()),\n extra: \"ssn goes here\".to_string(),}" | ||
expression: "&User{id: 975,\n username: \"jason_doe\".to_string(),\n email: Email(\"[email protected]\".to_string()),\n extra: \"ssn goes here\".to_string(),}" | ||
--- | ||
{ | ||
"id": "[uuid]", | ||
"id": "[id]", | ||
"username": "jason_doe", | ||
"email": "[email protected]", | ||
"extra": "[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 |
---|---|---|
|
@@ -42,7 +42,7 @@ fn test_with_random_value() { | |
email: Email("[email protected]".to_string()), | ||
extra: "".to_string(), | ||
}, { | ||
".id" => "[uuid]" | ||
".id" => "[id]" | ||
}); | ||
} | ||
|
||
|
@@ -56,16 +56,8 @@ fn test_with_random_value_inline_callback() { | |
}, { | ||
".id" => insta::dynamic_redaction(|value, path| { | ||
assert_eq!(path.to_string(), ".id"); | ||
assert_eq!( | ||
value | ||
.as_str() | ||
.unwrap() | ||
.chars() | ||
.filter(|&c| c == '-') | ||
.count(), | ||
4 | ||
); | ||
"[uuid]" | ||
assert_eq!(value.as_u64().unwrap(), 23); | ||
"[id]" | ||
}), | ||
}); | ||
} | ||
|
@@ -78,7 +70,7 @@ fn test_with_random_value_and_trailing_comma() { | |
email: Email("[email protected]".to_string()), | ||
extra: "".to_string(), | ||
}, { | ||
".id" => "[uuid]", | ||
".id" => "[id]", | ||
}); | ||
} | ||
|
||
|
@@ -92,7 +84,7 @@ fn test_with_random_value_ron() { | |
email: Email("[email protected]".to_string()), | ||
extra: "".to_string(), | ||
}, { | ||
".id" => "[uuid]" | ||
".id" => "[id]" | ||
}); | ||
} | ||
|
||
|
@@ -104,15 +96,15 @@ fn test_with_random_value_json() { | |
email: Email("[email protected]".to_string()), | ||
extra: "ssn goes here".to_string(), | ||
}, { | ||
".id" => "[uuid]", | ||
".id" => "[id]", | ||
".extra" => "[extra]" | ||
}); | ||
} | ||
|
||
#[test] | ||
fn test_with_random_value_json_settings() { | ||
let mut settings = Settings::new(); | ||
settings.add_redaction(".id", "[uuid]"); | ||
settings.add_redaction(".id", "[id]"); | ||
settings.add_redaction(".extra", "[extra]"); | ||
settings.bind(|| { | ||
assert_json_snapshot!( | ||
|
@@ -132,16 +124,8 @@ fn test_with_callbacks() { | |
let mut settings = Settings::new(); | ||
settings.add_dynamic_redaction(".id", |value, path| { | ||
assert_eq!(path.to_string(), ".id"); | ||
assert_eq!( | ||
value | ||
.as_str() | ||
.unwrap() | ||
.chars() | ||
.filter(|&c| c == '-') | ||
.count(), | ||
4 | ||
); | ||
"[uuid]" | ||
assert_eq!(value.as_u64().unwrap(), 1234); | ||
"[id]" | ||
}); | ||
settings.bind(|| { | ||
assert_json_snapshot!( | ||
|
@@ -159,7 +143,7 @@ fn test_with_callbacks() { | |
#[test] | ||
fn test_with_random_value_json_settings2() { | ||
with_settings!({redactions => vec![ | ||
(".id", "[uuid]".into()), | ||
(".id", "[id]".into()), | ||
(".extra", "[extra]".into()), | ||
]}, { | ||
assert_json_snapshot!( | ||
|