chore: remove Singleton & replace getIApp with getApp (#5514)

This commit is contained in:
pajlada
2024-07-21 15:09:59 +02:00
committed by GitHub
parent 21186df058
commit 5deec1f02f
145 changed files with 802 additions and 856 deletions
+11 -12
View File
@@ -27,6 +27,7 @@ class MockApplication : mock::EmptyApplication
public:
MockApplication()
: settings(this->settingsDir.filePath("settings.json"))
, commands(this->paths_)
{
}
@@ -833,8 +834,6 @@ TEST(Commands, E2E)
::testing::InSequence seq;
MockApplication app;
app.commands.initialize(*getSettings(), getIApp()->getPaths());
QJsonObject pajlada;
pajlada["id"] = "11148817";
pajlada["login"] = "pajlada";
@@ -879,10 +878,10 @@ TEST(Commands, E2E)
auto account = std::make_shared<TwitchAccount>(
testaccount420["login"].toString(), "token", "oauthclient",
testaccount420["id"].toString());
getIApp()->getAccounts()->twitch.accounts.append(account);
getIApp()->getAccounts()->twitch.currentUsername =
getApp()->getAccounts()->twitch.accounts.append(account);
getApp()->getAccounts()->twitch.currentUsername =
testaccount420["login"].toString();
getIApp()->getAccounts()->twitch.load();
getApp()->getAccounts()->twitch.load();
// Simple single-channel ban
EXPECT_CALL(mockHelix, fetchUsers(QStringList{"11148817"},
@@ -901,7 +900,7 @@ TEST(Commands, E2E)
QString(""), _, _))
.Times(1);
getIApp()->getCommands()->execCommand("/ban forsen", channel, false);
getApp()->getCommands()->execCommand("/ban forsen", channel, false);
// Multi-channel ban
EXPECT_CALL(mockHelix, fetchUsers(QStringList{"11148817"},
@@ -937,7 +936,7 @@ TEST(Commands, E2E)
std::optional<int>{}, QString(""), _, _))
.Times(1);
getIApp()->getCommands()->execCommand(
getApp()->getCommands()->execCommand(
"/ban --channel id:11148817 --channel testaccount_420 forsen", channel,
false);
@@ -948,7 +947,7 @@ TEST(Commands, E2E)
QString(""), _, _))
.Times(1);
getIApp()->getCommands()->execCommand("/ban id:22484632", channel, false);
getApp()->getCommands()->execCommand("/ban id:22484632", channel, false);
// ID-based redirected ban
EXPECT_CALL(mockHelix,
@@ -957,7 +956,7 @@ TEST(Commands, E2E)
QString(""), _, _))
.Times(1);
getIApp()->getCommands()->execCommand(
getApp()->getCommands()->execCommand(
"/ban --channel id:117166826 id:22484632", channel, false);
// name-based redirected ban
@@ -976,7 +975,7 @@ TEST(Commands, E2E)
QString(""), _, _))
.Times(1);
getIApp()->getCommands()->execCommand(
getApp()->getCommands()->execCommand(
"/ban --channel testaccount_420 id:22484632", channel, false);
// Multi-channel timeout
@@ -1013,7 +1012,7 @@ TEST(Commands, E2E)
std::optional<int>{600}, QString(""), _, _))
.Times(1);
getIApp()->getCommands()->execCommand(
getApp()->getCommands()->execCommand(
"/timeout --channel id:11148817 --channel testaccount_420 forsen",
channel, false);
@@ -1049,7 +1048,7 @@ TEST(Commands, E2E)
forsen["id"].toString(), _, _))
.Times(1);
getIApp()->getCommands()->execCommand(
getApp()->getCommands()->execCommand(
"/unban --channel id:11148817 --channel testaccount_420 forsen",
channel, false);
}