orm schema class progress added SchemaTest.cpp

This commit is contained in:
Sascha Kühl
2025-10-31 16:28:34 +01:00
parent 5632746eb6
commit 557abecf91
9 changed files with 111 additions and 207 deletions
+33
View File
@@ -0,0 +1,33 @@
#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());
}