orm schema class progress added SchemaTest.cpp
This commit is contained in:
@@ -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());
|
||||
}
|
||||
@@ -13,21 +13,20 @@ add_executable(OrmTests
|
||||
backend/test_result_reader.hpp
|
||||
backend/test_statement.cpp
|
||||
backend/test_statement.hpp
|
||||
orm/SessionInsertBuilderTest.cpp
|
||||
orm/SessionQueryBuilderTest.cpp
|
||||
query/CriteriaTests.cpp
|
||||
query/QueryBuilderTest.cpp
|
||||
query/QueryFixture.cpp
|
||||
query/QueryFixture.hpp
|
||||
query/QueryTest.cpp
|
||||
sql/ColumnTest.cpp
|
||||
sql/ColumnGeneratorTest.cpp
|
||||
sql/ColumnTest.cpp
|
||||
sql/ConnectionPoolFixture.hpp
|
||||
sql/ConnectionPoolTest.cpp
|
||||
sql/FieldTest.cpp
|
||||
sql/StatementCacheTest.cpp
|
||||
utils/auto_reset_event.cpp
|
||||
utils/auto_reset_event.hpp
|
||||
sql/StatementCacheTest.cpp
|
||||
sql/ConnectionPoolFixture.hpp
|
||||
query/CriteriaTests.cpp
|
||||
)
|
||||
|
||||
target_link_libraries(OrmTests matador-orm matador-core Catch2::Catch2WithMain)
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
#include <iostream>
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
|
||||
#include "matador/sql/backend_provider.hpp"
|
||||
#include "matador/sql/connection.hpp"
|
||||
#include "matador/sql/column.hpp"
|
||||
#include "matador/sql/table.hpp"
|
||||
|
||||
#include "matador/query/query.hpp"
|
||||
|
||||
#include "matador/orm/session_insert_builder.hpp"
|
||||
|
||||
#include "../backend/test_connection.hpp"
|
||||
#include "../backend/test_backend_service.hpp"
|
||||
|
||||
#include "../../models/airplane.hpp"
|
||||
#include "../../models/author.hpp"
|
||||
#include "../../models/department.hpp"
|
||||
#include "../../models/book.hpp"
|
||||
#include "../../models/flight.hpp"
|
||||
#include "../../models/recipe.hpp"
|
||||
#include "../../models/order.hpp"
|
||||
#include "../../models/student.hpp"
|
||||
|
||||
using namespace matador::object;
|
||||
using namespace matador::orm;
|
||||
using namespace matador::query;
|
||||
using namespace matador::sql;
|
||||
using namespace matador::test;
|
||||
|
||||
TEST_CASE("Create sql insert for entity with eager has one", "[query][entity][insert][builder]") {
|
||||
using namespace matador::test;
|
||||
backend_provider::instance().register_backend("noop", std::make_unique<orm::test_backend_service>());
|
||||
connection db("noop://noop.db");
|
||||
repository scm("noop");
|
||||
auto result = scm.attach<airplane>("airplanes")
|
||||
.and_then( [&scm] { return scm.attach<flight>("flights"); } );
|
||||
REQUIRE(result);
|
||||
|
||||
session_insert_builder eib(scm);
|
||||
|
||||
auto b737 = object_ptr(new airplane{0, "Boeing", "737"});
|
||||
flight f1{0, b737, "F828"};
|
||||
|
||||
// auto data = eib.build(f1);
|
||||
|
||||
// REQUIRE(data.is_ok());
|
||||
}
|
||||
Reference in New Issue
Block a user