Ensure tests have default-initialized settings (#4498)
Also rework HighlightController test directory creation/saving to ensure the test directory is written to & cleaned up appropriately
This commit is contained in:
@@ -19,6 +19,7 @@
|
|||||||
- Dev: Ignore unhandled BTTV user-events. (#4438)
|
- Dev: Ignore unhandled BTTV user-events. (#4438)
|
||||||
- Dev: Only log debug messages when NDEBUG is not defined. (#4442)
|
- Dev: Only log debug messages when NDEBUG is not defined. (#4442)
|
||||||
- Dev: Cleaned up theme related code. (#4450)
|
- Dev: Cleaned up theme related code. (#4450)
|
||||||
|
- Dev: Ensure tests have default-initialized settings. (#4498)
|
||||||
|
|
||||||
## 2.4.2
|
## 2.4.2
|
||||||
|
|
||||||
|
|||||||
@@ -140,6 +140,8 @@ Settings::Settings(const QString &settingsDirectory)
|
|||||||
|
|
||||||
Settings &Settings::instance()
|
Settings &Settings::instance()
|
||||||
{
|
{
|
||||||
|
assert(instance_ != nullptr);
|
||||||
|
|
||||||
return *instance_;
|
return *instance_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -550,14 +550,14 @@ class HighlightControllerTest : public ::testing::Test
|
|||||||
protected:
|
protected:
|
||||||
void SetUp() override
|
void SetUp() override
|
||||||
{
|
{
|
||||||
{
|
// Write default settings to the mock settings json file
|
||||||
// Write default settings to the mock settings json file
|
ASSERT_TRUE(QDir().mkpath("/tmp/c2-tests"));
|
||||||
QDir().mkpath("/tmp/c2-tests");
|
|
||||||
QFile settingsFile("/tmp/c2-tests/settings.json");
|
QFile settingsFile("/tmp/c2-tests/settings.json");
|
||||||
assert(settingsFile.open(QIODevice::WriteOnly | QIODevice::Text));
|
ASSERT_TRUE(settingsFile.open(QIODevice::WriteOnly | QIODevice::Text));
|
||||||
QTextStream out(&settingsFile);
|
ASSERT_GT(settingsFile.write(DEFAULT_SETTINGS.toUtf8()), 0);
|
||||||
out << DEFAULT_SETTINGS;
|
ASSERT_TRUE(settingsFile.flush());
|
||||||
}
|
settingsFile.close();
|
||||||
|
|
||||||
this->mockHelix = new MockHelix;
|
this->mockHelix = new MockHelix;
|
||||||
|
|
||||||
@@ -579,7 +579,7 @@ protected:
|
|||||||
|
|
||||||
void TearDown() override
|
void TearDown() override
|
||||||
{
|
{
|
||||||
QDir().rmdir("/tmp/c2-tests");
|
ASSERT_TRUE(QDir("/tmp/c2-tests").removeRecursively());
|
||||||
this->mockApplication.reset();
|
this->mockApplication.reset();
|
||||||
this->settings.reset();
|
this->settings.reset();
|
||||||
this->paths.reset();
|
this->paths.reset();
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
#include "common/Outcome.hpp"
|
#include "common/Outcome.hpp"
|
||||||
#include "common/QLogging.hpp"
|
#include "common/QLogging.hpp"
|
||||||
#include "providers/twitch/api/Helix.hpp"
|
#include "providers/twitch/api/Helix.hpp"
|
||||||
|
#include "singletons/Settings.hpp"
|
||||||
|
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
@@ -27,6 +28,9 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
chatterino::NetworkManager::init();
|
chatterino::NetworkManager::init();
|
||||||
|
|
||||||
|
// Ensure settings are initialized before any tests are run
|
||||||
|
chatterino::Settings settings("/tmp/c2-empty-test");
|
||||||
|
|
||||||
QtConcurrent::run([&app] {
|
QtConcurrent::run([&app] {
|
||||||
auto res = RUN_ALL_TESTS();
|
auto res = RUN_ALL_TESTS();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user