-
Notifications
You must be signed in to change notification settings - Fork 0
/
smoke_tests.sh
executable file
·54 lines (47 loc) · 1.31 KB
/
smoke_tests.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
#!/bin/bash
BODY=$(curl -s http://localhost:8081/anaplan/dashboards)
FAILED_TESTS=0
LENGTH=$(echo "$BODY" | jq length)
if ! [[ $LENGTH -ge 0 ]]; then
echo "it should return at least one dashboard: FAIL" 1>&2
((FAILED_TESTS++))
else
echo "it should return at least one dashboard: PASS"
fi
ID=$(echo "$BODY" | jq '.[0] | .id')
if ! [[ $ID -ge 0 ]]; then
echo "it should include a numeric id: FAIL" 1>&2
((FAILED_TESTS++))
else
echo "it should include a numeric id: PASS"
fi
CREATED_AT=$(echo "$BODY" | jq '.[0] | .createdAt')
if [[ $CREATED_AT == null ]]; then
echo "it should include a non empty createdAt: FAIL" 1>&2
((FAILED_TESTS++))
else
echo "it should include a non empty createdAt: PASS"
fi
UPDATED_AT=$(echo "$BODY" | jq '.[0] | .updatedAt')
if [[ $UPDATED_AT == null ]]; then
echo "it should include a non empty updatedAt: FAIL" 1>&2
((FAILED_TESTS++))
else
echo "it should include a non empty updatedAt: PASS"
fi
TITLE=$(echo "$BODY" | jq '.[0] | .title')
if [[ $TITLE == null ]]; then
echo "it should include a non empty title: FAIL" 1>&2
((FAILED_TESTS++))
else
echo "it should include a non empty title: PASS"
fi
if [[ $FAILED_TESTS -ne 0 ]]; then
echo
echo $FAILED_TESTS SMOKE TESTS FAILED
echo
echo The api returned the following response
echo "$BODY" | jq
echo
exit 1
fi