faker_rust/default/
coffee.rs1use crate::base::sample;
4use crate::locale::{fetch_locale_with_context, sample_with_resolve};
5
6pub fn blend_name() -> String {
8 fetch_locale_with_context("coffee.blend_name", "en", Some("coffee"))
9 .map(|v| sample_with_resolve(&v, Some("coffee")))
10 .unwrap_or_else(|| sample(FALLBACK_BLEND_NAMES).to_string())
11}
12
13pub fn country() -> String {
15 fetch_locale_with_context("coffee.country", "en", Some("coffee"))
16 .map(|v| sample_with_resolve(&v, Some("coffee")))
17 .unwrap_or_else(|| sample(FALLBACK_COUNTRIES).to_string())
18}
19
20pub fn variety() -> String {
22 fetch_locale_with_context("coffee.variety", "en", Some("coffee"))
23 .map(|v| sample_with_resolve(&v, Some("coffee")))
24 .unwrap_or_else(|| sample(FALLBACK_VARIETIES).to_string())
25}
26
27pub fn notes() -> String {
29 fetch_locale_with_context("coffee.notes", "en", Some("coffee"))
30 .map(|v| sample_with_resolve(&v, Some("coffee")))
31 .unwrap_or_else(|| sample(FALLBACK_NOTES).to_string())
32}
33
34const FALLBACK_BLEND_NAMES: &[&str] = &["Summer Solstice", "Winter Wonderland", "Midnight Brew"];
36const FALLBACK_COUNTRIES: &[&str] = &["Ethiopia", "Colombia", "Vietnam", "Brazil", "Indonesia"];
37const FALLBACK_VARIETIES: &[&str] = &["Arabica", "Robusta", "Caturra", "Bourbon", "Typica"];
38const FALLBACK_NOTES: &[&str] = &["fruity", "chocolatey", "nutty", "caramel", "acidic"];
39
40#[cfg(test)]
41mod tests {
42 use super::*;
43
44 #[test]
45 fn test_blend_name() {
46 assert!(!blend_name().is_empty());
47 }
48
49 #[test]
50 fn test_country() {
51 assert!(!country().is_empty());
52 }
53}