#include "catch2/catch_test_macros.hpp" #include "connection.hpp" #include "matador/sql/session.hpp" #include "models/airplane.hpp" class SessionFixture { public: SessionFixture() : pool(matador::test::connection::dns, 4) , ses(pool) {} ~SessionFixture() { drop_table_if_exists("flight"); drop_table_if_exists("airplane"); drop_table_if_exists("person"); } protected: matador::sql::connection_pool pool; matador::sql::session ses; private: void drop_table_if_exists(const std::string &table_name) { if (ses.table_exists(table_name)) { ses.drop_table(table_name); } } }; using namespace matador; TEST_CASE_METHOD(SessionFixture, "Session relation test", "[session][relation]") { using namespace matador; ses.attach("airplane"); ses.create_schema(); ses.insert(1, "Boeing", "A380"); REQUIRE(true); } TEST_CASE_METHOD(SessionFixture, "Find object with id", "[session][find]") { using namespace matador::test; ses.attach("airplane"); ses.create_schema(); auto a380 = ses.insert(1, "Boeing", "A380"); ses.find(1); }