fixed PostgreSQL tests
This commit is contained in:
@@ -16,8 +16,11 @@ using namespace matador::object;
|
||||
using namespace matador::test;
|
||||
|
||||
TEST_CASE_METHOD(SessionFixture, "Session insert test", "[session][insert]") {
|
||||
const auto result = ses.attach<airplane>("airplanes")
|
||||
.and_then([this] { return ses.create_schema(); } );
|
||||
const auto result = schema.attach<airplane>("airplanes")
|
||||
.and_then([this] {
|
||||
const auto conn = pool.acquire();
|
||||
return schema.create(*conn);
|
||||
} );
|
||||
REQUIRE(result.is_ok());
|
||||
|
||||
auto plane = ses.insert<airplane>(1, "Boeing", "A380");
|
||||
@@ -32,8 +35,11 @@ TEST_CASE_METHOD(SessionFixture, "Session insert test", "[session][insert]") {
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(SessionFixture, "Session update test", "[session][update]") {
|
||||
const auto res = ses.attach<airplane>("airplanes")
|
||||
.and_then([this] { return ses.create_schema(); } );
|
||||
const auto res = schema.attach<airplane>("airplanes")
|
||||
.and_then([this] {
|
||||
const auto conn = pool.acquire();
|
||||
return schema.create(*conn);
|
||||
} );
|
||||
REQUIRE(res.is_ok());
|
||||
|
||||
auto result = ses.insert<airplane>(1, "Boeing", "747");
|
||||
@@ -62,8 +68,11 @@ TEST_CASE_METHOD(SessionFixture, "Session update test", "[session][update]") {
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(SessionFixture, "Session delete test", "[session][delete]") {
|
||||
const auto res = ses.attach<airplane>("airplanes")
|
||||
.and_then([this] { return ses.create_schema(); } );
|
||||
const auto res = schema.attach<airplane>("airplanes")
|
||||
.and_then([this] {
|
||||
const auto conn = pool.acquire();
|
||||
return schema.create(*conn);
|
||||
} );
|
||||
REQUIRE(res.is_ok());
|
||||
|
||||
auto result = ses.insert<airplane>(1, "Boeing", "747");
|
||||
@@ -83,9 +92,12 @@ TEST_CASE_METHOD(SessionFixture, "Session delete test", "[session][delete]") {
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(SessionFixture, "Session relation test", "[session][relation]") {
|
||||
const auto result = ses.attach<airplane>("airplanes")
|
||||
.and_then([this] { return ses.attach<flight>("flights"); } )
|
||||
.and_then([this] { return ses.create_schema(); } );
|
||||
const auto result = schema.attach<airplane>("airplanes")
|
||||
.and_then([this] { return schema.attach<flight>("flights"); } )
|
||||
.and_then([this] {
|
||||
const auto conn = pool.acquire();
|
||||
return schema.create(*conn);
|
||||
} );
|
||||
REQUIRE(result.is_ok());
|
||||
|
||||
auto plane = ses.insert<airplane>(1, "Boeing", "A380");
|
||||
@@ -105,8 +117,11 @@ TEST_CASE_METHOD(SessionFixture, "Session relation test", "[session][relation]")
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(SessionFixture, "Use session to find object with id", "[session][find]") {
|
||||
const auto result = ses.attach<airplane>("airplanes")
|
||||
.and_then([this] { return ses.create_schema(); } );
|
||||
const auto result = schema.attach<airplane>("airplanes")
|
||||
.and_then([this] {
|
||||
const auto conn = pool.acquire();
|
||||
return schema.create(*conn);
|
||||
} );
|
||||
REQUIRE(result.is_ok());
|
||||
|
||||
auto a380 = ses.insert<airplane>(1, "Boeing", "A380");
|
||||
@@ -124,8 +139,11 @@ TEST_CASE_METHOD(SessionFixture, "Use session to find object with id", "[session
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(SessionFixture, "Use session to find all objects", "[session][find]") {
|
||||
const auto result = ses.attach<airplane>("airplanes")
|
||||
.and_then([this] { return ses.create_schema(); } );
|
||||
const auto result = schema.attach<airplane>("airplanes")
|
||||
.and_then([this] {
|
||||
const auto conn = pool.acquire();
|
||||
return schema.create(*conn);
|
||||
} );
|
||||
REQUIRE(result.is_ok());
|
||||
|
||||
std::vector<std::unique_ptr<airplane>> planes;
|
||||
@@ -157,9 +175,12 @@ TEST_CASE_METHOD(SessionFixture, "Use session to find all objects", "[session][f
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(SessionFixture, "Use session to find all objects with one-to-many lazy relation", "[session][find][one-to-many][eager]") {
|
||||
auto result = ses.attach<author>("authors")
|
||||
.and_then( [this] { return ses.attach<book>("books"); } )
|
||||
.and_then( [this] { return ses.create_schema(); } );
|
||||
auto result = schema.attach<author>("authors")
|
||||
.and_then( [this] { return schema.attach<book>("books"); } )
|
||||
.and_then([this] {
|
||||
const auto conn = pool.acquire();
|
||||
return schema.create(*conn);
|
||||
} );
|
||||
|
||||
std::vector<std::unique_ptr<author>> authors;
|
||||
authors.emplace_back(new author{1, "Michael", "Crichton", "23.10.1942", 1975, true, {}});
|
||||
@@ -207,9 +228,12 @@ TEST_CASE_METHOD(SessionFixture, "Use session to find all objects with one-to-ma
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(SessionFixture, "Use session to find all objects with one-to-many eager relation", "[session][find][one-to-many][eager]") {
|
||||
auto result = ses.attach<department>("departments")
|
||||
.and_then( [this] { return ses.attach<employee>("employees"); } )
|
||||
.and_then( [this] { return ses.create_schema(); } );
|
||||
auto result = schema.attach<department>("departments")
|
||||
.and_then( [this] { return schema.attach<employee>("employees"); } )
|
||||
.and_then([this] {
|
||||
const auto conn = pool.acquire();
|
||||
return schema.create(*conn);
|
||||
} );
|
||||
|
||||
std::vector<std::unique_ptr<department>> departments;
|
||||
departments.emplace_back(new department{1, "Insurance", {}});
|
||||
@@ -260,9 +284,12 @@ TEST_CASE_METHOD(SessionFixture, "Use session to find all objects with one-to-ma
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(SessionFixture, "Use session to find all objects with many-to-many eager relation", "[session][find][many-to-many][eager]") {
|
||||
auto result = ses.attach<recipe>("recipes")
|
||||
.and_then( [this] { return ses.attach<ingredient>("ingredients"); } )
|
||||
.and_then( [this] { return ses.create_schema(); } );
|
||||
auto result = schema.attach<recipe>("recipes")
|
||||
.and_then( [this] { return schema.attach<ingredient>("ingredients"); } )
|
||||
.and_then([this] {
|
||||
const auto conn = pool.acquire();
|
||||
return schema.create(*conn);
|
||||
} );
|
||||
|
||||
std::vector<std::unique_ptr<ingredient>> ingredients;
|
||||
ingredients.push_back(std::make_unique<ingredient>(1, "Apple"));
|
||||
|
||||
Reference in New Issue
Block a user