diff --git a/test/backends/SessionInsertHasMany.cpp b/test/backends/SessionInsertHasMany.cpp index 4502cb2..8ec8915 100644 --- a/test/backends/SessionInsertHasMany.cpp +++ b/test/backends/SessionInsertHasMany.cpp @@ -188,7 +188,7 @@ TEST_CASE_METHOD(SessionFixture, "Test insert object with has many relation with REQUIRE(author->books.size() == 5); } -TEST_CASE_METHOD(SessionFixture, "Test insert object with has many primitive relation with table sequence", "[session][insert][has_many][primitive][table_sequence]") { +TEST_CASE_METHOD(SessionFixture, "Test insert object with has many primitive relation with identity", "[session][insert][has_many][primitive][identity]") { const auto result = schema.attach("colorlist") .and_then([this] { return schema.create(db); } ); REQUIRE(result.is_ok()); @@ -209,4 +209,50 @@ TEST_CASE_METHOD(SessionFixture, "Test insert object with has many primitive rel for (const auto &cstr: clist->colors) { REQUIRE(std::find(expected_colors.begin(), expected_colors.end(), cstr) != expected_colors.end()); } -} \ No newline at end of file +} + +TEST_CASE_METHOD(SessionFixture, "Test insert object with has many primitive relation with table sequence", "[session][insert][has_many][primitive][table_sequence]") { + const auto result = schema.attach("colorlist") + .and_then([this] { return schema.create(db); } ); + REQUIRE(result.is_ok()); + + session ses({bus, connection::dns, 4}, schema); + + const auto c = make_object("rgb", std::vector{"red", "green", "blue"}); + + auto res = ses.insert(c); + REQUIRE(res.is_ok()); + + auto colorlist_result = ses.find(c->id); + REQUIRE(colorlist_result); + auto clist = *colorlist_result; + REQUIRE(clist.is_persistent()); + REQUIRE(clist->colors.size() == 3); + std::vector expected_colors{"red", "green", "blue"}; + for (const auto &cstr: clist->colors) { + REQUIRE(std::find(expected_colors.begin(), expected_colors.end(), cstr) != expected_colors.end()); + } +} + +TEST_CASE_METHOD(SessionFixture, "Test insert object with has many primitive relation with sequence", "[session][insert][has_many][primitive][sequence]") { + const auto result = schema.attach("colorlist") + .and_then([this] { return schema.create(db); } ); + REQUIRE(result.is_ok()); + + session ses({bus, connection::dns, 4}, schema); + + const auto c = make_object("rgb", std::vector{"red", "green", "blue"}); + + auto res = ses.insert(c); + REQUIRE(res.is_ok()); + + auto colorlist_result = ses.find(c->id); + REQUIRE(colorlist_result); + auto clist = *colorlist_result; + REQUIRE(clist.is_persistent()); + REQUIRE(clist->colors.size() == 3); + std::vector expected_colors{"red", "green", "blue"}; + for (const auto &cstr: clist->colors) { + REQUIRE(std::find(expected_colors.begin(), expected_colors.end(), cstr) != expected_colors.end()); + } +}