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:
pajlada
2023-04-01 13:23:18 +02:00
committed by GitHub
parent 7a081fdcfb
commit 0177ab4829
4 changed files with 16 additions and 9 deletions
+9 -9
View File
@@ -550,14 +550,14 @@ class HighlightControllerTest : public ::testing::Test
protected:
void SetUp() override
{
{
// Write default settings to the mock settings json file
QDir().mkpath("/tmp/c2-tests");
QFile settingsFile("/tmp/c2-tests/settings.json");
assert(settingsFile.open(QIODevice::WriteOnly | QIODevice::Text));
QTextStream out(&settingsFile);
out << DEFAULT_SETTINGS;
}
// Write default settings to the mock settings json file
ASSERT_TRUE(QDir().mkpath("/tmp/c2-tests"));
QFile settingsFile("/tmp/c2-tests/settings.json");
ASSERT_TRUE(settingsFile.open(QIODevice::WriteOnly | QIODevice::Text));
ASSERT_GT(settingsFile.write(DEFAULT_SETTINGS.toUtf8()), 0);
ASSERT_TRUE(settingsFile.flush());
settingsFile.close();
this->mockHelix = new MockHelix;
@@ -579,7 +579,7 @@ protected:
void TearDown() override
{
QDir().rmdir("/tmp/c2-tests");
ASSERT_TRUE(QDir("/tmp/c2-tests").removeRecursively());
this->mockApplication.reset();
this->settings.reset();
this->paths.reset();