query/test/backends/SchemaTest.cpp

33 lines
965 B
C++

#include <catch2/catch_test_macros.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;
TEST_CASE("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");
auto result = repo.attach<department>("departments")
.and_then( [&repo] { return repo.attach<employee>("employees"); } );
REQUIRE(result);
result = repo.create();
REQUIRE(result);
const auto exists_result = repo.table_exists("departments");
REQUIRE(exists_result.is_ok());
REQUIRE(exists_result.value());
}