Make tests more platform agnostic (#4650)
Use QTemporaryDir to create the test directory Add option to use httpbin over local docker Increase delay for opening a connection Co-authored-by: Rasmus Karlsson <rasmus.karlsson@pajlada.com>
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
#include <QFile>
|
||||
#include <QModelIndex>
|
||||
#include <QString>
|
||||
#include <QTemporaryDir>
|
||||
|
||||
namespace {
|
||||
|
||||
@@ -122,9 +123,9 @@ protected:
|
||||
void SetUp() override
|
||||
{
|
||||
// Write default settings to the mock settings json file
|
||||
ASSERT_TRUE(QDir().mkpath("/tmp/c2-tests"));
|
||||
this->settingsDir_ = std::make_unique<QTemporaryDir>();
|
||||
|
||||
QFile settingsFile("/tmp/c2-tests/settings.json");
|
||||
QFile settingsFile(this->settingsDir_->filePath("settings.json"));
|
||||
ASSERT_TRUE(settingsFile.open(QIODevice::WriteOnly | QIODevice::Text));
|
||||
ASSERT_GT(settingsFile.write(DEFAULT_SETTINGS.toUtf8()), 0);
|
||||
ASSERT_TRUE(settingsFile.flush());
|
||||
@@ -137,7 +138,7 @@ protected:
|
||||
EXPECT_CALL(*this->mockHelix, update).Times(Exactly(1));
|
||||
|
||||
this->mockApplication = std::make_unique<MockApplication>();
|
||||
this->settings = std::make_unique<Settings>("/tmp/c2-tests");
|
||||
this->settings = std::make_unique<Settings>(this->settingsDir_->path());
|
||||
this->paths = std::make_unique<Paths>();
|
||||
|
||||
this->mockApplication->accounts.initialize(*this->settings,
|
||||
@@ -153,15 +154,18 @@ protected:
|
||||
|
||||
void TearDown() override
|
||||
{
|
||||
ASSERT_TRUE(QDir("/tmp/c2-tests").removeRecursively());
|
||||
this->mockApplication.reset();
|
||||
this->settings.reset();
|
||||
this->paths.reset();
|
||||
this->mockHelix.reset();
|
||||
this->completionModel.reset();
|
||||
this->channelPtr.reset();
|
||||
|
||||
this->settingsDir_.reset();
|
||||
}
|
||||
|
||||
std::unique_ptr<QTemporaryDir> settingsDir_;
|
||||
|
||||
std::unique_ptr<MockApplication> mockApplication;
|
||||
std::unique_ptr<Settings> settings;
|
||||
std::unique_ptr<Paths> paths;
|
||||
@@ -222,8 +226,14 @@ protected:
|
||||
|
||||
TEST_F(InputCompletionTest, EmoteNameFiltering)
|
||||
{
|
||||
// The completion doesn't guarantee an ordering for a specific category of emotes.
|
||||
// This tests a specific implementation of the underlying std::unordered_map,
|
||||
// so depending on the standard library used when compiling, this might yield
|
||||
// different results.
|
||||
|
||||
auto completion = queryEmoteCompletion(":feels");
|
||||
ASSERT_EQ(completion.size(), 3);
|
||||
// all these matches are BTTV global emotes
|
||||
ASSERT_EQ(completion[0].displayName, "FeelsBirthdayMan");
|
||||
ASSERT_EQ(completion[1].displayName, "FeelsBadMan");
|
||||
ASSERT_EQ(completion[2].displayName, "FeelsGoodMan");
|
||||
@@ -231,6 +241,7 @@ TEST_F(InputCompletionTest, EmoteNameFiltering)
|
||||
completion = queryEmoteCompletion(":)");
|
||||
ASSERT_EQ(completion.size(), 3);
|
||||
ASSERT_EQ(completion[0].displayName, ":)"); // Exact match with : prefix
|
||||
// all these matches are Twitch global emotes
|
||||
ASSERT_EQ(completion[1].displayName, ":-)");
|
||||
ASSERT_EQ(completion[2].displayName, "B-)");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user