X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=test;h=017f38eda85a0d4930b25f573746a80f850e9a96;hb=bb50292173f978457b4b64d6495db96cd581a4d6;hp=30dbe7f2781cd292de35b2b4112862f11af992c3;hpb=d6817ef860a230cbbb694e729a400ed37ed43d68;p=empires-server diff --git a/test b/test index 30dbe7f..017f38e 100755 --- a/test +++ b/test @@ -140,6 +140,24 @@ tictactoe_game_id=$(new_game tictactoe) test "$tictactoe_game_id" != "" TEST_END $tictactoe_game_id +TEST_SUBSECTION "Test redirects" + +TEST "Redirect of /GAMEID at top level" +redirect=$(curl_get $empires_game_id) +test "$redirect" = "Moved Permanently. Redirecting to /empires/$empires_game_id/" +TEST_END + +TEST "Redirect of lowercase /gameid at top level" +empires_game_id_lower=$(tr '[:upper:]' '[:lower:]' <<< $empires_game_id) +redirect=$(curl_get $empires_game_id_lower) +test "$redirect" = "Moved Permanently. Redirecting to /$empires_game_id/" +TEST_END + +TEST "Redirect of lowercase /empires/gameid" +redirect=$(curl_get empires/$empires_game_id_lower) +test "$redirect" = "Moved Permanently. Redirecting to /empires/$empires_game_id/" +TEST_END + TEST_SECTION "Empires game" empires_game_path=empires/$empires_game_id @@ -268,5 +286,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