Skip to content

Commit b109c46

Browse files
committed
Tests: Wait for DB to start.
1 parent ca3c241 commit b109c46

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

test/oatpp-postgresql/tests.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,34 @@
66
#include "types/FloatTest.hpp"
77
#include "types/InterpretationTest.hpp"
88

9+
10+
#include "oatpp-postgresql/orm.hpp"
911
#include "oatpp/core/base/Environment.hpp"
1012

13+
#include <thread>
14+
#include <chrono>
15+
1116
namespace {
1217

1318
void runTests() {
1419

20+
OATPP_LOGI("Tests", "DB-URL='%s'", TEST_DB_URL);
21+
auto connectionProvider = std::make_shared<oatpp::postgresql::ConnectionProvider>(TEST_DB_URL);
22+
for(v_int32 i = 0; i < 6; i ++) {
23+
try {
24+
auto connection = connectionProvider->get();
25+
if(connection) {
26+
OATPP_LOGD("Tests", "Database is up! We've got a connection!");
27+
break;
28+
}
29+
} catch (...) {
30+
// DO NOTHING
31+
}
32+
33+
OATPP_LOGD("Tests", "Database is not ready. Sleep 10s...");
34+
std::this_thread::sleep_for(std::chrono::seconds(10));
35+
}
36+
1537
OATPP_RUN_TEST(oatpp::test::postgresql::ql_template::ParserTest);
1638

1739
OATPP_RUN_TEST(oatpp::test::postgresql::types::IntTest);

0 commit comments

Comments
 (0)