// rocie - An enterprise grocery management system // // Copyright (C) 2026 Benedikt Peetz // SPDX-License-Identifier: GPL-3.0-or-later // // This file is part of Rocie. // // You should have received a copy of the License along with this program. // If not, see . use rocie_client::{ apis::{ api_get_auth_recipe_api::recipe_by_id, api_set_auth_recipe_api::add_recipe, api_set_auth_recipe_parent_api::register_recipe_parent, }, models::{RecipeParentStub, RecipeStub}, }; use crate::testenv::{TestEnv, init::function_name, log::request}; #[tokio::test] async fn test_recipe_parent_register_roundtrip() { let env = TestEnv::new(function_name!()).await; let parent_dairy = request!( env, register_recipe_parent(RecipeParentStub { description: Some("Dairy replacment recipes".to_owned()), name: "Dairy replacements".to_owned(), parent: None, }) ); let parent_dairy_milk = request!( env, register_recipe_parent(RecipeParentStub { description: Some("Milk replacment recipes".to_owned()), name: "Milk replacements".to_owned(), parent: Some(parent_dairy), }) ); let recipe_soy_milk = request!( env, add_recipe(RecipeStub { name: "Soy drink".to_owned(), parent: Some(parent_dairy_milk), content: "Mix soy and drink".to_owned() }) ); let recipe_oat_milk = request!( env, add_recipe(RecipeStub { name: "Oat drink".to_owned(), parent: Some(parent_dairy_milk), content: "Mix oat and drink".to_owned() }) ); let recipe_vegan_cheese = request!( env, add_recipe(RecipeStub { name: "Vegan cheese".to_owned(), parent: Some(parent_dairy), content: "Make cheese. Remove cheese".to_owned() }) ); for recipe in [recipe_soy_milk, recipe_oat_milk] { let recipe = request!(env, recipe_by_id(recipe)); assert_eq!(recipe.parent, Some(parent_dairy_milk)); } { let recipe = request!(env, recipe_by_id(recipe_vegan_cheese)); assert_eq!(recipe.parent, Some(parent_dairy)); } }