fix: close logging-channels when closing channels (#5592)

Co-authored-by: kornes <28986062+kornes@users.noreply.github.com>
Co-authored-by: Rasmus Karlsson <rasmus.karlsson@pajlada.com>
This commit is contained in:
nerix
2024-09-14 12:17:31 +02:00
committed by GitHub
parent 2afa227139
commit 694cc2dbff
13 changed files with 106 additions and 15 deletions
+35 -6
View File
@@ -1,6 +1,8 @@
#include "common/ChannelChatters.hpp"
#include "mocks/BaseApplication.hpp"
#include "mocks/Channel.hpp"
#include "mocks/Logging.hpp"
#include "Test.hpp"
#include <QColor>
@@ -9,9 +11,28 @@
using namespace chatterino;
using chatterino::mock::MockChannel;
// Ensure inserting the same user does not increase the size of the stored colors
TEST(ChatterChatters, insertSameUser)
namespace {
class MockApplication : public mock::BaseApplication
{
public:
MockApplication() = default;
ILogging *getChatLogger() override
{
return &this->logging;
}
mock::EmptyLogging logging;
};
} // namespace
// Ensure inserting the same user does not increase the size of the stored colors
TEST(ChannelChatters, insertSameUser)
{
MockApplication app;
MockChannel channel("test");
ChannelChatters chatters(channel);
@@ -24,8 +45,10 @@ TEST(ChatterChatters, insertSameUser)
}
// Ensure we can update a chatters color
TEST(ChatterChatters, insertSameUserUpdatesColor)
TEST(ChannelChatters, insertSameUserUpdatesColor)
{
MockApplication app;
MockChannel channel("test");
ChannelChatters chatters(channel);
@@ -37,8 +60,10 @@ TEST(ChatterChatters, insertSameUserUpdatesColor)
}
// Ensure getting a non-existant users color returns an invalid QColor
TEST(ChatterChatters, getNonExistantUser)
TEST(ChannelChatters, getNonExistantUser)
{
MockApplication app;
MockChannel channel("test");
ChannelChatters chatters(channel);
@@ -47,8 +72,10 @@ TEST(ChatterChatters, getNonExistantUser)
}
// Ensure getting a user doesn't create an entry
TEST(ChatterChatters, getDoesNotCreate)
TEST(ChannelChatters, getDoesNotCreate)
{
MockApplication app;
MockChannel channel("test");
ChannelChatters chatters(channel);
@@ -59,8 +86,10 @@ TEST(ChatterChatters, getDoesNotCreate)
}
// Ensure the least recently used entry is purged when we reach MAX_SIZE
TEST(ChatterChatters, insertMaxSize)
TEST(ChannelChatters, insertMaxSize)
{
MockApplication app;
MockChannel channel("test");
ChannelChatters chatters(channel);