1
Fork 0

Replace individual snapshots with a Vec snapshot.

This commit is contained in:
Bauke 2022-04-02 22:04:17 +02:00
parent 52fb210268
commit 471656abc5
Signed by: Bauke
GPG Key ID: C1C0F29952BCF558
11 changed files with 64 additions and 57 deletions

View File

@ -6,23 +6,23 @@ const HOLLLO_EMAIL: &str = "helllo@holllo.cc";
#[test] #[test]
fn test_hash_email() { fn test_hash_email() {
let samples = [("bauke", BAUKE_EMAIL), ("holllo", HOLLLO_EMAIL)]; let samples = [("bauke", BAUKE_EMAIL), ("holllo", HOLLLO_EMAIL)];
let mut snapshot = vec![];
for (name, email) in samples { for (name, email) in samples {
insta::assert_snapshot!( snapshot.push((format!("hash-{name}"), Generator::hash_email(email)));
format!("hash-{name}"),
Generator::hash_email(email)
);
insta::assert_snapshot!( snapshot.push((
format!("hash-{name}-whitespace"), format!("hash-{name}-whitespace"),
Generator::hash_email(&format!(" {email} ")) Generator::hash_email(&format!(" {email} ")),
); ));
insta::assert_snapshot!( snapshot.push((
format!("hash-{name}-casing"), format!("hash-{name}-casing"),
Generator::hash_email(&email.to_uppercase()) Generator::hash_email(&email.to_uppercase()),
); ));
} }
insta::assert_debug_snapshot!("hash-email", snapshot);
} }
#[test] #[test]
@ -32,12 +32,15 @@ fn test_generator() {
("gravatar", Generator::default().base_url), ("gravatar", Generator::default().base_url),
("libravatar", "cdn.libravatar.org".to_string()), ("libravatar", "cdn.libravatar.org".to_string()),
]; ];
let mut snapshot = vec![];
for (name, base_url) in samples { for (name, base_url) in samples {
let generator = Generator::default().set_base_url(&base_url); let generator = Generator::default().set_base_url(&base_url);
let urls = emails.map(|email| generator.generate(email)); let urls = emails.map(|email| generator.generate(email));
insta::assert_debug_snapshot!(format!("generate-{name}"), urls); snapshot.push((format!("generate-{name}"), urls));
} }
insta::assert_debug_snapshot!("generator", snapshot);
} }
#[test] #[test]

View File

@ -1,8 +0,0 @@
---
source: tests/lib.rs
expression: urls
---
[
"https://www.gravatar.com/avatar/ecd836ee843ff0ab75d4720bd40c2baf",
"https://www.gravatar.com/avatar/ebff9105dce4954b1bdb57fdab079ff3",
]

View File

@ -1,8 +0,0 @@
---
source: tests/lib.rs
expression: urls
---
[
"https://cdn.libravatar.org/avatar/ecd836ee843ff0ab75d4720bd40c2baf",
"https://cdn.libravatar.org/avatar/ebff9105dce4954b1bdb57fdab079ff3",
]

View File

@ -0,0 +1,20 @@
---
source: tests/lib.rs
expression: snapshot
---
[
(
"generate-gravatar",
[
"https://www.gravatar.com/avatar/ecd836ee843ff0ab75d4720bd40c2baf",
"https://www.gravatar.com/avatar/ebff9105dce4954b1bdb57fdab079ff3",
],
),
(
"generate-libravatar",
[
"https://cdn.libravatar.org/avatar/ecd836ee843ff0ab75d4720bd40c2baf",
"https://cdn.libravatar.org/avatar/ebff9105dce4954b1bdb57fdab079ff3",
],
),
]

View File

@ -1,5 +0,0 @@
---
source: tests/lib.rs
expression: "Generator::hash_email(&email.to_uppercase())"
---
ecd836ee843ff0ab75d4720bd40c2baf

View File

@ -1,5 +0,0 @@
---
source: tests/lib.rs
expression: "Generator::hash_email(&format!(\" {email} \"))"
---
ecd836ee843ff0ab75d4720bd40c2baf

View File

@ -1,5 +0,0 @@
---
source: tests/lib.rs
expression: "Generator::hash_email(email)"
---
ecd836ee843ff0ab75d4720bd40c2baf

View File

@ -0,0 +1,30 @@
---
source: tests/lib.rs
expression: snapshot
---
[
(
"hash-bauke",
"ecd836ee843ff0ab75d4720bd40c2baf",
),
(
"hash-bauke-whitespace",
"ecd836ee843ff0ab75d4720bd40c2baf",
),
(
"hash-bauke-casing",
"ecd836ee843ff0ab75d4720bd40c2baf",
),
(
"hash-holllo",
"ebff9105dce4954b1bdb57fdab079ff3",
),
(
"hash-holllo-whitespace",
"ebff9105dce4954b1bdb57fdab079ff3",
),
(
"hash-holllo-casing",
"ebff9105dce4954b1bdb57fdab079ff3",
),
]

View File

@ -1,5 +0,0 @@
---
source: tests/lib.rs
expression: "Generator::hash_email(&email.to_uppercase())"
---
ebff9105dce4954b1bdb57fdab079ff3

View File

@ -1,5 +0,0 @@
---
source: tests/lib.rs
expression: "Generator::hash_email(&format!(\" {email} \"))"
---
ebff9105dce4954b1bdb57fdab079ff3

View File

@ -1,5 +0,0 @@
---
source: tests/lib.rs
expression: "Generator::hash_email(email)"
---
ebff9105dce4954b1bdb57fdab079ff3