diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2021-07-05 20:22:35 +0100 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2021-07-05 20:22:35 +0100 |
commit | cc4bcfbd5b3c67eb6a63e01328149b6e8fd3a034 (patch) | |
tree | a5f851065103b2960e6ab56b088706243d8a4d37 | |
parent | Test something more predictable (diff) | |
download | mygrate-cc4bcfbd5b3c67eb6a63e01328149b6e8fd3a034.tar.bz2 mygrate-cc4bcfbd5b3c67eb6a63e01328149b6e8fd3a034.tar.xz mygrate-cc4bcfbd5b3c67eb6a63e01328149b6e8fd3a034.zip |
Modernize namespaces
-rw-r--r-- | test/testdb-mysql.cpp | 44 | ||||
-rw-r--r-- | test/testdb-postgresql.cpp | 50 |
2 files changed, 45 insertions, 49 deletions
diff --git a/test/testdb-mysql.cpp b/test/testdb-mysql.cpp index 17bc241..24e41c0 100644 --- a/test/testdb-mysql.cpp +++ b/test/testdb-mysql.cpp @@ -4,31 +4,29 @@ #include <helpers.h> #include <input/mysqlConn.h> -namespace MyGrate { - namespace Testing { - const char * const MySQLDB::SERVER {MyGrate::getenv("MYGRATE_MYSQL_SERVER", "localhost")}; - const char * const MySQLDB::USER {MyGrate::getenv("MYGRATE_MYSQL_USER", ::getenv("LOGNAME"))}; - const char * const MySQLDB::PASSWORD {::getenv("MYGRATE_MYSQL_PASSWORD")}; - const unsigned short MySQLDB::PORT {(unsigned short)std::atoi(MyGrate::getenv("MYGRATE_MYSQL_PORT", "3306"))}; - std::size_t MySQLDB::mocknum; +namespace MyGrate::Testing { + const char * const MySQLDB::SERVER {MyGrate::getenv("MYGRATE_MYSQL_SERVER", "localhost")}; + const char * const MySQLDB::USER {MyGrate::getenv("MYGRATE_MYSQL_USER", ::getenv("LOGNAME"))}; + const char * const MySQLDB::PASSWORD {::getenv("MYGRATE_MYSQL_PASSWORD")}; + const unsigned short MySQLDB::PORT {(unsigned short)std::atoi(MyGrate::getenv("MYGRATE_MYSQL_PORT", "3306"))}; + std::size_t MySQLDB::mocknum; - MySQLDB::MySQLDB() : - MySQLConn(SERVER, USER, PASSWORD, PORT), mockname {scprintf<"mygrate_test_%?_%?">(getpid(), mocknum++)} - { - query(("DROP DATABASE IF EXISTS " + mockname).c_str()); - query(("CREATE DATABASE " + mockname).c_str()); - } + MySQLDB::MySQLDB() : + MySQLConn(SERVER, USER, PASSWORD, PORT), mockname {scprintf<"mygrate_test_%?_%?">(getpid(), mocknum++)} + { + query(("DROP DATABASE IF EXISTS " + mockname).c_str()); + query(("CREATE DATABASE " + mockname).c_str()); + } - MySQLDB::~MySQLDB() - { - query(("DROP DATABASE IF EXISTS " + mockname).c_str()); - mockname.clear(); - } + MySQLDB::~MySQLDB() + { + query(("DROP DATABASE IF EXISTS " + mockname).c_str()); + mockname.clear(); + } - Input::MySQLConn - MySQLDB::mock() const - { - return {SERVER, USER, PASSWORD, PORT, mockname.c_str()}; - } + Input::MySQLConn + MySQLDB::mock() const + { + return {SERVER, USER, PASSWORD, PORT, mockname.c_str()}; } } 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()}; } } |