From eb526b1ba4e69fe2fc1e741dbbe6809fbb8b2feb Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Tue, 1 Mar 2022 00:39:57 +0000 Subject: Clear sent emails on fixture exit --- gentoobrowse-api/unittests/mockDefs.cpp | 7 +++++++ gentoobrowse-api/unittests/mockDefs.h | 4 ++++ gentoobrowse-api/unittests/testUsers.cpp | 2 +- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/gentoobrowse-api/unittests/mockDefs.cpp b/gentoobrowse-api/unittests/mockDefs.cpp index 7f78b9d..883f84d 100644 --- a/gentoobrowse-api/unittests/mockDefs.cpp +++ b/gentoobrowse-api/unittests/mockDefs.cpp @@ -68,6 +68,13 @@ TestClient::TestClient() : BOOST_REQUIRE(u); } +TestClient::~TestClient() +{ + if (mms) { + mms->clear(); + } +} + std::array TestClient::humanReadableParts(const IceTray::Mail::EmailPtr & e) const { diff --git a/gentoobrowse-api/unittests/mockDefs.h b/gentoobrowse-api/unittests/mockDefs.h index 404b2a2..8284f11 100644 --- a/gentoobrowse-api/unittests/mockDefs.h +++ b/gentoobrowse-api/unittests/mockDefs.h @@ -3,6 +3,7 @@ #include #include +#include #include #include #include @@ -49,6 +50,9 @@ public: class DLL_PUBLIC TestClient : public IceTray::DryIceClient { public: TestClient(); + ~TestClient(); + + SPECIAL_MEMBERS_DELETE(TestClient); Gentoo::MaintenancePrxPtr m; Gentoo::PortagePrxPtr p; diff --git a/gentoobrowse-api/unittests/testUsers.cpp b/gentoobrowse-api/unittests/testUsers.cpp index 0f5ee9c..4af063b 100644 --- a/gentoobrowse-api/unittests/testUsers.cpp +++ b/gentoobrowse-api/unittests/testUsers.cpp @@ -116,7 +116,7 @@ BOOST_AUTO_TEST_CASE(createAgain) * * resend verification */ auto user = u->create("testuser", "testpass", "Test User", "recreate@user.com"); - BOOST_REQUIRE_EQUAL(2, mms->getSentEmails().size()); + BOOST_REQUIRE_EQUAL(1, 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); -- cgit v1.2.3