summaryrefslogtreecommitdiff
path: root/libmysqlpp/my-mock.cpp
blob: 97783d7b851a6af5df4e51d22121afdad5f2edcb (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
27
28
29
30
31
32
33
34
#include "my-mock.h"
#include "connection_fwd.h"
#include "mockDatabase.h"
#include "my-connection.h"
#include <compileTimeFormatter.h>
#include <factory.h>
#include <memory>
#include <string>
#include <vector>

NAMEDFACTORY("mysql", MySQL::Mock, DB::MockDatabaseFactory)

namespace MySQL {

	Mock::Mock(const std::string & master, const std::string & name, const std::vector<std::filesystem::path> & ss) :
		MockServerDatabase(master, name, "mysql")
	{
		CreateNewDatabase();
		PlaySchemaScripts(ss);
	}

	AdHocFormatter(MockConnStr, "options=libdbpp;database=%?");
	DB::ConnectionPtr
	Mock::openConnection() const
	{
		return std::make_shared<Connection>(MockConnStr::get(testDbName));
	}

	Mock::~Mock()
	{
		DropDatabase();
	}

}