summaryrefslogtreecommitdiff
path: root/tests/database.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/database.cpp')
-rw-r--r--tests/database.cpp19
1 files changed, 17 insertions, 2 deletions
diff --git a/tests/database.cpp b/tests/database.cpp
index aeddea3..20a446b 100644
--- a/tests/database.cpp
+++ b/tests/database.cpp
@@ -1,14 +1,29 @@
#include "catch.hpp"
+#include <biboumi.h>
+
+#ifdef USE_DATABASE
+
+#include <cstdlib>
+
#include <database/database.hpp>
#include <config/config.hpp>
TEST_CASE("Database")
{
-#ifdef USE_DATABASE
-// Database::open("postgresql://test");
+#ifdef PQ_FOUND
+ std::string postgresql_uri{"postgresql://"};
+ const char* env_value = ::getenv("TEST_POSTGRES_URI");
+ if (env_value != nullptr)
+ postgresql_uri += env_value;
+ else
+ postgresql_uri += "/test";
+ Database::open(postgresql_uri);
+#else
Database::open(":memory:");
+#endif
+
Database::raw_exec("DELETE FROM " + Database::irc_server_options.get_name());
Database::raw_exec("DELETE FROM " + Database::irc_channel_options.get_name());