integrated object cache into session and added message bus to object_cache and update tests

This commit is contained in:
2026-05-22 15:26:16 +02:00
parent ddf19bbf07
commit 5ec7c13420
8 changed files with 212 additions and 21 deletions
+23 -11
View File
@@ -79,18 +79,30 @@ TEST_CASE_METHOD(SessionFixture, "Test insert object with has many relation", "[
session ses({bus, connection::dns, 4}, schema);
auto s_king = make_object<author>(1, "Steven", "King", "21.9.1947", 1956, false);
{
auto s_king = make_object<author>(1, "Steven", "King", "21.9.1947", 1956, false);
s_king->books.push_back(make_object<book>(2, "Carrie", nullobj, 1974));
s_king->books.push_back(make_object<book>(3, "The Shining", nullobj, 1977));
s_king->books.push_back(make_object<book>(4, "It", nullobj, 1986));
s_king->books.push_back(make_object<book>(5, "Misery", nullobj, 1987));
s_king->books.push_back(make_object<book>(6, "The Dark Tower: The Gunslinger", nullobj, 1982));
s_king->books.push_back(make_object<book>(2, "Carrie", nullobj, 1974));
s_king->books.push_back(make_object<book>(3, "The Shining", nullobj, 1977));
s_king->books.push_back(make_object<book>(4, "It", nullobj, 1986));
s_king->books.push_back(make_object<book>(5, "Misery", nullobj, 1987));
s_king->books.push_back(make_object<book>(6, "The Dark Tower: The Gunslinger", nullobj, 1982));
validate_author_state(s_king, object_state::Transient);
auto res = ses.insert(s_king);
REQUIRE(res);
validate_author_state(s_king, object_state::Persistent);
validate_author_state(s_king, object_state::Transient);
auto res = ses.insert(s_king);
REQUIRE(res);
validate_author_state(s_king, object_state::Persistent);
auto author_result = ses.find<author>(s_king->id);
REQUIRE(author_result);
REQUIRE(author_result->is_persistent());
REQUIRE(author_result.value()->books.size() == 5);
}
auto author_result = ses.find<author>(1);
REQUIRE(author_result);
REQUIRE(author_result->is_persistent());
REQUIRE(author_result.value()->books.size() == 5);
}
TEST_CASE_METHOD(SessionFixture, "Test insert object with has many relation with identity", "[session][insert][has_many][identity]") {
@@ -214,4 +226,4 @@ 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());
}
}
}