summaryrefslogtreecommitdiff
path: root/test/testdb-postgresql.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'test/testdb-postgresql.cpp')
-rw-r--r--test/testdb-postgresql.cpp50
1 files changed, 24 insertions, 26 deletions
diff --git a/test/testdb-postgresql.cpp b/test/testdb-postgresql.cpp
index c59640a..94a587e 100644
--- a/test/testdb-postgresql.cpp
+++ b/test/testdb-postgresql.cpp
@@ -5,37 +5,35 @@
#include <helpers.h>
#include <output/pq/pqConn.h>
-namespace MyGrate {
- namespace Testing {
- const auto CONNSTR {MyGrate::getenv("MYGRATE_POSTGRESQL_CONNSTR", "user=postgres")};
- std::size_t PqConnDB::mocknum;
+namespace MyGrate::Testing {
+ const auto CONNSTR {MyGrate::getenv("MYGRATE_POSTGRESQL_CONNSTR", "user=postgres")};
+ std::size_t PqConnDB::mocknum;
- PqConnDB::PqConnDB() : PqConn(CONNSTR), mockname {scprintf<"mygrate_test_%?_%?">(getpid(), mocknum++)}
- {
- query(("DROP DATABASE IF EXISTS " + mockname).c_str());
- query(("CREATE DATABASE " + mockname).c_str());
- }
+ PqConnDB::PqConnDB() : PqConn(CONNSTR), mockname {scprintf<"mygrate_test_%?_%?">(getpid(), mocknum++)}
+ {
+ query(("DROP DATABASE IF EXISTS " + mockname).c_str());
+ query(("CREATE DATABASE " + mockname).c_str());
+ }
- PqConnDB::PqConnDB(const std::string & schemaFile) : PqConnDB()
- {
- auto mdb = mock();
+ PqConnDB::PqConnDB(const std::string & schemaFile) : PqConnDB()
+ {
+ auto mdb = mock();
- std::stringstream buffer;
- buffer << std::ifstream(schemaFile).rdbuf();
+ std::stringstream buffer;
+ buffer << std::ifstream(schemaFile).rdbuf();
- mdb.query(buffer.str().c_str());
- }
+ mdb.query(buffer.str().c_str());
+ }
- PqConnDB::~PqConnDB()
- {
- query(("DROP DATABASE IF EXISTS " + mockname).c_str());
- mockname.clear();
- }
+ PqConnDB::~PqConnDB()
+ {
+ query(("DROP DATABASE IF EXISTS " + mockname).c_str());
+ mockname.clear();
+ }
- Output::Pq::PqConn
- PqConnDB::mock() const
- {
- return PqConn {scprintf<"%? dbname=%?">(CONNSTR, mockname).c_str()};
- }
+ Output::Pq::PqConn
+ PqConnDB::mock() const
+ {
+ return PqConn {scprintf<"%? dbname=%?">(CONNSTR, mockname).c_str()};
}
}