Tests: Wait for DB to start.

This commit is contained in:
lganzzzo 2021-02-10 03:40:59 +02:00
parent ca3c241fe9
commit b109c462a7

View File

@ -6,12 +6,34 @@
#include "types/FloatTest.hpp"
#include "types/InterpretationTest.hpp"
#include "oatpp-postgresql/orm.hpp"
#include "oatpp/core/base/Environment.hpp"
#include <thread>
#include <chrono>
namespace {
void runTests() {
OATPP_LOGI("Tests", "DB-URL='%s'", TEST_DB_URL);
auto connectionProvider = std::make_shared<oatpp::postgresql::ConnectionProvider>(TEST_DB_URL);
for(v_int32 i = 0; i < 6; i ++) {
try {
auto connection = connectionProvider->get();
if(connection) {
OATPP_LOGD("Tests", "Database is up! We've got a connection!");
break;
}
} catch (...) {
// DO NOTHING
}
OATPP_LOGD("Tests", "Database is not ready. Sleep 10s...");
std::this_thread::sleep_for(std::chrono::seconds(10));
}
OATPP_RUN_TEST(oatpp::test::postgresql::ql_template::ParserTest);
OATPP_RUN_TEST(oatpp::test::postgresql::types::IntTest);