implemented the first version of statement_cache
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
|
||||
#include <matador/query/query.hpp>
|
||||
|
||||
#include "matador/sql/connection_pool.hpp"
|
||||
#include "matador/sql/statement_cache.hpp"
|
||||
|
||||
#include "../backend/test_backend_service.hpp"
|
||||
|
||||
#include "ConnectionPoolFixture.hpp"
|
||||
|
||||
using namespace matador::test;
|
||||
using namespace matador::sql;
|
||||
using namespace matador::query;
|
||||
|
||||
TEST_CASE("Test statement cache", "[statement][cache]") {
|
||||
backend_provider::instance().register_backend("noop", std::make_unique<orm::test_backend_service>());
|
||||
|
||||
connection_pool pool("noop://noop.db", 4);
|
||||
statement_cache cache(pool, 4);
|
||||
|
||||
query_context ctx;
|
||||
ctx.sql = "SELECT * FROM person";
|
||||
|
||||
REQUIRE(cache.capacity() == 4);
|
||||
REQUIRE(cache.empty());
|
||||
|
||||
auto result = cache.acquire(ctx);
|
||||
REQUIRE(result);
|
||||
|
||||
REQUIRE(cache.size() == 1);
|
||||
REQUIRE(!cache.empty());
|
||||
REQUIRE(cache.capacity() == 4);
|
||||
|
||||
const auto stmt = result.value();
|
||||
}
|
||||
Reference in New Issue
Block a user