]> git.cworth.org Git - lmno-server/commitdiff
test: Add simple testing for tictactoe as well
authorCarl Worth <cworth@cworth.org>
Sun, 31 May 2020 23:12:10 +0000 (16:12 -0700)
committerCarl Worth <cworth@cworth.org>
Sun, 31 May 2020 23:12:10 +0000 (16:12 -0700)
This just verifies we can move to a square, (and can't then move to
the same square again).

To do something more interesting here, I'll have to think about how to
test with multiple clients connecting to the same game and how to
verify the results of the streaming from the /events API.

test

diff --git a/test b/test
index 30dbe7f2781cd292de35b2b4112862f11af992c3..b5be7d8fa20e27142a8acbdb719e950a22b7acf5 100755 (executable)
--- a/test
+++ b/test
@@ -268,5 +268,26 @@ players=$(empires_players_string)
 test "$players" = ""
 TEST_END
 
+TEST_SECTION "Tic Tac Toe game"
+
+tictactoe_game_path=tictactoe/$tictactoe_game_id
+
+tictactoe_move()
+{
+    curl_post $tictactoe_game_path/move "{\"square\": $1}"
+}
+
+TEST_SUBSECTION "Tic Tac Toe /move"
+
+TEST "Move to the center square"
+result=$(tictactoe_move 4)
+test "$result" = "true"
+TEST_END
+
+TEST "Move to center square again is now illegal"
+result=$(tictactoe_move 4)
+test "$result" = "false"
+TEST_END
+
 TEST_REPORT