From 08a28b162753c92bbf47b19833388655c6a26ad0 Mon Sep 17 00:00:00 2001 From: sascha Date: Mon, 18 May 2026 14:07:08 +0200 Subject: [PATCH] completed session tests for lazy and eager has_many_to_many tests --- test/backends/SessionTest.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/test/backends/SessionTest.cpp b/test/backends/SessionTest.cpp index 3ecb511..6cabe3a 100644 --- a/test/backends/SessionTest.cpp +++ b/test/backends/SessionTest.cpp @@ -316,6 +316,19 @@ TEST_CASE_METHOD(SessionFixture, "Use session to find all objects with many-to-m auto res = ses.insert(r); REQUIRE(res.is_ok()); } + + auto find_result = ses.find(); + REQUIRE(find_result.is_ok()); + auto all_ingredients = find_result.release(); + std::vector> ingredients_repo; + std::vector expected_ingredients_sizes {2, 1, 1, 1, 1, 1, 1}; + size_t index {0}; + for (auto it = all_ingredients.begin(); it != all_ingredients.end(); ++it) { + REQUIRE(!it->recipes.empty()); + REQUIRE(it->recipes.size() == expected_ingredients_sizes[index++]); + ingredients_repo.emplace_back(it.optr()); + } + REQUIRE(ingredients_repo.size() == ingredients.size()); } TEST_CASE_METHOD(SessionFixture, "Use session to find all objects with many-to-many lazy relation", "[session][find][many-to-many][lazy]") { @@ -352,4 +365,18 @@ TEST_CASE_METHOD(SessionFixture, "Use session to find all objects with many-to-m auto res = ses.insert(r); REQUIRE(res.is_ok()); } + + auto find_result = ses.find(); + REQUIRE(find_result.is_ok()); + auto all_recipes = find_result.release(); + std::vector> recipes_repo; + std::vector expected_recipe_sizes {3, 2, 3}; + size_t index {0}; + for (auto it = all_recipes.begin(); it != all_recipes.end(); ++it) { + REQUIRE(!it->ingredients.empty()); + REQUIRE(it->ingredients.size() == expected_recipe_sizes[index++]); + recipes_repo.emplace_back(it.optr()); + } + REQUIRE(recipes_repo.size() == recipes.size()); + } \ No newline at end of file