object generator progress
This commit is contained in:
+5
-2
@@ -1,6 +1,7 @@
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
|
||||
#include "matador/object/attribute_generator.hpp"
|
||||
#include "matador/object/object.hpp"
|
||||
#include "matador/object/repository.hpp"
|
||||
|
||||
#include "../test/models/product.hpp"
|
||||
@@ -17,7 +18,8 @@ TEST_CASE("Generate column definitions from object", "[column][definition][gener
|
||||
.and_then([&repo] { return repo.attach<matador::test::category>("categories"); });
|
||||
REQUIRE(result);
|
||||
|
||||
auto columns = attribute_generator::generate<matador::test::product>(repo);
|
||||
object obj("products");
|
||||
auto columns = attribute_generator::generate<matador::test::product>(repo, obj);
|
||||
|
||||
const std::vector expected_columns = {
|
||||
attribute{"product_name", basic_type::type_varchar, constraints::PrimaryKey, null_option_type::NOT_NULL },
|
||||
@@ -43,7 +45,8 @@ TEST_CASE("Generate column definitions from object", "[column][definition][gener
|
||||
TEST_CASE("Generate columns from object with nullable columns", "[column generator]") {
|
||||
repository repo("main");
|
||||
|
||||
auto columns = attribute_generator::generate<matador::test::optional>(repo);
|
||||
object obj("optionals");
|
||||
auto columns = attribute_generator::generate<matador::test::optional>(repo, obj);
|
||||
|
||||
const std::vector expected_columns = {
|
||||
attribute{"id", basic_type::type_uint32, constraints::PrimaryKey, null_option_type::NOT_NULL },
|
||||
@@ -0,0 +1,20 @@
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
|
||||
#include "matador/object/object.hpp"
|
||||
#include "matador/object/repository.hpp"
|
||||
|
||||
#include "../test/models/author.hpp"
|
||||
#include "../test/models/book.hpp"
|
||||
|
||||
TEST_CASE("Generate object from type", "[object][generate]") {
|
||||
using namespace matador;
|
||||
object::repository repo;
|
||||
auto result = repo.attach<test::author>("authors");
|
||||
REQUIRE(result);
|
||||
|
||||
const auto obj = object::object::generate<test::book>(repo, "books");
|
||||
REQUIRE(obj->name() == "books");
|
||||
REQUIRE(obj->alias().empty());
|
||||
REQUIRE(obj->attributes().size() == 4);
|
||||
REQUIRE(obj->constraints().size() == 2);
|
||||
}
|
||||
Reference in New Issue
Block a user