summaryrefslogtreecommitdiff
path: root/site/test.cpp
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2021-01-09 13:58:38 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2021-01-09 13:58:38 +0000
commit62d506c24aaf543f84c82e2850a05b1387e4990d (patch)
tree3d356dcef6cb64baf648119c6b61aa9afd4e450b /site/test.cpp
parentExclude api.h from tidy checks (diff)
downloadmirrorsearch-62d506c24aaf543f84c82e2850a05b1387e4990d.tar.bz2
mirrorsearch-62d506c24aaf543f84c82e2850a05b1387e4990d.tar.xz
mirrorsearch-62d506c24aaf543f84c82e2850a05b1387e4990d.zip
Clang format
Diffstat (limited to 'site/test.cpp')
-rw-r--r--site/test.cpp99
1 files changed, 48 insertions, 51 deletions
diff --git a/site/test.cpp b/site/test.cpp
index 4cd9763..bcff64b 100644
--- a/site/test.cpp
+++ b/site/test.cpp
@@ -1,68 +1,66 @@
#define BOOST_TEST_MODULE mirrorsearchsite
#include <boost/test/unit_test.hpp>
-#include <testRequest.h>
-#include <core.h>
#include <api.h>
+#include <core.h>
+#include <testRequest.h>
-#include <Ice/ObjectAdapter.h>
#include <Ice/Initialize.h>
+#include <Ice/ObjectAdapter.h>
using namespace IceSpider;
using namespace MirrorSearch;
class TestSerice : public Search {
- public:
- virtual SearchServices getServices(const ::Ice::Current& = ::Ice::Current()) override
- {
- return {};
+public:
+ virtual SearchServices
+ getServices(const ::Ice::Current & = ::Ice::Current()) override
+ {
+ return {};
+ }
+ virtual SearchHits
+ getMatches(const ::std::string fn, const ::Ice::Current & = ::Ice::Current()) override
+ {
+ BOOST_TEST_INFO(fn);
+ if (fn == "good.txt") {
+ return {std::make_shared<SearchHit>(1, 1, "file:///some/file/path"),
+ std::make_shared<SearchHit>(1, 1, "file:///some/other/path")};
}
- virtual SearchHits getMatches(const ::std::string fn, const ::Ice::Current& = ::Ice::Current()) override
- {
- BOOST_TEST_INFO(fn);
- if (fn == "good.txt") {
- return {
- std::make_shared<SearchHit>(1, 1, "file:///some/file/path"),
- std::make_shared<SearchHit>(1, 1, "file:///some/other/path")
- };
- }
- return {};
- }
- virtual ::Ice::optional<::std::string> feelingLucky(const ::std::string fn, const ::Ice::Current & c = ::Ice::Current()) override
- {
- auto ms = getMatches(fn, c);
- if (ms.empty()) {
- return IceUtil::None;
-
- }
- return ms.front()->url;
+ return {};
+ }
+ virtual ::Ice::optional<::std::string>
+ feelingLucky(const ::std::string fn, const ::Ice::Current & c = ::Ice::Current()) override
+ {
+ auto ms = getMatches(fn, c);
+ if (ms.empty()) {
+ return IceUtil::None;
}
+ return ms.front()->url;
+ }
};
class TestApp : public CoreWithDefaultRouter {
- public:
- TestApp() :
- CoreWithDefaultRouter({
- "--MirrorSearch.Search=Search"
- }),
- adp(communicator->createObjectAdapterWithEndpoints("test", "default"))
- {
- adp->activate();
- adp->add(std::make_shared<TestSerice>(), Ice::stringToIdentity("Search"));
- }
-
- ~TestApp()
- {
- adp->deactivate();
- adp->destroy();
- }
-
- Ice::ObjectAdapterPtr adp;
+public:
+ TestApp() :
+ CoreWithDefaultRouter({"--MirrorSearch.Search=Search"}),
+ adp(communicator->createObjectAdapterWithEndpoints("test", "default"))
+ {
+ adp->activate();
+ adp->add(std::make_shared<TestSerice>(), Ice::stringToIdentity("Search"));
+ }
+
+ ~TestApp()
+ {
+ adp->deactivate();
+ adp->destroy();
+ }
+
+ Ice::ObjectAdapterPtr adp;
};
BOOST_FIXTURE_TEST_SUITE(ta, TestApp);
-BOOST_AUTO_TEST_CASE( testCallIndexNoFile )
+BOOST_AUTO_TEST_CASE(testCallIndexNoFile)
{
TestRequest requestGetIndex(this, HttpMethod::GET, "/list");
process(&requestGetIndex);
@@ -70,7 +68,7 @@ BOOST_AUTO_TEST_CASE( testCallIndexNoFile )
BOOST_CHECK_EQUAL(h["Status"], "404 Not found");
}
-BOOST_AUTO_TEST_CASE( testCallServiceList )
+BOOST_AUTO_TEST_CASE(testCallServiceList)
{
TestRequest requestGetIndex(this, HttpMethod::GET, "/services");
process(&requestGetIndex);
@@ -79,7 +77,7 @@ BOOST_AUTO_TEST_CASE( testCallServiceList )
BOOST_CHECK_EQUAL(h["Content-Type"], "application/json");
}
-BOOST_AUTO_TEST_CASE( testCallIndex )
+BOOST_AUTO_TEST_CASE(testCallIndex)
{
TestRequest requestGetIndex(this, HttpMethod::GET, "/list/somefile.txt");
process(&requestGetIndex);
@@ -88,7 +86,7 @@ BOOST_AUTO_TEST_CASE( testCallIndex )
BOOST_CHECK_EQUAL(h["Content-Type"], "application/json");
}
-BOOST_AUTO_TEST_CASE( testCallDownloadNotFile )
+BOOST_AUTO_TEST_CASE(testCallDownloadNotFile)
{
TestRequest requestGetIndex(this, HttpMethod::GET, "/download");
process(&requestGetIndex);
@@ -96,7 +94,7 @@ BOOST_AUTO_TEST_CASE( testCallDownloadNotFile )
BOOST_CHECK_EQUAL(h["Status"], "404 Not found");
}
-BOOST_AUTO_TEST_CASE( testCallDownloadBad )
+BOOST_AUTO_TEST_CASE(testCallDownloadBad)
{
TestRequest requestGetIndex(this, HttpMethod::GET, "/download/bad.txt");
process(&requestGetIndex);
@@ -104,7 +102,7 @@ BOOST_AUTO_TEST_CASE( testCallDownloadBad )
BOOST_CHECK_EQUAL(h["Status"], "404 No mirror found");
}
-BOOST_AUTO_TEST_CASE( testCallDownloadGood )
+BOOST_AUTO_TEST_CASE(testCallDownloadGood)
{
TestRequest requestGetIndex(this, HttpMethod::GET, "/download/good.txt");
process(&requestGetIndex);
@@ -114,4 +112,3 @@ BOOST_AUTO_TEST_CASE( testCallDownloadGood )
}
BOOST_AUTO_TEST_SUITE_END();
-