backend tests progress
This commit is contained in:
@@ -25,9 +25,10 @@ void postgres_connection::open()
|
||||
|
||||
conn_ = PQconnectdb(connection.c_str());
|
||||
if (PQstatus(conn_) == CONNECTION_BAD) {
|
||||
const auto msg = PQerrorMessage(conn_);
|
||||
const std::string msg = PQerrorMessage(conn_);
|
||||
PQfinish(conn_);
|
||||
throw_postgres_error(msg, "postgres");
|
||||
conn_ = nullptr;
|
||||
throw_postgres_error(msg.c_str(), "postgres");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
return "$" + std::to_string(index);
|
||||
})
|
||||
.with_token_replace_map({
|
||||
{dialect::token_t::BEGIN_BINARY_DATA, "E'\\\\"}
|
||||
{dialect::token_t::BEGIN_BINARY_DATA, "E'\\"}
|
||||
})
|
||||
.with_data_type_replace_map({
|
||||
{data_type_t::type_blob, "BYTEA"}
|
||||
|
||||
@@ -8,14 +8,21 @@ FetchContent_Declare(
|
||||
|
||||
FetchContent_MakeAvailable(Catch2)
|
||||
|
||||
SET(POSTGRES_CONNECTION_STRING "postgresql://test:test123@127.0.0.1/matador_test" CACHE STRING "postgresql connection string")
|
||||
list(APPEND CMAKE_MODULE_PATH ${catch2_SOURCE_DIR}/extras)
|
||||
include(CTest)
|
||||
include(Catch)
|
||||
|
||||
CONFIGURE_FILE(Connection.hpp.in ${PROJECT_BINARY_DIR}/backends/postgres/test/connection.hpp @ONLY IMMEDIATE)
|
||||
set(POSTGRES_CONNECTION_STRING "postgres://test:test123@127.0.0.1:15432/test")
|
||||
|
||||
MESSAGE(STATUS "postgresql connection string: ${POSTGRES_CONNECTION_STRING}")
|
||||
MESSAGE(STATUS "current binary dir: ${CMAKE_CURRENT_BINARY_DIR}")
|
||||
configure_file(Connection.hpp.in ${PROJECT_BINARY_DIR}/backends/postgres/test/connection.hpp @ONLY IMMEDIATE)
|
||||
|
||||
set(TEST_SOURCES ../../tests/QueryTest.cpp)
|
||||
message(STATUS "postgresql connection string: ${POSTGRES_CONNECTION_STRING}")
|
||||
|
||||
set(TEST_SOURCES
|
||||
../../tests/QueryTest.cpp
|
||||
../../tests/SessionTest.cpp
|
||||
../../tests/ConnectionTest.cpp
|
||||
../../tests/SessionRecordTest.cpp)
|
||||
|
||||
set(LIBRARY_TEST_TARGET postgres_tests)
|
||||
|
||||
@@ -29,6 +36,7 @@ target_link_libraries(${LIBRARY_TEST_TARGET} PRIVATE
|
||||
|
||||
target_include_directories(${LIBRARY_TEST_TARGET}
|
||||
PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}>/include
|
||||
PRIVATE $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}>/test
|
||||
PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
add_test(NAME matador_postgres_tests COMMAND ${LIBRARY_TEST_TARGET})
|
||||
catch_discover_tests(${LIBRARY_TEST_TARGET} TEST_SUFFIX " (PostgreSQL)")
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
#ifndef POSTGRES_CONNECTION_HPP
|
||||
#define POSTGRES_CONNECTION_HPP
|
||||
|
||||
#define MATADOR_DB_TYPE "Postgres"
|
||||
|
||||
namespace matador::test::connection {
|
||||
const char* const dns = "@POSTGRES_CONNECTION_STRING@";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user