Got rid of TaskbarlessServerTest

Now ServerTest provides an optional taskbarless kiwix::Server.
This commit is contained in:
Veloman Yunkan 2022-06-04 19:50:51 +04:00 committed by Matthieu Gautier
parent 600acb76c7
commit 1c98b00128
2 changed files with 15 additions and 12 deletions

View File

@ -507,7 +507,7 @@ const std::vector<std::string> LARGE_SEARCH_RESULTS = {
// //
// In order to be able to share the same expected output data // In order to be able to share the same expected output data
// LARGE_SEARCH_RESULTS between multiple build platforms and test-points // LARGE_SEARCH_RESULTS between multiple build platforms and test-points
// of the TaskbarlessServerTest.searchResults test-case // of the ServerTest.searchResults test-case
// //
// 1. Snippets are excluded from the plain-text comparison of actual and // 1. Snippets are excluded from the plain-text comparison of actual and
// expected HTML strings. This is done with the help of the // expected HTML strings. This is done with the help of the
@ -583,7 +583,7 @@ bool isSubSnippet(std::string subSnippet, const std::string& superSnippet)
#define RAYCHARLESZIMID "6f1d19d0-633f-087b-fb55-7ac324ff9baf" #define RAYCHARLESZIMID "6f1d19d0-633f-087b-fb55-7ac324ff9baf"
#define EXAMPLEZIMID "5dc0b3af-5df2-0925-f0ca-d2bf75e78af6" #define EXAMPLEZIMID "5dc0b3af-5df2-0925-f0ca-d2bf75e78af6"
TEST_F(TaskbarlessServerTest, searchResults) TEST_F(ServerTest, searchResults)
{ {
struct TestData struct TestData
{ {
@ -1301,7 +1301,7 @@ TEST_F(TaskbarlessServerTest, searchResults)
}; };
for ( const auto& t : testData ) { for ( const auto& t : testData ) {
const auto r = zfs1_->GET(t.url().c_str()); const auto r = taskbarlessZimFileServer().GET(t.url().c_str());
EXPECT_EQ(r->status, 200); EXPECT_EQ(r->status, 200);
t.check(r->body); t.check(r->body);
} }

View File

@ -134,6 +134,9 @@ ZimFileServer::~ZimFileServer()
class ServerTest : public ::testing::Test class ServerTest : public ::testing::Test
{ {
private:
std::unique_ptr<ZimFileServer> taskbarlessZfs_;
protected: protected:
std::unique_ptr<ZimFileServer> zfs1_; std::unique_ptr<ZimFileServer> zfs1_;
@ -149,16 +152,16 @@ protected:
zfs1_.reset(new ZimFileServer(SERVER_PORT, /*withTaskbar=*/true, ZIMFILES)); zfs1_.reset(new ZimFileServer(SERVER_PORT, /*withTaskbar=*/true, ZIMFILES));
} }
ZimFileServer& taskbarlessZimFileServer()
{
if ( ! taskbarlessZfs_ ) {
taskbarlessZfs_.reset(new ZimFileServer(SERVER_PORT+1, /*withTaskbar=*/false, ZIMFILES));
}
return *taskbarlessZfs_;
}
void TearDown() override { void TearDown() override {
zfs1_.reset(); zfs1_.reset();
taskbarlessZfs_.reset();
} }
}; };
class TaskbarlessServerTest : public ServerTest
{
protected:
void SetUp() override {
zfs1_.reset(new ZimFileServer(SERVER_PORT, /*withTaskbar=*/false, ZIMFILES));
}
};