summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libodbcpp/odbc-mock.cpp8
-rw-r--r--libodbcpp/odbc-mock.h4
-rw-r--r--libodbcpp/unittests/testodbc.cpp8
3 files changed, 14 insertions, 6 deletions
diff --git a/libodbcpp/odbc-mock.cpp b/libodbcpp/odbc-mock.cpp
index 71c4c56..2799fb3 100644
--- a/libodbcpp/odbc-mock.cpp
+++ b/libodbcpp/odbc-mock.cpp
@@ -4,8 +4,9 @@
namespace ODBC {
-Mock::Mock(const std::string & masterdb, const std::string & name, const std::vector<boost::filesystem::path> & ss) :
- MockServerDatabase(masterdb, name, "odbc")
+Mock::Mock(const std::string & b, const std::string & masterdb, const std::string & name, const std::vector<boost::filesystem::path> & ss) :
+ MockServerDatabase(b + ";" + masterdb, name, "odbc"),
+ base(b)
{
CreateNewDatabase();
PlaySchemaScripts(ss);
@@ -14,7 +15,7 @@ Mock::Mock(const std::string & masterdb, const std::string & name, const std::ve
DB::Connection *
Mock::openConnection() const
{
- return new Connection(stringbf("Driver=postgresql;Database=%s;uid=postgres;servername=/run/postgresql", testDbName));
+ return new Connection(stringbf("%s;Database=%s", base, testDbName));
}
Mock::~Mock()
@@ -24,7 +25,6 @@ Mock::~Mock()
void Mock::DropDatabase() const
{
- master->execute("SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE datname = '" + testDbName + "'");
MockServerDatabase::DropDatabase();
}
diff --git a/libodbcpp/odbc-mock.h b/libodbcpp/odbc-mock.h
index d2bcbfe..f66d09d 100644
--- a/libodbcpp/odbc-mock.h
+++ b/libodbcpp/odbc-mock.h
@@ -9,9 +9,11 @@ namespace ODBC {
class DLL_PUBLIC Mock : public DB::MockServerDatabase {
public:
- Mock(const std::string & master, const std::string & name, const std::vector<boost::filesystem::path> & ss);
+ Mock(const std::string & base, const std::string & master, const std::string & name, const std::vector<boost::filesystem::path> & ss);
~Mock();
+ const std::string base;
+
protected:
void DropDatabase() const override;
diff --git a/libodbcpp/unittests/testodbc.cpp b/libodbcpp/unittests/testodbc.cpp
index f288bf8..77f0a71 100644
--- a/libodbcpp/unittests/testodbc.cpp
+++ b/libodbcpp/unittests/testodbc.cpp
@@ -13,10 +13,16 @@
class StandardMockDatabase : public ODBC::Mock {
public:
- StandardMockDatabase() : ODBC::Mock("Driver=postgresql;Database=postgres;uid=postgres;servername=/run/postgresql", "odbcmock", {
+ StandardMockDatabase() : ODBC::Mock("Driver=psqlodbcw.so;uid=postgres;servername=/run/postgresql", "Database=postgres", "odbcmock", {
rootDir / "odbcschema.sql" })
{
}
+
+ void DropDatabase() const override
+ {
+ master->execute("SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE datname = '" + testDbName + "'");
+ ODBC::Mock::DropDatabase();
+ }
};
BOOST_GLOBAL_FIXTURE( StandardMockDatabase );