diff --git a/Makefile b/Makefile index 11e7e315..6b39dc69 100644 --- a/Makefile +++ b/Makefile @@ -11,6 +11,7 @@ test: cargotest cargotest: @rustup component add rustfmt 2> /dev/null @cargo test + @cargo test --all-features @cargo test --no-default-features @cd cargo-insta; cargo test diff --git a/tests/snapshots/test_redaction__user.snap b/tests/snapshots/test_redaction__user.snap index 8deb31de..f74f62d3 100644 --- a/tests/snapshots/test_redaction__user.snap +++ b/tests/snapshots/test_redaction__user.snap @@ -1,8 +1,8 @@ --- source: tests/test_redaction.rs -expression: "&User{id: Uuid::new_v4(),\n username: \"john_doe\".to_string(),\n email: Email(\"john@example.com\".to_string()),\n extra: \"\".to_string(),}" +expression: "&User{id: 23,\n username: \"john_doe\".to_string(),\n email: Email(\"john@example.com\".to_string()),\n extra: \"\".to_string(),}" --- -id: "[uuid]" +id: "[id]" username: john_doe email: john@example.com extra: "" diff --git a/tests/snapshots/test_redaction__user_json.snap b/tests/snapshots/test_redaction__user_json.snap index d6101231..c8ed9d88 100644 --- a/tests/snapshots/test_redaction__user_json.snap +++ b/tests/snapshots/test_redaction__user_json.snap @@ -1,9 +1,9 @@ --- source: tests/test_redaction.rs -expression: "&User{id: Uuid::new_v4(),\n username: \"jason_doe\".to_string(),\n email: Email(\"jason@example.com\".to_string()),\n extra: \"ssn goes here\".to_string(),}" +expression: "&User{id: 9999,\n username: \"jason_doe\".to_string(),\n email: Email(\"jason@example.com\".to_string()),\n extra: \"ssn goes here\".to_string(),}" --- { - "id": "[uuid]", + "id": "[id]", "username": "jason_doe", "email": "jason@example.com", "extra": "[extra]" diff --git a/tests/snapshots/test_redaction__user_json_settings.snap b/tests/snapshots/test_redaction__user_json_settings.snap index d6101231..c7429973 100644 --- a/tests/snapshots/test_redaction__user_json_settings.snap +++ b/tests/snapshots/test_redaction__user_json_settings.snap @@ -1,9 +1,9 @@ --- source: tests/test_redaction.rs -expression: "&User{id: Uuid::new_v4(),\n username: \"jason_doe\".to_string(),\n email: Email(\"jason@example.com\".to_string()),\n extra: \"ssn goes here\".to_string(),}" +expression: "&User{id: 122,\n username: \"jason_doe\".to_string(),\n email: Email(\"jason@example.com\".to_string()),\n extra: \"ssn goes here\".to_string(),}" --- { - "id": "[uuid]", + "id": "[id]", "username": "jason_doe", "email": "jason@example.com", "extra": "[extra]" diff --git a/tests/snapshots/test_redaction__user_json_settings_callback.snap b/tests/snapshots/test_redaction__user_json_settings_callback.snap index f224ac66..e80e7e81 100644 --- a/tests/snapshots/test_redaction__user_json_settings_callback.snap +++ b/tests/snapshots/test_redaction__user_json_settings_callback.snap @@ -1,9 +1,9 @@ --- source: tests/test_redaction.rs -expression: "&User{id: Uuid::new_v4(),\n username: \"jason_doe\".to_string(),\n email: Email(\"jason@example.com\".to_string()),\n extra: \"extra here\".to_string(),}" +expression: "&User{id: 1234,\n username: \"jason_doe\".to_string(),\n email: Email(\"jason@example.com\".to_string()),\n extra: \"extra here\".to_string(),}" --- { - "id": "[uuid]", + "id": "[id]", "username": "jason_doe", "email": "jason@example.com", "extra": "extra here" diff --git a/tests/snapshots/test_redaction__user_ron.snap b/tests/snapshots/test_redaction__user_ron.snap index cdc270a8..da83abb3 100644 --- a/tests/snapshots/test_redaction__user_ron.snap +++ b/tests/snapshots/test_redaction__user_ron.snap @@ -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(\"john@example.com\".to_string()),\n extra: \"\".to_string(),}" +expression: "&User{id: 53,\n username: \"john_ron\".to_string(),\n email: Email(\"john@example.com\".to_string()),\n extra: \"\".to_string(),}" --- User( - id: "[uuid]", + id: "[id]", username: "john_ron", email: Email("john@example.com"), extra: "", diff --git a/tests/snapshots/test_redaction__with_random_value_json_settings2.snap b/tests/snapshots/test_redaction__with_random_value_json_settings2.snap index d6101231..72e4e062 100644 --- a/tests/snapshots/test_redaction__with_random_value_json_settings2.snap +++ b/tests/snapshots/test_redaction__with_random_value_json_settings2.snap @@ -1,9 +1,9 @@ --- source: tests/test_redaction.rs -expression: "&User{id: Uuid::new_v4(),\n username: \"jason_doe\".to_string(),\n email: Email(\"jason@example.com\".to_string()),\n extra: \"ssn goes here\".to_string(),}" +expression: "&User{id: 975,\n username: \"jason_doe\".to_string(),\n email: Email(\"jason@example.com\".to_string()),\n extra: \"ssn goes here\".to_string(),}" --- { - "id": "[uuid]", + "id": "[id]", "username": "jason_doe", "email": "jason@example.com", "extra": "[extra]" diff --git a/tests/test_redaction.rs b/tests/test_redaction.rs index 8ec62acb..0e6f637e 100644 --- a/tests/test_redaction.rs +++ b/tests/test_redaction.rs @@ -42,7 +42,7 @@ fn test_with_random_value() { email: Email("john@example.com".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("john@example.com".to_string()), extra: "".to_string(), }, { - ".id" => "[uuid]", + ".id" => "[id]", }); } @@ -92,7 +84,7 @@ fn test_with_random_value_ron() { email: Email("john@example.com".to_string()), extra: "".to_string(), }, { - ".id" => "[uuid]" + ".id" => "[id]" }); } @@ -104,7 +96,7 @@ fn test_with_random_value_json() { email: Email("jason@example.com".to_string()), extra: "ssn goes here".to_string(), }, { - ".id" => "[uuid]", + ".id" => "[id]", ".extra" => "[extra]" }); } @@ -112,7 +104,7 @@ fn test_with_random_value_json() { #[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!(