mirror of
https://github.com/mudita/MuditaOS.git
synced 2026-10-24 07:28:29 -04:00
db: improve query handling
Introduce a new way to handle query responses allowing to deal with races: - bind reponse with request, - handle responses with an observer-like interface. Signed-off-by: Marcin Smoczyński <smoczynski.marcin@gmail.com>
This commit is contained in:
1 parent
258ef22228
commit
885fe1083a
32 files changed
+182
-115
No files matched your search
@@ -40,20 +40,20 @@ TEST_CASE("Query interface")
|
||||
|
||||
SECTION("unknown query -> no results")
|
||||
{
|
||||
REQUIRE(smsInterface->runQuery(std::make_unique<db::TestQuery>().get()) == nullptr);
|
||||
REQUIRE(smsInterface->runQuery(std::make_shared<db::TestQuery>()) == nullptr);
|
||||
}
|
||||
|
||||
auto query = std::make_unique<db::query::SMSSearch>("a", 0, 10);
|
||||
auto query = std::make_shared<db::query::SMSSearch>("a", 0, 10);
|
||||
|
||||
SECTION("known query, wrong interface")
|
||||
{
|
||||
auto result = smsInterface->runQuery(query.get());
|
||||
auto result = smsInterface->runQuery(query);
|
||||
REQUIRE(result == nullptr);
|
||||
}
|
||||
|
||||
SECTION("proper result returned")
|
||||
{
|
||||
auto result = threadInterface->runQuery(query.get());
|
||||
auto result = threadInterface->runQuery(query);
|
||||
REQUIRE(dynamic_cast<db::query::SMSSearchResult *>(result.get()));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user