summaryrefslogtreecommitdiff
path: root/libodbcpp/odbc-mock.cpp
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2016-01-04 19:46:34 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2016-01-04 19:46:34 +0000
commitdcf0c906a22e7f23495ee8fe5c30c2d1870f7639 (patch)
tree666533e14c2fdca28df953a3d060b9aa592ee050 /libodbcpp/odbc-mock.cpp
parentFix error message creation in exception (diff)
downloadlibdbpp-odbc-dcf0c906a22e7f23495ee8fe5c30c2d1870f7639.tar.bz2
libdbpp-odbc-dcf0c906a22e7f23495ee8fe5c30c2d1870f7639.tar.xz
libdbpp-odbc-dcf0c906a22e7f23495ee8fe5c30c2d1870f7639.zip
Take an extra argument to mock to allow for specifying which driver to use, etc. Move all the PostgreSQL specific bits into the unit test itself. Reference the driver library by filename thus not requiring configuration for the test to run.libdbpp-odbc-1.0.1
Diffstat (limited to 'libodbcpp/odbc-mock.cpp')
-rw-r--r--libodbcpp/odbc-mock.cpp8
1 files changed, 4 insertions, 4 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();
}