use table metas where possible
This commit is contained in:
@@ -9,30 +9,28 @@
|
||||
#include "catch2/catch_test_macros.hpp"
|
||||
|
||||
namespace matador::test {
|
||||
|
||||
QueryFixture::QueryFixture()
|
||||
: db(connection::dns)
|
||||
, repo(db.dialect().default_schema_name())
|
||||
{
|
||||
: db(connection::dns)
|
||||
, repo(db.dialect().default_schema_name()) {
|
||||
REQUIRE(db.open());
|
||||
}
|
||||
|
||||
QueryFixture::~QueryFixture() {
|
||||
while (!tables_to_drop.empty()) {
|
||||
drop_table_if_exists(tables_to_drop.top());
|
||||
tables_to_drop.pop();
|
||||
}
|
||||
while (!tables_to_drop.empty()) {
|
||||
drop_table_if_exists(tables_to_drop.top());
|
||||
tables_to_drop.pop();
|
||||
}
|
||||
REQUIRE(repo.drop(db));
|
||||
REQUIRE(db.close());
|
||||
}
|
||||
|
||||
void QueryFixture::check_table_exists(const std::string &table_name) const
|
||||
{
|
||||
void QueryFixture::check_table_exists(const std::string &table_name) const {
|
||||
auto result = db.exists(table_name);
|
||||
REQUIRE(result.is_ok());
|
||||
REQUIRE(*result);
|
||||
}
|
||||
|
||||
void QueryFixture::check_table_not_exists(const std::string &table_name) const
|
||||
{
|
||||
void QueryFixture::check_table_not_exists(const std::string &table_name) const {
|
||||
auto result = db.exists(table_name);
|
||||
REQUIRE(result.is_ok());
|
||||
REQUIRE(!*result);
|
||||
@@ -41,7 +39,7 @@ void QueryFixture::check_table_not_exists(const std::string &table_name) const
|
||||
void QueryFixture::drop_table_if_exists(const std::string &table_name) const {
|
||||
const auto result = db.exists(table_name).and_then([&table_name, this](const bool exists) {
|
||||
if (exists) {
|
||||
auto res = query::query::drop()
|
||||
auto res = query::query::drop()
|
||||
.table(table_name)
|
||||
.execute(db);
|
||||
REQUIRE(res);
|
||||
@@ -50,5 +48,4 @@ void QueryFixture::drop_table_if_exists(const std::string &table_name) const {
|
||||
return utils::ok(true);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user