-
Notifications
You must be signed in to change notification settings - Fork 0
/
prod_test.sh
executable file
·47 lines (36 loc) · 1.01 KB
/
prod_test.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/bin/bash
root_url="https://rockpaperscissors.duckdns.org/"
function get_endpoint() {
description=$1
url=$2
expected_status_code=$3
args=(
--head
--silent
--output /dev/null
--write-out %{http_code}
--connect-timeout 5
--max-time 10
--retry 5
--retry-delay 0
--retry-max-time 40
"$url")
status=$(curl "${args[@]}")
message="Test: ${description} ${expected_status_code} ->"
if [[ "${status}" == "${expected_status_code}" ]]; then
echo "${message} succeeded."
else
echo "${message} failed. Got ${status} instead."
exit 1
fi
}
# test index page
get_endpoint "GET '/' ..." "${root_url}" 200
# test projects page
get_endpoint "GET '/play' ..." "${root_url}play" 200
# test contact page
get_endpoint "GET '/auth/login/' ..." "${root_url}auth/login/" 200
# test resume page
get_endpoint "GET '/auth/register/' ..." "${root_url}auth/register/" 200
# test 404 page
get_endpoint "GET '/oops/' ..." "${root_url}oops/" 404