2022-04-02 12:05:23 +00:00
|
|
|
use gravatar_rs::Generator;
|
|
|
|
|
|
|
|
const BAUKE_EMAIL: &str = "me@bauke.xyz";
|
|
|
|
const HOLLLO_EMAIL: &str = "helllo@holllo.cc";
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_hash_email() {
|
2022-04-02 13:19:19 +00:00
|
|
|
let samples = [("bauke", BAUKE_EMAIL), ("holllo", HOLLLO_EMAIL)];
|
|
|
|
|
|
|
|
for (name, email) in samples {
|
|
|
|
insta::assert_snapshot!(
|
|
|
|
format!("hash-{name}"),
|
|
|
|
Generator::hash_email(email)
|
|
|
|
);
|
|
|
|
|
|
|
|
insta::assert_snapshot!(
|
|
|
|
format!("hash-{name}-whitespace"),
|
|
|
|
Generator::hash_email(&format!(" {email} "))
|
|
|
|
);
|
|
|
|
|
|
|
|
insta::assert_snapshot!(
|
|
|
|
format!("hash-{name}-casing"),
|
|
|
|
Generator::hash_email(&email.to_uppercase())
|
|
|
|
);
|
|
|
|
}
|
2022-04-02 12:05:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_generator() {
|
2022-04-02 13:19:19 +00:00
|
|
|
let emails = [BAUKE_EMAIL, HOLLLO_EMAIL];
|
|
|
|
let samples = [
|
|
|
|
("gravatar", Generator::default().base_url),
|
|
|
|
("libravatar", "cdn.libravatar.org".to_string()),
|
|
|
|
];
|
|
|
|
|
|
|
|
for (name, base_url) in samples {
|
|
|
|
let generator = Generator::default().set_base_url(&base_url);
|
|
|
|
let urls = emails.map(|email| generator.generate(email));
|
|
|
|
insta::assert_debug_snapshot!(format!("generate-{name}"), urls);
|
2022-04-02 12:05:23 +00:00
|
|
|
}
|
|
|
|
}
|