Add test for OnInvite()+OnInviteMessage()

This commit is contained in:
Alexey Sokolov
2025-04-18 22:36:53 +01:00
parent 5befe2f7f8
commit 5d6aceac79

View File

@@ -1048,15 +1048,38 @@ TEST_F(ZNCTest, InviteNotify) {
client.ReadUntil("ACK");
auto client2 = LoginClient();
InstallModule("testmod.cpp", R"(
#include <znc/Modules.h>
class TestModule : public CModule {
public:
MODCONSTRUCTOR(TestModule) {}
EModRet OnInviteMessage(CInviteMessage& Msg) override {
PutIRC("__MSG__ " + Msg.ToString());
return CONTINUE;
}
EModRet OnInvite(const CNick& Nick, const CString& sChan) override {
PutIRC("__INV__ " + Nick.GetNickMask() + " " + sChan);
return CONTINUE;
}
};
GLOBALMODULEDEFS(TestModule, "Test")
)");
client.Write("znc loadmod testmod");
client.ReadUntil("Loaded module testmod");
ircd.Write("001 nick Welcome");
ircd.Write(":source!id@ho INVITE nick #chan");
client.ReadUntil(":source!id@ho INVITE nick #chan");
client2.ReadUntil(":source!id@ho INVITE nick #chan");
ircd.ReadUntil("__MSG__ :source!id@ho INVITE nick #chan");
ircd.ReadUntil("__INV__ source!id@ho #chan");
ircd.Write(":source!id@ho INVITE someone #chan");
client.ReadUntil(":source!id@ho INVITE someone #chan");
ASSERT_THAT(client2.ReadRemainder().toStdString(), Not(HasSubstr("someone")));
ircd.ReadUntil("__MSG__ :source!id@ho INVITE someone #chan");
ASSERT_THAT(ircd.ReadRemainder().toStdString(), Not(HasSubstr("__INV__")));
}
} // namespace