removed attribute_generator and constraints_generator
This commit is contained in:
@@ -1,64 +0,0 @@
|
||||
#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"
|
||||
#include "../test/models/optional.hpp"
|
||||
|
||||
using namespace matador::object;
|
||||
using namespace matador::utils;
|
||||
|
||||
TEST_CASE("Generate column definitions from object", "[column][definition][generator]") {
|
||||
repository repo("main");
|
||||
|
||||
auto result = repo.attach<matador::test::product>("products")
|
||||
.and_then([&repo] { return repo.attach<matador::test::supplier>("supplier"); })
|
||||
.and_then([&repo] { return repo.attach<matador::test::category>("categories"); });
|
||||
REQUIRE(result);
|
||||
|
||||
auto obj = std::make_shared<object>("products");
|
||||
auto columns = attribute_generator::generate<matador::test::product>(repo, obj);
|
||||
|
||||
const std::vector expected_columns = {
|
||||
attribute{"product_name", basic_type::Varchar, constraints::PrimaryKey, null_option_type::NotNull },
|
||||
attribute{"supplier_id", basic_type::UInt32, constraints::ForeignKey, null_option_type::NotNull },
|
||||
attribute{"category_id", basic_type::UInt32, constraints::ForeignKey, null_option_type::NotNull },
|
||||
attribute{"quantity_per_unit", basic_type::Varchar, null_attributes, null_option_type::NotNull },
|
||||
attribute{"unit_price", basic_type::UInt32, null_attributes, null_option_type::NotNull },
|
||||
attribute{"units_in_stock", basic_type::UInt32, null_attributes, null_option_type::NotNull },
|
||||
attribute{"units_in_order", basic_type::UInt32, null_attributes, null_option_type::NotNull },
|
||||
attribute{"reorder_level", basic_type::UInt32, null_attributes, null_option_type::NotNull },
|
||||
attribute{"discontinued", basic_type::Boolean, null_attributes, null_option_type::NotNull }
|
||||
};
|
||||
REQUIRE(!columns.empty());
|
||||
REQUIRE(columns.size() == expected_columns.size());
|
||||
|
||||
for (size_t i = 0; i != expected_columns.size(); ++i) {
|
||||
REQUIRE(expected_columns[i].name() == columns[i].name());
|
||||
REQUIRE(expected_columns[i].attributes().options() == columns[i].attributes().options() );
|
||||
REQUIRE(expected_columns[i].type() == columns[i].type() );
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("Generate columns from object with nullable columns", "[column generator]") {
|
||||
repository repo("main");
|
||||
|
||||
auto obj = std::make_shared<object>("optionals");
|
||||
auto columns = attribute_generator::generate<matador::test::optional>(repo, obj);
|
||||
|
||||
const std::vector expected_columns = {
|
||||
attribute{"id", basic_type::UInt32, constraints::PrimaryKey, null_option_type::NotNull },
|
||||
attribute{"name", basic_type::Varchar, null_attributes, null_option_type::NotNull },
|
||||
attribute{"age", basic_type::UInt32, null_attributes, null_option_type::NotNull }
|
||||
};
|
||||
REQUIRE(!columns.empty());
|
||||
REQUIRE(columns.size() == expected_columns.size());
|
||||
|
||||
for (size_t i = 0; i != expected_columns.size(); ++i) {
|
||||
REQUIRE(expected_columns[i].name() == columns[i].name());
|
||||
REQUIRE(expected_columns[i].attributes().options() == columns[i].attributes().options() );
|
||||
REQUIRE(expected_columns[i].type() == columns[i].type() );
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user