From 5c9443849dd33e91690369f8194ac0cd725f23ec Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sat, 12 Jun 2021 20:31:17 +0100 Subject: Create a basic MySQL testing database class --- test/testdb-mysql.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 test/testdb-mysql.cpp (limited to 'test/testdb-mysql.cpp') 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 +#include +#include + +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"); + } + } +} -- cgit v1.2.3