31 lines
915 B
Rust
31 lines
915 B
Rust
use super::types;
|
|
use crate::repo::ingredient::IngredientRepo;
|
|
|
|
pub fn execute(repo: &impl IngredientRepo) -> Vec<types::Ingredient> {
|
|
repo.get_ingredients()
|
|
}
|
|
|
|
#[cfg(test)]
|
|
mod tests {
|
|
use super::*;
|
|
use crate::domain::ingredient::types::Lang;
|
|
|
|
#[test]
|
|
fn should_return_all_ingredients() {
|
|
let repo = crate::repo::ingredient::InMemoryIngredientRepo::new();
|
|
let res = execute(&repo);
|
|
|
|
match res.as_slice() {
|
|
[first, second] => {
|
|
assert_eq!(first.key, String::from("apple"));
|
|
assert_eq!(first.lang, Lang::Rus);
|
|
assert_eq!(first.name, String::from("Яблоко"));
|
|
assert_eq!(second.key, String::from("salt"));
|
|
assert_eq!(second.lang, Lang::Rus);
|
|
assert_eq!(second.name, String::from("Соль"));
|
|
}
|
|
_ => unimplemented!(),
|
|
}
|
|
}
|
|
}
|