diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2021-06-12 20:31:17 +0100 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2021-06-12 20:31:17 +0100 |
commit | 5c9443849dd33e91690369f8194ac0cd725f23ec (patch) | |
tree | c0495ffb12436a4535d2a15e375826a15c744883 /test/testdb-mysql.cpp | |
parent | Avoid direct use of runtime_error in MySQL stuff (diff) | |
download | mygrate-5c9443849dd33e91690369f8194ac0cd725f23ec.tar.bz2 mygrate-5c9443849dd33e91690369f8194ac0cd725f23ec.tar.xz mygrate-5c9443849dd33e91690369f8194ac0cd725f23ec.zip |
Create a basic MySQL testing database class
Diffstat (limited to 'test/testdb-mysql.cpp')
-rw-r--r-- | test/testdb-mysql.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/test/testdb-mysql.cpp b/test/testdb-mysql.cpp new file mode 100644 index 0000000..20ba677 --- /dev/null +++ b/test/testdb-mysql.cpp @@ -0,0 +1,26 @@ +#include "testdb-mysql.h" +#include <cstdlib> +#include <helpers.h> +#include <input/mysqlConn.h> + +namespace MyGrate { + namespace Testing { + const auto SERVER {MyGrate::getenv("MYGRATE_MYSQL_SERVER", "localhost")}; + const auto USER {MyGrate::getenv("MYGRATE_MYSQL_USER", ::getenv("LOGNAME"))}; + const auto PASSWORD {::getenv("MYGRATE_MYSQL_PASSWORD")}; + const auto PORT {(unsigned short)std::atoi(MyGrate::getenv("MYGRATE_MYSQL_PORT", "3306"))}; + + MySQLDB::MySQLDB() : MySQLConn(SERVER, USER, PASSWORD, PORT) + { + query("DROP DATABASE IF EXISTS mygrate_test"); + query("CREATE DATABASE mygrate_test"); + query("USE mygrate_test"); + } + + MySQLDB::~MySQLDB() + { + query("USE mysql"); + query("DROP DATABASE IF EXISTS mygrate_test"); + } + } +} |