summaryrefslogtreecommitdiff
path: root/test/testdb-mysql.cpp
blob: 20ba677238a4a2d20aee4d3138b881fc0b738186 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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");
		}
	}
}