From da3919245bb8ee983df2b74132fd06598c53ed41 Mon Sep 17 00:00:00 2001 From: Alexey Sokolov Date: Sat, 13 Jan 2024 22:07:40 +0000 Subject: [PATCH] Improve test --- src/Modules.cpp | 7 ++++--- test/integration/tests/core.cpp | 11 ++++++++++- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/Modules.cpp b/src/Modules.cpp index 25b1e351..f1b568c5 100644 --- a/src/Modules.cpp +++ b/src/Modules.cpp @@ -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); + } } } } diff --git a/test/integration/tests/core.cpp b/test/integration/tests/core.cpp index bde99d43..8e41494d 100644 --- a/test/integration/tests/core.cpp +++ b/test/integration/tests/core.cpp @@ -567,7 +567,7 @@ 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"); @@ -575,8 +575,10 @@ TEST_F(ZNCTest, ServerDependentCapInModule) { 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");