diff options
| author | Dan Goodliffe <dan@randomdan.homeip.net> | 2017-01-03 20:48:06 +0000 | 
|---|---|---|
| committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2017-01-03 20:48:06 +0000 | 
| commit | 5c918ffba1932a5ba76344352f7ae1062403ead0 (patch) | |
| tree | fa0f6e6947402919e18f17bea3a71861a8915c3c | |
| parent | Support merging when applying updates that target existing packages (diff) | |
| download | gentoobrowse-api-5c918ffba1932a5ba76344352f7ae1062403ead0.tar.bz2 gentoobrowse-api-5c918ffba1932a5ba76344352f7ae1062403ead0.tar.xz gentoobrowse-api-5c918ffba1932a5ba76344352f7ae1062403ead0.zip | |
Introduce to mock mail server
| -rw-r--r-- | gentoobrowse-api/unittests/Jamfile.jam | 7 | ||||
| -rw-r--r-- | gentoobrowse-api/unittests/mockDefs.cpp | 25 | ||||
| -rw-r--r-- | gentoobrowse-api/unittests/mockDefs.h | 15 | ||||
| -rw-r--r-- | gentoobrowse-api/unittests/mocks.ice | 15 | ||||
| -rw-r--r-- | gentoobrowse-api/unittests/testNotifications.cpp | 2 | 
5 files changed, 60 insertions, 4 deletions
| diff --git a/gentoobrowse-api/unittests/Jamfile.jam b/gentoobrowse-api/unittests/Jamfile.jam index 70fa90f..60ee5e6 100644 --- a/gentoobrowse-api/unittests/Jamfile.jam +++ b/gentoobrowse-api/unittests/Jamfile.jam @@ -15,6 +15,7 @@ alias test-data :  lib testCommon :  	mockDefs.cpp +	mocks.ice  	:  	<library>dbpp-postgresql  	<library>..//dbppcore @@ -63,6 +64,7 @@ run  	<dependency>../db/schema.sql  	<define>BOOST_TEST_DYN_LINK  	<library>testCommon +	<implicit-dependency>testCommon  	: testChangeLog ;  run @@ -79,6 +81,7 @@ run  	<dependency>../db/schema.sql  	<define>BOOST_TEST_DYN_LINK  	<library>testCommon +	<implicit-dependency>testCommon  	: testMaintenance ;  run @@ -87,6 +90,7 @@ run  	<dependency>../db/schema.sql  	<define>BOOST_TEST_DYN_LINK  	<library>testCommon +	<implicit-dependency>testCommon  	: testPortage ;  run @@ -95,6 +99,7 @@ run  	<dependency>../db/schema.sql  	<define>BOOST_TEST_DYN_LINK  	<library>testCommon +	<implicit-dependency>testCommon  	: testUsers ;  run @@ -103,6 +108,7 @@ run  	<dependency>../db/schema.sql  	<define>BOOST_TEST_DYN_LINK  	<library>testCommon +	<implicit-dependency>testCommon  	: testNotifications ;  run @@ -111,6 +117,7 @@ run  	<dependency>../db/schema.sql  	<define>BOOST_TEST_DYN_LINK  	<library>testCommon +	<implicit-dependency>testCommon  	: testBugs ;  explicit testPerf ; diff --git a/gentoobrowse-api/unittests/mockDefs.cpp b/gentoobrowse-api/unittests/mockDefs.cpp index eeab5f2..cfe426b 100644 --- a/gentoobrowse-api/unittests/mockDefs.cpp +++ b/gentoobrowse-api/unittests/mockDefs.cpp @@ -1,14 +1,25 @@  #include "mockDefs.h"  #include <definedDirs.h> +#include <notifications.h> + +void +MockMailServerImpl::sendEmail(const Gentoo::EmailPtr & e, const Ice::Current &) +{ +	sentEmails.push_back(e); +} + +Gentoo::Emails +MockMailServerImpl::getSentEmails(const Ice::Current &) +{ +	return sentEmails; +}  Service::Service() : -	IceTray::DryIce({ -			"--GentooBrowseAPI.MailServer=smtp.random.lan:25", -		}),  	PQ::Mock("user=postgres dbname=postgres", "GentooBrowseAPI", {  			rootDir.parent_path() / "db" / "schema.sql",  			rootDir / "data.sql" })  { +	replace("mailserver", new MockMailServerImpl());  }  Maintenance::Maintenance() : @@ -20,6 +31,14 @@ Maintenance::Maintenance() :  			rootDir.parent_path() / "db" / "schema.sql",  			rootDir / "basedata.sql" })  { +	replace("mailserver", new MockMailServerImpl()); +} + +Mail::Mail() : +	IceTray::DryIce({ +			"--GentooBrowseAPI.MailServer=smtp.random.lan:25", +		}) +{  }  TestClient::TestClient() : diff --git a/gentoobrowse-api/unittests/mockDefs.h b/gentoobrowse-api/unittests/mockDefs.h index a0c044a..5bb1cd5 100644 --- a/gentoobrowse-api/unittests/mockDefs.h +++ b/gentoobrowse-api/unittests/mockDefs.h @@ -8,8 +8,18 @@  #include <users.h>  #include <maintenance.h>  #include <notifications.h> +#include <mocks.h>  #include <selectcommandUtil.impl.h> +class MockMailServerImpl : public Gentoo::MockMailServer { +	public: +		void sendEmail(const Gentoo::EmailPtr & msg, const Ice::Current &) override; +		Gentoo::Emails getSentEmails(const Ice::Current &) override; + +	private: +		Gentoo::Emails sentEmails; +}; +  class DLL_PUBLIC Service : public IceTray::DryIce, PQ::Mock {  	public:  		Service(); @@ -20,6 +30,11 @@ class DLL_PUBLIC Maintenance : public IceTray::DryIce, PQ::Mock {  		Maintenance();  }; +class DLL_PUBLIC Mail : public IceTray::DryIce { +	public: +		Mail(); +}; +  class DLL_PUBLIC TestClient : public IceTray::DryIceClient {  	public:  		TestClient(); diff --git a/gentoobrowse-api/unittests/mocks.ice b/gentoobrowse-api/unittests/mocks.ice new file mode 100644 index 0000000..f780d59 --- /dev/null +++ b/gentoobrowse-api/unittests/mocks.ice @@ -0,0 +1,15 @@ +#ifndef GENTOO_MOCKS +#define GENTOO_MOCKS + +#include <notifications.ice> + +module Gentoo { +	sequence<Email> Emails; + +	interface MockMailServer extends MailServer { +		Emails getSentEmails(); +	}; +}; + +#endif + diff --git a/gentoobrowse-api/unittests/testNotifications.cpp b/gentoobrowse-api/unittests/testNotifications.cpp index 5596e62..21a76a5 100644 --- a/gentoobrowse-api/unittests/testNotifications.cpp +++ b/gentoobrowse-api/unittests/testNotifications.cpp @@ -5,7 +5,7 @@  #include <definedDirs.h>  #include <fstream> -BOOST_GLOBAL_FIXTURE( Service ); +BOOST_GLOBAL_FIXTURE( Mail );  BOOST_FIXTURE_TEST_SUITE(tp, TestClient); | 
