added session test with has one relation
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
#include "matador/sql/session.hpp"
|
||||
|
||||
#include "models/airplane.hpp"
|
||||
#include "models/flight.hpp"
|
||||
|
||||
class SessionFixture
|
||||
{
|
||||
@@ -16,9 +17,8 @@ public:
|
||||
|
||||
~SessionFixture()
|
||||
{
|
||||
drop_table_if_exists("flight");
|
||||
drop_table_if_exists("airplane");
|
||||
drop_table_if_exists("person");
|
||||
drop_table_if_exists("flights");
|
||||
drop_table_if_exists("airplanes");
|
||||
}
|
||||
|
||||
protected:
|
||||
@@ -38,16 +38,19 @@ using namespace matador;
|
||||
|
||||
TEST_CASE_METHOD(SessionFixture, "Session relation test", "[session][relation]") {
|
||||
using namespace matador;
|
||||
ses.attach<test::airplane>("airplane");
|
||||
ses.attach<test::airplane>("airplanes");
|
||||
ses.attach<test::flight>("flights");
|
||||
ses.create_schema();
|
||||
ses.insert<test::airplane>(1, "Boeing", "A380");
|
||||
auto plane = ses.insert<test::airplane>(1, "Boeing", "A380");
|
||||
auto f = ses.insert<test::flight>(2, plane, "sully");
|
||||
|
||||
REQUIRE(true);
|
||||
auto result = ses.find<test::flight>(2);
|
||||
REQUIRE(result.is_ok());
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(SessionFixture, "Use session to find object with id", "[session][find]") {
|
||||
using namespace matador::test;
|
||||
ses.attach<airplane>("airplane");
|
||||
ses.attach<airplane>("airplanes");
|
||||
ses.create_schema();
|
||||
auto a380 = ses.insert<airplane>(1, "Boeing", "A380");
|
||||
|
||||
@@ -64,7 +67,7 @@ TEST_CASE_METHOD(SessionFixture, "Use session to find object with id", "[session
|
||||
|
||||
TEST_CASE_METHOD(SessionFixture, "Use session to find all objects", "[session][find]") {
|
||||
using namespace matador::test;
|
||||
ses.attach<airplane>("airplane");
|
||||
ses.attach<airplane>("airplanes");
|
||||
ses.create_schema();
|
||||
|
||||
std::vector<std::unique_ptr<airplane>> planes;
|
||||
|
||||
Reference in New Issue
Block a user