added session test (progress)

This commit is contained in:
2024-02-04 22:24:50 +01:00
parent fa3ea28920
commit 0f13884f06
8 changed files with 115 additions and 16 deletions
+2 -1
View File
@@ -25,7 +25,8 @@ set(TEST_SOURCES
../../tests/QueryRecordTest.cpp
../../tests/StatementTest.cpp
../../tests/TypeTraitsTest.cpp
../../tests/StatementCacheTest.cpp)
../../tests/StatementCacheTest.cpp
../../tests/SessionTest.cpp)
set(LIBRARY_TEST_TARGET mysql_tests)
+3 -2
View File
@@ -12,7 +12,7 @@ list(APPEND CMAKE_MODULE_PATH ${catch2_SOURCE_DIR}/extras)
include(CTest)
include(Catch)
set(POSTGRES_CONNECTION_STRING "postgres://test:test123@127.0.0.1:15432/test")
set(POSTGRES_CONNECTION_STRING "postgres://test:test123@127.0.0.1:5432/matador_test")
configure_file(Connection.hpp.in ${PROJECT_BINARY_DIR}/backends/postgres/test/connection.hpp @ONLY IMMEDIATE)
@@ -25,7 +25,8 @@ set(TEST_SOURCES
../../tests/QueryRecordTest.cpp
../../tests/StatementTest.cpp
../../tests/TypeTraitsTest.cpp
../../tests/StatementCacheTest.cpp)
../../tests/StatementCacheTest.cpp
../../tests/SessionTest.cpp)
set(LIBRARY_TEST_TARGET postgres_tests)
+2 -1
View File
@@ -25,7 +25,8 @@ set(TEST_SOURCES
../../tests/QueryRecordTest.cpp
../../tests/StatementTest.cpp
../../tests/TypeTraitsTest.cpp
../../tests/StatementCacheTest.cpp)
../../tests/StatementCacheTest.cpp
../../tests/SessionTest.cpp)
set(LIBRARY_TEST_TARGET sqlite_tests)
+45
View File
@@ -0,0 +1,45 @@
#include "catch2/catch_test_macros.hpp"
#include "connection.hpp"
#include "matador/sql/session.hpp"
#include "models/airplane.hpp"
class SessionFixture
{
public:
SessionFixture()
: pool(matador::test::connection::dns, 4)
, ses(pool)
{}
~SessionFixture()
{
drop_table_if_exists("flight");
drop_table_if_exists("airplane");
drop_table_if_exists("person");
}
protected:
matador::sql::connection_pool<matador::sql::connection> pool;
matador::sql::session ses;
private:
void drop_table_if_exists(const std::string &table_name)
{
if (ses.table_exists(table_name)) {
ses.drop_table(table_name);
}
}
};
using namespace matador;
TEST_CASE_METHOD(SessionFixture, "Session relation test", "[session][relation]") {
ses.attach<matador::test::airplane>("airplane");
ses.insert<test::airplane>(1, "Boeing", "A380");
REQUIRE(true);
}