Skip to content

Commit

Permalink
Improve test
Browse files Browse the repository at this point in the history
DarthGandalf committed Jan 13, 2024
1 parent 99e6869 commit da39192
Showing 2 changed files with 14 additions and 4 deletions.
7 changes: 4 additions & 3 deletions src/Modules.cpp
Original file line number Diff line number Diff line change
@@ -1079,9 +1079,10 @@ void CModule::OnServerCapResult(const CString& sCap, bool bSuccess) {
if (GetNetwork()->GetIRCSock()->IsAuthed()) {
GetNetwork()->NotifyClientsAboutServerDependentCap(
sCap, bSuccess, [&](CClient* pClient, bool bState) {});
if (!bSuccess)
for (CClient* pClient : GetNetwork()->GetClients()) {
it->second->OnClientChangedSupport(pClient, false);
if (!bSuccess) {
for (CClient* pClient : GetNetwork()->GetClients()) {
it->second->OnClientChangedSupport(pClient, false);
}
}
}
}
11 changes: 10 additions & 1 deletion test/integration/tests/core.cpp
Original file line number Diff line number Diff line change
@@ -567,16 +567,18 @@ TEST_F(ZNCTest, ServerDependentCapInModule) {
client.Write("CAP LS 302");
client.Write("PASS :hunter2");
client.Write("NICK nick");
client.Write("USER user x x :x");
client.Write("USER user/test x x :x");
client.Write("CAP END");
client.ReadUntil("Welcome");

ircd.Write("001 nick Welcome");
ircd.Write("CAP nick NEW testcap=value");
ircd.ReadUntil("CAP REQ :testcap");
ircd.Write("CAP nick ACK :testcap");
client.ReadUntil(":Server changed support: true");
client.ReadUntil("CAP nick NEW :testcap=value");
client.Write("CAP REQ testcap");
client.ReadUntil(":Client changed support: true");
client.ReadUntil("CAP nick ACK :testcap");

client.Write("CAP LS");
@@ -585,13 +587,19 @@ TEST_F(ZNCTest, ServerDependentCapInModule) {
ircd.Write("CAP nick DEL testcap");
client.ReadUntil(":Server changed support: false");
client.ReadUntil("CAP nick DEL :testcap");
client.ReadUntil(":Client changed support: false");

ircd.Close();
// TODO combine multiple DELs to single line
client.ReadUntil("CAP nick DEL :testcap");
client.ReadUntil(":Client changed support: false");

ircd = ConnectIRCd();
ircd.ReadUntil("CAP LS 302");
ircd.Write("CAP nick LS :testcap=new");
ircd.ReadUntil("CAP REQ :testcap");
ircd.Write("CAP nick ACK :testcap");
client.ReadUntil(":Server changed support: true");
ircd.ReadUntil("CAP END");
// NEW waits until 001
ASSERT_THAT(ircd.ReadRemainder().toStdString(), Not(HasSubstr("testcap")));
@@ -606,6 +614,7 @@ TEST_F(ZNCTest, ServerDependentCapInModule) {

client.Write("znc jumpnetwork net2");
client.ReadUntil("CAP nick DEL :testcap");
client.ReadUntil(":Client changed support: false");

client.Write("znc jumpnetwork test");
client.ReadUntil("CAP nick NEW :testcap=another");

0 comments on commit da39192

Please sign in to comment.