summaryrefslogtreecommitdiff
path: root/gentoobrowse-api/unittests/testMaintenance.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'gentoobrowse-api/unittests/testMaintenance.cpp')
-rw-r--r--gentoobrowse-api/unittests/testMaintenance.cpp18
1 files changed, 5 insertions, 13 deletions
diff --git a/gentoobrowse-api/unittests/testMaintenance.cpp b/gentoobrowse-api/unittests/testMaintenance.cpp
index b2f88cc..a23444a 100644
--- a/gentoobrowse-api/unittests/testMaintenance.cpp
+++ b/gentoobrowse-api/unittests/testMaintenance.cpp
@@ -9,6 +9,7 @@
#include <fstream>
#include <maintenanceimpl.h>
#include <portageimpl.h>
+#include <mockPool.h>
class MaintenanceClientCombined : public Maintenance, public TestClient { };
@@ -70,7 +71,7 @@ class M2 : public Gentoo::Service::Maintenance {
public:
typedef std::map<boost::filesystem::path, size_t> FileMap;
- M2(IceTray::DatabasePoolPtr d) :
+ M2(const DB::ConnectionPoolPtr & d) :
Gentoo::Service::Maintenance(d)
{
}
@@ -80,7 +81,7 @@ class M2 : public Gentoo::Service::Maintenance {
auto dbc = db->get();
auto fromFiles = fileSet(from);
auto toFiles = fileSet(to);
- DB::TransactionScope tx(dbc.get());
+ DB::TransactionScope tx(*dbc.get());
Gentoo::Service::ChangeSet changes;
newFiles(changes, fromFiles, toFiles);
removedFiles(changes, fromFiles, toFiles);
@@ -139,15 +140,6 @@ class M2 : public Gentoo::Service::Maintenance {
}
};
-class MockPool : public IceTray::DatabasePool {
- public:
- MockPool() : IceTray::DatabasePool(10, 2) {}
- DB::Connection * createResource() const override
- {
- return DB::MockDatabase::openConnectionTo("GentooBrowseAPI");
- }
-};
-
#define BOOST_TEST_CONTEXT_VAR(VAR, EXPR) \
BOOST_TEST_CONTEXT(#EXPR) \
for (auto VAR = EXPR, * __context__run = &VAR; __context__run; __context__run = NULL)
@@ -165,7 +157,7 @@ BOOST_AUTO_TEST_CASE( refreshPackageTree )
boost::filesystem::remove_all(binDir / "empty");
boost::filesystem::create_directory(binDir / "empty");
- auto p = IceTray::DatabasePoolPtr(new MockPool());
+ auto p = std::make_shared<IceTray::MockPool>("GentooBrowseAPI", 1, 1);
M2 m2(p);
BOOST_TEST_CONTEXT("4156eb45cf3b0ce1d7125b84efd8688c2d6e831d") {
@@ -173,7 +165,7 @@ BOOST_AUTO_TEST_CASE( refreshPackageTree )
doRefreshPackageTree(db,
5, 1, 482, 981, 3626, 4593, 501, 393, 238, 50, 1573, 2008, 1543, 81, 152, 7);
- Gentoo::PortagePtr portage = new Gentoo::Service::Portage(p);
+ Gentoo::PortagePtr portage = std::make_shared<Gentoo::Service::Portage>(p);
BOOST_TEST_CONTEXT_VAR(acjtr, portage->findPackage("app-crypt", "johntheripper", Ice::Current())) {
BOOST_TEST_CONTEXT_VAR(acjtrUses, portage->getPackageUses(acjtr->packageid, Ice::Current())) {
BOOST_REQUIRE_EQUAL(9, acjtrUses.size());