query/test/ConnectionTest.cpp

30 lines
639 B
C++

#include <catch2/catch_test_macros.hpp>
#include <catch2/catch_template_test_macros.hpp>
#include "matador/sql/connection.hpp"
#include "Databases.hpp"
using namespace matador::sql;
template<class Type>
class ConnectionTestFixture
{
public:
ConnectionTestFixture() = default;
~ConnectionTestFixture() = default;
std::string dns() { return Type::dns; }
};
TEMPLATE_TEST_CASE_METHOD(ConnectionTestFixture, "Create connection", "[connection]", Sqlite, Postgres, MySql) {
connection c(ConnectionTestFixture<TestType>::dns());
REQUIRE(!c.is_open());
c.open();
REQUIRE(c.is_open());
c.close();
REQUIRE(!c.is_open());
}