]> git.cworth.org Git - lmno-server/commitdiff
Add simple testing for the entire API
authorCarl Worth <cworth@cworth.org>
Sun, 3 May 2020 02:24:34 +0000 (19:24 -0700)
committerCarl Worth <cworth@cworth.org>
Sun, 3 May 2020 02:24:34 +0000 (19:24 -0700)
This is more "exercising" than testing, (it doesn't currently verify
the results), but I've verified the server isn't hitting any syntax
errors (with fairly decent code coverage I think) and I've manually
inspected the results to ensure they look correct.

test [new file with mode: 0755]

diff --git a/test b/test
new file mode 100755 (executable)
index 0000000..a75f515
--- /dev/null
+++ b/test
@@ -0,0 +1,74 @@
+#!/bin/sh
+set -e
+
+ENDPOINT=http://localhost:3000
+
+register() {
+    curl -X POST -H "Content-Type: application/json" -d "{\"name\": \"$1\", \"character\": \"$2\"}" $ENDPOINT/register
+}
+
+capture() {
+    curl -X POST $ENDPOINT/capture/$1/$2
+}
+
+echo "Registering several players"
+register Carl "Bugs Bunny"
+register Richard "Bob Hope"
+register Kevin "Elvis Presley"
+register Stacy Phineas
+register David Red Power Ranger
+register Nancy "Audrey Hepburn"
+register Bogus "Bogus Player"
+
+echo "Listing registered players (with bogus)"
+curl $ENDPOINT/players
+echo ""
+
+echo "Listing characters (with bogus)"
+curl $ENDPOINT/characters
+echo ""
+
+echo "Removing bogus player"
+curl -X POST $ENDPOINT/deregister/7
+echo ""
+
+echo "Listing registered players (without bogus)"
+curl $ENDPOINT/players
+echo ""
+
+echo "Listing characters (without bogus)"
+curl $ENDPOINT/characters
+echo ""
+
+echo "Performing some captures"
+capture 1 2
+capture 3 5
+capture 4 6
+capture 3 4
+
+echo "Listing captured empires"
+curl $ENDPOINT/empires
+echo ""
+
+echo "Liberating player with index 2"
+curl -X POST $ENDPOINT/liberate/2
+echo ""
+
+echo "Listing captured empires"
+curl $ENDPOINT/empires
+echo ""
+
+echo "Clearing all captures"
+curl -X POST $ENDPOINT/restart
+
+echo "Listing cleared empires"
+curl $ENDPOINT/empires
+echo ""
+
+echo "Eliminating all players"
+curl -X POST $ENDPOINT/reset
+
+echo "Listing empty players array"
+curl $ENDPOINT/players
+echo ""
+