summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2018-04-22 13:29:45 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2018-04-22 13:29:45 +0100
commitc083cf65bc6a7df2528a5fe41112fb1806755463 (patch)
treeb2bbff60bea4bf4c241e2ae9ee8fc1cda49d5ef3
parentUpdate to latest libdbpq (diff)
downloadlibdbpp-c083cf65bc6a7df2528a5fe41112fb1806755463.tar.bz2
libdbpp-c083cf65bc6a7df2528a5fe41112fb1806755463.tar.xz
libdbpp-c083cf65bc6a7df2528a5fe41112fb1806755463.zip
Variadic mock pool constructor
Support for variadic constructor arguments for MockPool. Irritatingly breaks the signature by having to move the varargs to the end from the front.
-rw-r--r--libdbpp/mockDatabase.h5
-rw-r--r--libdbpp/unittests/testConnectionPool.cpp2
-rw-r--r--libdbpp/unittests/testPatch.cpp2
-rw-r--r--libdbpp/unittests/testUtils.cpp4
4 files changed, 7 insertions, 6 deletions
diff --git a/libdbpp/mockDatabase.h b/libdbpp/mockDatabase.h
index 2510c73..d3e5bff 100644
--- a/libdbpp/mockDatabase.h
+++ b/libdbpp/mockDatabase.h
@@ -63,10 +63,11 @@ class DLL_PUBLIC MockServerDatabase : public MockDatabase {
template<typename T>
class PluginMock {
public:
- PluginMock(const std::string & m, const std::string & name, const std::vector<boost::filesystem::path> & s) :
+ template<typename ... Args>
+ PluginMock(const std::string & name, const std::initializer_list<boost::filesystem::path> & s, const Args & ... args) :
mockName(name)
{
- AdHoc::PluginManager::getDefault()->create<MockDatabase, T>(mockName, __FILE__, __LINE__, m, name, s);
+ AdHoc::PluginManager::getDefault()->create<MockDatabase, T>(mockName, __FILE__, __LINE__, args..., name, s);
}
~PluginMock()
{
diff --git a/libdbpp/unittests/testConnectionPool.cpp b/libdbpp/unittests/testConnectionPool.cpp
index 124df5b..de3de79 100644
--- a/libdbpp/unittests/testConnectionPool.cpp
+++ b/libdbpp/unittests/testConnectionPool.cpp
@@ -8,7 +8,7 @@
class MockPool : public DB::PluginMock<PQ::Mock>, public DB::ConnectionPool {
public:
MockPool() :
- PluginMock<PQ::Mock>("user=postgres dbname=postgres", "pqmock", { }),
+ PluginMock<PQ::Mock>("pqmock", { }, "user=postgres dbname=postgres"),
DB::ConnectionPool(4, 2, "postgresql", stringbf("user=postgres dbname=%s", databaseName()))
{
}
diff --git a/libdbpp/unittests/testPatch.cpp b/libdbpp/unittests/testPatch.cpp
index b9ede04..a1c77d3 100644
--- a/libdbpp/unittests/testPatch.cpp
+++ b/libdbpp/unittests/testPatch.cpp
@@ -13,7 +13,7 @@
class Mock : public DB::PluginMock<PQ::Mock> {
public:
Mock() :
- DB::PluginMock<PQ::Mock>("user=postgres dbname=postgres", "pqmock", { rootDir / "patch.sql" })
+ DB::PluginMock<PQ::Mock>("pqmock", { rootDir / "patch.sql" }, "user=postgres dbname=postgres")
{
}
};
diff --git a/libdbpp/unittests/testUtils.cpp b/libdbpp/unittests/testUtils.cpp
index c926a47..04fad4f 100644
--- a/libdbpp/unittests/testUtils.cpp
+++ b/libdbpp/unittests/testUtils.cpp
@@ -15,8 +15,8 @@
class StandardMockDatabase : public DB::PluginMock<PQ::Mock> {
public:
- StandardMockDatabase() : DB::PluginMock<PQ::Mock>("user=postgres dbname=postgres", "pqmock", {
- rootDir / "util.sql" })
+ StandardMockDatabase() : DB::PluginMock<PQ::Mock>("pqmock", {
+ rootDir / "util.sql" }, "user=postgres dbname=postgres")
{
}
};