diff options
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"); + } + } +} |