diff options
-rw-r--r-- | gentoobrowse-api/unittests/mockDefs.cpp | 2 | ||||
-rw-r--r-- | gentoobrowse-api/unittests/mockDefs.h | 2 | ||||
-rw-r--r-- | gentoobrowse-api/unittests/testNotificationsTriggers.cpp | 5 | ||||
-rw-r--r-- | gentoobrowse-api/unittests/testUsers.cpp | 20 |
4 files changed, 11 insertions, 18 deletions
diff --git a/gentoobrowse-api/unittests/mockDefs.cpp b/gentoobrowse-api/unittests/mockDefs.cpp index 1d4018e..7f78b9d 100644 --- a/gentoobrowse-api/unittests/mockDefs.cpp +++ b/gentoobrowse-api/unittests/mockDefs.cpp @@ -59,7 +59,7 @@ Mail::Mail() : TestClient::TestClient() : m(IceTray::Cube::get<Gentoo::Maintenance>()), p(IceTray::Cube::get<Gentoo::Portage>()), n(IceTray::Cube::get<Gentoo::Notifications>()), ms(IceTray::Cube::get<IceTray::Mail::MailServer>()), - u(IceTray::Cube::get<Gentoo::Users>()) + mms(std::dynamic_pointer_cast<IceTray::Mail::MockMailServerImpl>(ms)), u(IceTray::Cube::get<Gentoo::Users>()) { BOOST_REQUIRE(m); BOOST_REQUIRE(p); diff --git a/gentoobrowse-api/unittests/mockDefs.h b/gentoobrowse-api/unittests/mockDefs.h index 963112b..404b2a2 100644 --- a/gentoobrowse-api/unittests/mockDefs.h +++ b/gentoobrowse-api/unittests/mockDefs.h @@ -11,6 +11,7 @@ #include <maintenance.h> #include <memory> #include <mockDatabase.h> +#include <mockMailServer.h> #include <notifications.h> #include <portage.h> #include <selectcommandUtil.impl.h> @@ -53,6 +54,7 @@ public: Gentoo::PortagePrxPtr p; Gentoo::NotificationsPtr n; IceTray::Mail::MailServerPtr ms; + IceTray::Mail::MockMailServerPtr mms; Gentoo::UsersPrxPtr u; void lintable_test_files(std::string_view name, const IceTray::Mail::EmailPtr & e) const; diff --git a/gentoobrowse-api/unittests/testNotificationsTriggers.cpp b/gentoobrowse-api/unittests/testNotificationsTriggers.cpp index db53041..b353af8 100644 --- a/gentoobrowse-api/unittests/testNotificationsTriggers.cpp +++ b/gentoobrowse-api/unittests/testNotificationsTriggers.cpp @@ -53,13 +53,10 @@ BOOST_AUTO_TEST_CASE(triggers) BOOST_AUTO_TEST_CASE(send) { - auto ms = std::dynamic_pointer_cast<IceTray::Mail::MockMailServer>(this->ms); - BOOST_REQUIRE(ms); - BOOST_REQUIRE(!u->get(1)->lastmailshot); m->sendNotifications(); BOOST_REQUIRE(u->get(1)->lastmailshot); - const auto & es = ms->getSentEmails(); + const auto & es = mms->getSentEmails(); BOOST_REQUIRE_EQUAL(1, es.size()); BOOST_REQUIRE_EQUAL("Gentoo Browse: Latest updates", es[0]->subject); BOOST_REQUIRE_EQUAL("Dan Goodliffe", es[0]->to.name); diff --git a/gentoobrowse-api/unittests/testUsers.cpp b/gentoobrowse-api/unittests/testUsers.cpp index 1b74006..0f5ee9c 100644 --- a/gentoobrowse-api/unittests/testUsers.cpp +++ b/gentoobrowse-api/unittests/testUsers.cpp @@ -57,15 +57,11 @@ BOOST_AUTO_TEST_CASE(authenticateVerify) BOOST_AUTO_TEST_CASE(create) { - auto ms1 = IceTray::Cube::get<IceTray::Mail::MailServer>(); - BOOST_REQUIRE(ms1); - auto ms = std::dynamic_pointer_cast<IceTray::Mail::MockMailServer>(ms1); - BOOST_REQUIRE(ms); auto user = u->create("testuser", "testpass", "Test User", "test@user.com"); - BOOST_REQUIRE_EQUAL(1, ms->getSentEmails().size()); - BOOST_REQUIRE_EQUAL("Gentoo Browse: Welcome", ms->getSentEmails().front()->subject); - BOOST_REQUIRE_EQUAL("test@user.com", ms->getSentEmails().front()->to.address); - BOOST_REQUIRE_EQUAL("Test User", ms->getSentEmails().front()->to.name); + BOOST_REQUIRE_EQUAL(1, mms->getSentEmails().size()); + BOOST_REQUIRE_EQUAL("Gentoo Browse: Welcome", mms->getSentEmails().front()->subject); + BOOST_REQUIRE_EQUAL("test@user.com", mms->getSentEmails().front()->to.address); + BOOST_REQUIRE_EQUAL("Test User", mms->getSentEmails().front()->to.name); BOOST_REQUIRE_EQUAL(4, user->userid); BOOST_REQUIRE_EQUAL("testuser", user->username); BOOST_REQUIRE_EQUAL("Test User", user->userrealname); @@ -119,12 +115,10 @@ BOOST_AUTO_TEST_CASE(createAgain) * * return original user * * resend verification */ - auto ms = std::dynamic_pointer_cast<IceTray::Mail::MockMailServerImpl>(this->ms); - BOOST_REQUIRE(ms); auto user = u->create("testuser", "testpass", "Test User", "recreate@user.com"); - BOOST_REQUIRE_EQUAL(2, ms->getSentEmails().size()); - BOOST_REQUIRE_EQUAL("Gentoo Browse: Welcome", ms->getSentEmails()[1]->subject); - BOOST_REQUIRE_EQUAL("test@user.com", ms->getSentEmails()[1]->to.address); + BOOST_REQUIRE_EQUAL(2, mms->getSentEmails().size()); + BOOST_REQUIRE_EQUAL("Gentoo Browse: Welcome", mms->getSentEmails()[0]->subject); + BOOST_REQUIRE_EQUAL("test@user.com", mms->getSentEmails()[0]->to.address); BOOST_REQUIRE_EQUAL(4, user->userid); BOOST_REQUIRE_EQUAL(36, user->verifyguid.length()); } |