summaryrefslogtreecommitdiff
path: root/doc/codelab/wiki/test.sh
diff options
context:
space:
mode:
Diffstat (limited to 'doc/codelab/wiki/test.sh')
-rwxr-xr-xdoc/codelab/wiki/test.sh35
1 files changed, 19 insertions, 16 deletions
diff --git a/doc/codelab/wiki/test.sh b/doc/codelab/wiki/test.sh
index 5b752fe3c..95ff145b9 100755
--- a/doc/codelab/wiki/test.sh
+++ b/doc/codelab/wiki/test.sh
@@ -1,24 +1,27 @@
-#1/bin/bash
-
-./final.bin &
-wiki_pid=$!
+#!/usr/bin/env bash
+set -e
+wiki_pid=
cleanup() {
kill $wiki_pid
- rm -f test_*.out Test.txt
- exit ${1:-1}
+ rm -f test_*.out Test.txt final-test.bin final-test.go
}
-trap cleanup INT
+trap cleanup 0 INT
-sleep 1
+gomake get.bin
+addr=$(./get.bin -addr)
+sed s/:8080/$addr/ < final.go > final-test.go
+gomake final-test.bin
+./final-test.bin &
+wiki_pid=$!
-curl -s -o test_edit.out http://localhost:8080/edit/Test
-cmp test_edit.out test_edit.good || cleanup 1
-curl -s -o /dev/null -d body=some%20content http://localhost:8080/save/Test
-cmp Test.txt test_Test.txt.good || cleanup 1
-curl -s -o test_view.out http://localhost:8080/view/Test
-cmp test_view.out test_view.good || cleanup 1
+sleep 1
-echo "Passed"
-cleanup 0
+./get.bin http://$addr/edit/Test > test_edit.out
+diff -u test_edit.out test_edit.good
+./get.bin -post=body=some%20content http://$addr/save/Test
+diff -u Test.txt test_Test.txt.good
+./get.bin http://$addr/view/Test > test_view.out
+diff -u test_view.out test_view.good
+echo PASS