added describe table and table exists to session
This commit is contained in:
@@ -12,7 +12,6 @@ add_executable(tests QueryBuilderTest.cpp
|
||||
SessionTest.cpp
|
||||
RecordTest.cpp
|
||||
ConnectionPoolTest.cpp
|
||||
query.cpp
|
||||
BackendProviderTest.cpp
|
||||
ConnectionTest.cpp
|
||||
models/product.hpp
|
||||
|
||||
@@ -6,7 +6,11 @@
|
||||
using namespace matador::sql;
|
||||
|
||||
TEST_CASE("Create connection", "[connection]") {
|
||||
connection c("sqlite://test.db");
|
||||
auto dns = GENERATE(as<std::string>{},
|
||||
"sqlite://sqlite.db",
|
||||
"postgres://test:test123@127.0.0.1:5432/matador_test" );
|
||||
|
||||
connection c(dns);
|
||||
REQUIRE(!c.is_open());
|
||||
|
||||
c.open();
|
||||
|
||||
@@ -9,9 +9,13 @@
|
||||
using namespace matador::sql;
|
||||
|
||||
TEST_CASE("Create and drop table statement", "[session record]") {
|
||||
connection_pool<connection> pool("sqlite://sqlite.db", 4);
|
||||
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);
|
||||
|
||||
REQUIRE(!s.table_exists("person"));
|
||||
auto res = s.create()
|
||||
.table("person", {
|
||||
make_pk_column<unsigned long>("id"),
|
||||
@@ -22,6 +26,8 @@ TEST_CASE("Create and drop table statement", "[session record]") {
|
||||
|
||||
REQUIRE(res.second == R"(CREATE TABLE "person" ("id" BIGINT NOT NULL, "name" VARCHAR(255), "age" INTEGER, CONSTRAINT PK_person PRIMARY KEY (id)))");
|
||||
|
||||
REQUIRE(s.table_exists("person"));
|
||||
|
||||
res = s.drop()
|
||||
.table("person")
|
||||
.execute();
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
#include <catch2/generators/catch_generators.hpp>
|
||||
|
||||
#include "matador/sql/connection.hpp"
|
||||
|
||||
using namespace matador;
|
||||
|
||||
TEST_CASE("Query test", "[query]") {
|
||||
auto dns = GENERATE(as<std::string>{},
|
||||
"sqlite://sqlite.db",
|
||||
"postgres://test:test123@127.0.0.1:5432/matador_test" );
|
||||
|
||||
sql::connection c(dns);
|
||||
REQUIRE(!c.is_open());
|
||||
|
||||
c.open();
|
||||
REQUIRE(c.is_open());
|
||||
|
||||
c.close();
|
||||
REQUIRE(!c.is_open());
|
||||
|
||||
INFO(dns);
|
||||
REQUIRE(!dns.empty());
|
||||
}
|
||||
Reference in New Issue
Block a user