-
Notifications
You must be signed in to change notification settings - Fork 2
/
test-server.sh
executable file
·78 lines (63 loc) · 1.76 KB
/
test-server.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/usr/bin/env bash
set -e
coach_json () {
echo """{
\"name\": \"$1\",
\"bio\": \"$2\",
\"available\": true,
\"birth_year\": $3,
\"gender\": \"$4\",
\"languages\": {$5},
\"need\": [1, 2, 3],
\"rights\": [2],
\"housing\": [3]
}"""
}
echo "List empty DB"
echo "-------------"
curl localhost:8000/api/v1/coaches
echo
echo
echo "Create coaches"
echo "--------------"
curl -H "Content-Type: application/json" -d "$(coach_json Bob 'Hey, Bob here.' 1992 male '"english":1,"spanish":4')" localhost:8000/api/v1/coaches
echo
curl -H "Content-Type: application/json" -d "$(coach_json Albert '' 1990 other)" localhost:8000/api/v1/coaches
echo
curl -H "Content-Type: application/json" -d "$(coach_json Kelly '' 1988 female)" localhost:8000/api/v1/coaches
echo
curl -H "Content-Type: application/json" -d "$(coach_json Susan '' 1993 female)" localhost:8000/api/v1/coaches
echo
curl -H "Content-Type: application/json" -d "$(coach_json Mike '' 1970 male '"spanish":1,"french":2')" localhost:8000/api/v1/coaches
echo
echo
echo "List DB"
echo "-------"
curl localhost:8000/api/v1/coaches
echo
echo
echo "Get coach by ID"
echo "---------------"
curl localhost:8000/api/v1/coaches/1
echo
echo
echo "Modify coach"
echo "------------"
curl -H "Content-Type: application/json" -d '{"name":"Kelly S."}' localhost:8000/api/v1/coaches/2
echo
echo
echo "Remove coach"
echo "------------"
curl --request DELETE localhost:8000/api/v1/coaches/3
echo
echo
echo "List DB"
echo "-------"
curl localhost:8000/api/v1/coaches
echo
echo
echo "Coach matches for birth_year=34, languages=english:2, gender=male"
echo "-----------------------------------------------------------------"
curl "localhost:8000/api/v1/coach-matches?birth_year=1990&languages=english:2&gender=male"
echo
echo