diff options
-rw-r--r-- | gentoobrowse-api/service/main.cpp | 5 | ||||
-rw-r--r-- | gentoobrowse-api/unittests/mockDefs.cpp | 12 | ||||
-rw-r--r-- | gentoobrowse-api/unittests/mockDefs.h | 10 |
3 files changed, 23 insertions, 4 deletions
diff --git a/gentoobrowse-api/service/main.cpp b/gentoobrowse-api/service/main.cpp index 8d21d92..7fd74ca 100644 --- a/gentoobrowse-api/service/main.cpp +++ b/gentoobrowse-api/service/main.cpp @@ -37,10 +37,11 @@ namespace Gentoo { const Ice::ObjectAdapterPtr & adp) override { auto db = getConnectionPool(ic, "postgresql", "GentooBrowseAPI"); + auto dbp = getConnectionPool(ic, "postgresql", "GentooBrowseAPIprimary"); auto props = ic->getProperties(); IceTray::Cube::addObject<Gentoo::Portage, Portage>(adp, "portage", db); - IceTray::Cube::addObject<Gentoo::Maintenance, Maintenance>(adp, "maintenance", db, ic, props); - IceTray::Cube::addObject<Gentoo::Users, Users>(adp, "users", db); + IceTray::Cube::addObject<Gentoo::Maintenance, Maintenance>(adp, "maintenance", dbp, ic, props); + IceTray::Cube::addObject<Gentoo::Users, Users>(adp, "users", dbp); IceTray::Cube::add<Gentoo::Notifications, Notifications>(); IceTray::Cube::add<IceTray::Mail::MailServer, IceTray::Mail::LibesmtpMailServer>( props->getPropertyWithDefault("GentooBrowseAPI.MailServer", "localhost:25")); diff --git a/gentoobrowse-api/unittests/mockDefs.cpp b/gentoobrowse-api/unittests/mockDefs.cpp index 60241cd..2152220 100644 --- a/gentoobrowse-api/unittests/mockDefs.cpp +++ b/gentoobrowse-api/unittests/mockDefs.cpp @@ -6,6 +6,18 @@ #include <notifications.h> #include <tidy.h> +DbAlias::DbAlias() +{ + AdHoc::PluginManager::getDefault()->add( + AdHoc::PluginManager::getDefault()->get<DB::MockDatabase>("GentooBrowseAPI")->implementation(), + "GentooBrowseAPIprimary", __FILE__, __LINE__); +} + +DbAlias::~DbAlias() +{ + AdHoc::PluginManager::getDefault()->remove<DB::MockDatabase>("GentooBrowseAPIprimary"); +} + Service::Service() : DB::PluginMock<PQ::Mock>("GentooBrowseAPI", {rootDir.parent_path() / "db" / "schema.sql", rootDir / "data.sql"}, "user=postgres dbname=postgres") diff --git a/gentoobrowse-api/unittests/mockDefs.h b/gentoobrowse-api/unittests/mockDefs.h index 7600e15..327f293 100644 --- a/gentoobrowse-api/unittests/mockDefs.h +++ b/gentoobrowse-api/unittests/mockDefs.h @@ -12,12 +12,18 @@ #include <users.h> #include <visibility.h> -class DLL_PUBLIC Service : public IceTray::DryIce, DB::PluginMock<PQ::Mock> { +class DLL_PUBLIC DbAlias { +public: + DbAlias(); + virtual ~DbAlias(); +}; + +class DLL_PUBLIC Service : public IceTray::DryIce, DB::PluginMock<PQ::Mock>, DbAlias { public: Service(); }; -class DLL_PUBLIC Maintenance : public IceTray::DryIce, DB::PluginMock<PQ::Mock> { +class DLL_PUBLIC Maintenance : public IceTray::DryIce, DB::PluginMock<PQ::Mock>, DbAlias { public: Maintenance(); }; |