added alter table command to fluent query builder (progress)
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
#include "SchemaFixture.hpp"
|
||||
|
||||
#include "connection.hpp"
|
||||
|
||||
namespace matador::test {
|
||||
SchemaFixture::SchemaFixture()
|
||||
: pool(connection::dns, 4) {}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
#ifndef MATADOR_QUERY_SCHEMA_FIXTURE_HPP
|
||||
#define MATADOR_QUERY_SCHEMA_FIXTURE_HPP
|
||||
|
||||
#include "matador/sql/connection_pool.hpp"
|
||||
|
||||
namespace matador::test {
|
||||
class SchemaFixture {
|
||||
public:
|
||||
SchemaFixture();
|
||||
|
||||
protected:
|
||||
sql::connection_pool pool;
|
||||
};
|
||||
}
|
||||
|
||||
#endif //MATADOR_QUERY_SCHEMA_FIXTURE_HPP
|
||||
@@ -1,24 +1,20 @@
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
|
||||
#include "SchemaFixture.hpp"
|
||||
|
||||
#include "matador/sql/backend_provider.hpp"
|
||||
#include "matador/sql/connection_pool.hpp"
|
||||
|
||||
#include "matador/orm/schema.hpp"
|
||||
|
||||
#include "../orm/backend/test_connection.hpp"
|
||||
#include "../orm/backend/test_backend_service.hpp"
|
||||
|
||||
#include "../models/department.hpp"
|
||||
|
||||
using namespace matador;
|
||||
using namespace matador::test;
|
||||
|
||||
TEST_CASE("Test schema", "[schema]") {
|
||||
TEST_CASE_METHOD(SchemaFixture, "Test schema", "[schema]") {
|
||||
using namespace matador::test;
|
||||
sql::backend_provider::instance().register_backend("noop", std::make_unique<test::orm::test_backend_service>());
|
||||
|
||||
sql::connection_pool pool("noop://noop.db", 4);
|
||||
|
||||
matador::orm::schema repo(pool, "NoopSchema");
|
||||
matador::orm::schema repo(pool/*, "NoopSchema"*/);
|
||||
|
||||
auto result = repo.attach<department>("departments")
|
||||
.and_then( [&repo] { return repo.attach<employee>("employees"); } );
|
||||
@@ -27,7 +23,14 @@ TEST_CASE("Test schema", "[schema]") {
|
||||
result = repo.create();
|
||||
REQUIRE(result);
|
||||
|
||||
const auto exists_result = repo.table_exists("departments");
|
||||
auto exists_result = repo.table_exists("departments");
|
||||
REQUIRE(exists_result.is_ok());
|
||||
REQUIRE(exists_result.value());
|
||||
}
|
||||
|
||||
result = repo.drop();
|
||||
REQUIRE(result);
|
||||
|
||||
exists_result = repo.table_exists("departments");
|
||||
REQUIRE(exists_result.is_ok());
|
||||
REQUIRE(!exists_result.value());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user