added session test (progress)
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
#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<matador::sql::connection> 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]") {
|
||||
|
||||
ses.attach<matador::test::airplane>("airplane");
|
||||
ses.insert<test::airplane>(1, "Boeing", "A380");
|
||||
|
||||
REQUIRE(true);
|
||||
}
|
||||
Reference in New Issue
Block a user