completed session tests for lazy and eager has_many_to_many tests
This commit is contained in:
parent
60f03246dc
commit
08a28b1627
|
|
@ -316,6 +316,19 @@ TEST_CASE_METHOD(SessionFixture, "Use session to find all objects with many-to-m
|
||||||
auto res = ses.insert(r);
|
auto res = ses.insert(r);
|
||||||
REQUIRE(res.is_ok());
|
REQUIRE(res.is_ok());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto find_result = ses.find<ingredient>();
|
||||||
|
REQUIRE(find_result.is_ok());
|
||||||
|
auto all_ingredients = find_result.release();
|
||||||
|
std::vector<object_ptr<ingredient>> 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]") {
|
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);
|
auto res = ses.insert(r);
|
||||||
REQUIRE(res.is_ok());
|
REQUIRE(res.is_ok());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto find_result = ses.find<recipe>();
|
||||||
|
REQUIRE(find_result.is_ok());
|
||||||
|
auto all_recipes = find_result.release();
|
||||||
|
std::vector<object_ptr<recipe>> 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());
|
||||||
|
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue