From f891299236dabc38c006f22f73786002c57b9164 Mon Sep 17 00:00:00 2001 From: Sebastian Crane Date: Wed, 9 Feb 2022 21:46:07 +0000 Subject: [PATCH] Add response function with tests to list games Signed-off-by: Sebastian Crane --- src/bot.clj | 6 ++++++ test/bot_test.clj | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/src/bot.clj b/src/bot.clj index 08f23c0..8449dee 100644 --- a/src/bot.clj +++ b/src/bot.clj @@ -41,6 +41,12 @@ game "!")) +(defn list-games-string [state _ _] + (str "Games with a list of players: " + (str/join + ", " + (sort (map name (game/get-games state)))))) + (defn split-message [message] (let [message-parts (str/split message #"\s") command (if-let [x (first message-parts)] (str/lower-case x) "") diff --git a/test/bot_test.clj b/test/bot_test.clj index 1260a36..60bb12b 100644 --- a/test/bot_test.clj +++ b/test/bot_test.clj @@ -25,6 +25,10 @@ (is (= "Removed abc from the list of players for hypothetical-shooter!" (remove-player-string nil "hypothetical-shooter" "abc")))) +(deftest list-games-string-test + (is (= "Games with a list of players: hypothetical-shooter, imaginary-rpg, quasi-rts" + (list-games-string test-state nil nil)))) + (deftest split-message-test (is (= {:command "!match" :game "Quasi-Rts" :game-keyword :quasi-rts} (split-message "!match Quasi-Rts "))))