mirror of
https://github.com/oatpp/oatpp-postgresql.git
synced 2024-11-21 01:05:09 +08:00
Tests: Wait for DB to start.
This commit is contained in:
parent
ca3c241fe9
commit
b109c462a7
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user