From fe91adde0a2b2f8f1b3e13dfa9ac715acd071339 Mon Sep 17 00:00:00 2001 From: "Tristan B. Velloza Kildaire" Date: Thu, 9 Mar 2023 08:37:38 +0200 Subject: [PATCH 1/3] Client - Fixed bug in `channelMessage(string, string[])` in the case where multiple channels were specified then the message would fail to send to the channels after the first one specified Unit tests - Disabled using `command(string, string, string)` to join a channel, rather use `joinChannel(string)` - Added tests for singular `channelMessage(string, string[])` and multiple `channelMessage(string, string[])` --- source/birchwood/client.d | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/source/birchwood/client.d b/source/birchwood/client.d index 38da76e..bcf4df4 100644 --- a/source/birchwood/client.d +++ b/source/birchwood/client.d @@ -507,6 +507,9 @@ public class Client : Thread /* Ensure valid characters in first channel */ if(isValidText(channelLine)) { + /* Append on a trailing `,` */ + channelLine ~= ","; + for(ulong i = 1; i < channels.length; i++) { string currentChannel = channels[i]; @@ -1177,7 +1180,10 @@ public class Client : Thread client.command(new Message("", "USER", "doggie doggie irc.frdeenode.net :Tristan B. Kildaire")); Thread.sleep(dur!("seconds")(4)); - client.command(new Message("", "JOIN", "#birchwood")); + // client.command(new Message("", "JOIN", "#birchwood")); + client.joinChannel("#birchwood"); + // TODO: Add a joinChannels(string[]) + client.joinChannel("#birchwood2"); Thread.sleep(dur!("seconds")(2)); client.command(new Message("", "NAMES", "")); @@ -1188,6 +1194,17 @@ public class Client : Thread Thread.sleep(dur!("seconds")(2)); client.command(new Message("", "PRIVMSG", "deavmi naai")); + + /** + * Test sending a message to a channel + */ + client.channelMessage("This is a test message sent to a channel", ["#birchwood"]); + + /** + * Test sending a message to multiple channels + */ + client.channelMessage("This is a message sent to multiple channels one-shot", ["#birchwood", "#birchwood2"]); + /* TODO: Add a check here to make sure the above worked I guess? */ /* TODO: Make this end */ // while(true) From 5155912bddda62de55078f0321fc9fdeb10acad0 Mon Sep 17 00:00:00 2001 From: "Tristan B. Velloza Kildaire" Date: Thu, 9 Mar 2023 08:40:42 +0200 Subject: [PATCH 2/3] Unit tests - Added a unit test for the (single) `channelMessage(string, string)` --- source/birchwood/client.d | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/source/birchwood/client.d b/source/birchwood/client.d index bcf4df4..26384e7 100644 --- a/source/birchwood/client.d +++ b/source/birchwood/client.d @@ -509,7 +509,7 @@ public class Client : Thread { /* Append on a trailing `,` */ channelLine ~= ","; - + for(ulong i = 1; i < channels.length; i++) { string currentChannel = channels[i]; @@ -1196,12 +1196,17 @@ public class Client : Thread /** - * Test sending a message to a channel + * Test sending a message to a single channel (singular) */ - client.channelMessage("This is a test message sent to a channel", ["#birchwood"]); + client.channelMessage("This is a test message sent to a channel 1", ["#birchwood"]); /** - * Test sending a message to multiple channels + * Test sending a message to a single channel (multi) + */ + client.channelMessage("This is a test message sent to a channel 2", "#birchwood"); + + /** + * Test sending a message to multiple channels (multi) */ client.channelMessage("This is a message sent to multiple channels one-shot", ["#birchwood", "#birchwood2"]); From 35ce86478db3a6321a28c5534f3104ec815cf478 Mon Sep 17 00:00:00 2001 From: "Tristan B. Velloza Kildaire" Date: Thu, 9 Mar 2023 08:44:09 +0200 Subject: [PATCH 3/3] Unit tests - Test `directMessage(string, string)` (so singular) to send to myself - Adding such a test will test the direct message receive handler which helps us a lot in increasing code coverage --- source/birchwood/client.d | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/source/birchwood/client.d b/source/birchwood/client.d index 26384e7..e8f08c4 100644 --- a/source/birchwood/client.d +++ b/source/birchwood/client.d @@ -1217,6 +1217,11 @@ public class Client : Thread // } + /** + * Test sending a message to myself (singular) + */ + client.directMessage("Message to myself", "birchwood"); + // TODO: Don't forget to re-enable this when done testing! Thread.sleep(dur!("seconds")(15)); client.quit();