#ifndef CATCH2_PGTAP_H
#define CATCH2_PGTAP_H
#include <external/catch2/catch.hpp>
#include <external/soci/include/soci/postgresql/soci-postgresql.h>
#include <external/soci/include/soci/soci.h>
// -----------------------------------------------------------------
// ------ some usefull TAP test macros -----------------------------
// -----------------------------------------------------------------
// ------ all tests inside transaction ... with NO commit ----------
// clang-format off
#define PGTAP_SETUP_TR(con_string) \
std::string connection_string = con_string; \
\
soci::session sql(soci::postgresql, connection_string); \
soci::indicator i1; \
std::string TAP; \
\
soci::transaction tr(sql); \
{ \
sql << "select * from no_plan()", soci::into(TAP, i1)
#define PGTAP_CLEANUP_TR \
sql << "SELECT * from finish(false)"; \
}
// ------ all tests without ----------------------------------------
#define PGTAP_SETUP(con_string) \
std::string connection_string = con_string; \
\
soci::session sql(soci::postgresql, connection_string); \
soci::indicator i1; \
std::string TAP; \
\
sql << "select * from no_plan()", soci::into(TAP, i1)
#define PGTAP_CLEANUP \
sql << "SELECT * from finish(false)"
// ------ test definition ------------------------------------------
#define PGTAP_TEST(test_sql) \
sql << test_sql, soci::into(TAP, i1); \
INFO(TAP); \
CHECK(TAP.find("ok") == 0)
// cla ng-format on
#endif