added mysql backend
This commit is contained in:
+15
-6
@@ -1,16 +1,25 @@
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
#include <catch2/generators/catch_generators.hpp>
|
||||
#include <catch2/catch_template_test_macros.hpp>
|
||||
|
||||
#include "matador/sql/connection.hpp"
|
||||
|
||||
#include "Databases.hpp"
|
||||
|
||||
using namespace matador::sql;
|
||||
|
||||
TEST_CASE("Create connection", "[connection]") {
|
||||
auto dns = GENERATE(as<std::string>{},
|
||||
"sqlite://sqlite.db",
|
||||
"postgres://test:test123@127.0.0.1:5432/matador_test" );
|
||||
template<class Type>
|
||||
class ConnectionTestFixture
|
||||
{
|
||||
public:
|
||||
ConnectionTestFixture() = default;
|
||||
~ConnectionTestFixture() = default;
|
||||
|
||||
connection c(dns);
|
||||
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();
|
||||
|
||||
@@ -12,4 +12,9 @@ struct Sqlite
|
||||
constexpr static const char *dns{"sqlite://sqlite.db"};
|
||||
};
|
||||
|
||||
struct MySql
|
||||
{
|
||||
constexpr static const char *dns{"mysql://test:test123!@127.0.0.1:3306/matador_test"};
|
||||
};
|
||||
|
||||
#endif //QUERY_DATABASES_HPP
|
||||
|
||||
@@ -1,20 +1,35 @@
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
#include <catch2/generators/catch_generators.hpp>
|
||||
#include <catch2/catch_template_test_macros.hpp>
|
||||
|
||||
#include <matador/sql/condition.hpp>
|
||||
#include <matador/sql/session.hpp>
|
||||
|
||||
#include "Databases.hpp"
|
||||
|
||||
#include <list>
|
||||
|
||||
using namespace matador::sql;
|
||||
|
||||
TEST_CASE("Create and drop table statement", "[session record]")
|
||||
template<class Type>
|
||||
class SessionRecordTestFixture
|
||||
{
|
||||
auto dns = GENERATE(as < std::string > {},
|
||||
"sqlite://sqlite.db",
|
||||
"postgres://test:test123@127.0.0.1:5432/matador_test");
|
||||
connection_pool<connection> pool(dns, 4);
|
||||
session s(pool);
|
||||
public:
|
||||
SessionRecordTestFixture()
|
||||
: pool_(Type::dns, 4), session_(pool_)
|
||||
{}
|
||||
|
||||
matador::sql::session &session()
|
||||
{ return session_; }
|
||||
|
||||
private:
|
||||
matador::sql::connection_pool<matador::sql::connection> pool_;
|
||||
matador::sql::session session_;
|
||||
};
|
||||
|
||||
TEMPLATE_TEST_CASE_METHOD(SessionRecordTestFixture, "Create and drop table statement", "[session record]", Sqlite, Postgres, MySql)
|
||||
{
|
||||
auto &s = SessionRecordTestFixture<TestType>::session();
|
||||
|
||||
REQUIRE(!s.table_exists("person"));
|
||||
s.create()
|
||||
|
||||
Reference in New Issue
Block a user