added SchemaTest, fixed bug in class shipment, added contains methods to class schema and enabled some tests
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
|
||||
#include "matador/query/schema.hpp"
|
||||
|
||||
#include "../../models/shipment.hpp"
|
||||
|
||||
using namespace matador::query;
|
||||
using namespace matador::test;
|
||||
|
||||
TEST_CASE("Test schema with belongs-to to has-many relation" "[schema][relation][belongs_to]") {
|
||||
schema repo;
|
||||
auto result = repo.attach<package>("packages")
|
||||
.and_then( [&repo] { return repo.attach<shipment>("shipments"); } );
|
||||
REQUIRE(result.is_ok());
|
||||
REQUIRE(repo.size() == 2);
|
||||
REQUIRE(repo.contains<shipment>());
|
||||
REQUIRE(repo.contains<package>());
|
||||
|
||||
auto it = repo.find<shipment>();
|
||||
REQUIRE(it != repo.end());
|
||||
REQUIRE(it->second.name() == "shipments");
|
||||
it = repo.find<package>();
|
||||
REQUIRE(it != repo.end());
|
||||
REQUIRE(it->second.name() == "packages");
|
||||
}
|
||||
|
||||
TEST_CASE("Test schema with has-many to belongs-to relation" "[schema][relation][has_many]") {
|
||||
schema repo;
|
||||
auto result = repo.attach<shipment>("shipments")
|
||||
.and_then( [&repo] { return repo.attach<package>("packages"); } );
|
||||
REQUIRE(result.is_ok());
|
||||
REQUIRE(repo.size() == 2);
|
||||
REQUIRE(repo.contains<shipment>());
|
||||
REQUIRE(repo.contains<package>());
|
||||
|
||||
auto it = repo.find<shipment>();
|
||||
REQUIRE(it != repo.end());
|
||||
REQUIRE(it->second.name() == "shipments");
|
||||
it = repo.find<package>();
|
||||
REQUIRE(it != repo.end());
|
||||
REQUIRE(it->second.name() == "packages");
|
||||
}
|
||||
Reference in New Issue
Block a user