5
5
# Fail on error
6
6
set -e
7
7
8
- ORDER_ID=" $1 "
8
+ TEST_STEP=" $1 "
9
+ ORDER_ID=" $2 "
9
10
10
11
function order() {
11
12
echo ' {"serviceName": "order", "commandName": "' " $2 " ' ", "orderId": ' " $1 " ' , "orderItem": "sushi", "deliverTo": "780 PANORAMA DR, San francisco, CA"}'
12
13
}
13
14
14
15
function inventory() {
15
- echo ' {"serviceName": "supplier", "commandName": "' " $2 " ' ", "orderId": "-1" , "orderItem": ' " $1 " ' , "deliverTo": ""}'
16
+ echo ' {"serviceName": "supplier", "commandName": "' " $2 " ' ", "orderId": -1 , "orderItem": " ' " $1 " ' " , "deliverTo": ""}'
16
17
}
17
18
18
19
function placeOrderTest() {
19
20
# Place order
20
- if wget --http-user grabdish --http-password " $TEST_UI_PASSWORD " --no-check-certificate --post-data " $( order " $1 " ' placeOrder' ) " \
21
- --header=' Content-Type: application/json' " $( state_get FRONTEND_URL) /placeorder" ; then
22
- echo " placeOrder $1 failed"
23
- return 1
21
+ local ORDER_ID=" $1 "
22
+ if wget --http-user grabdish --http-password " $TEST_UI_PASSWORD " --no-check-certificate --post-data " $( order " $ORDER_ID " ' placeOrder' ) " \
23
+ --header=' Content-Type: application/json' " $( state_get FRONTEND_URL) /placeorder" -O $GRABDISH_LOG /order; then
24
+ echo " TEST_LOG: $TEST_STEP placeOrder $ORDER_ID succeeded"
25
+ else
26
+ echo " TEST_LOG_FAILED: $TEST_STEP placeOrder $ORDER_ID failed"
24
27
fi
25
28
}
26
29
27
30
function showOrderTest() {
28
- # Place order
29
- if wget --http-user grabdish --http-password " $TEST_UI_PASSWORD " --no-check-certificate --post-data " $( order " $1 " ' showorder' ) " \
30
- --header=' Content-Type: application/json' " $( state_get FRONTEND_URL) /command" > $GRUBDASH_LOG /order; then
31
- echo " showOrder $1 failed"
32
- return 1
31
+ # Show order
32
+ local ORDER_ID=" $1 "
33
+ local SEARCH_FOR=" $2 "
34
+ if wget --http-user grabdish --http-password " $TEST_UI_PASSWORD " --no-check-certificate --post-data " $( order " $ORDER_ID " ' showorder' ) " \
35
+ --header=' Content-Type: application/json' " $( state_get FRONTEND_URL) /command" -O $GRABDISH_LOG /order; then
36
+ echo " TEST_LOG: $TEST_STEP showOrder request $1 succeeded"
37
+ if grep " $SEARCH_FOR " $GRABDISH_LOG /order > /dev/null; then
38
+ echo " TEST_LOG: $TEST_STEP showOrder $ORDER_ID matched"
39
+ else
40
+ echo " TEST_LOG_FAILED: $TEST_STEP showOrder $ORDER_ID nomatch"
41
+ fi
42
+ else
43
+ echo " TEST_LOG_FAILED: $TEST_STEP showOrder request $1 failed"
33
44
fi
34
-
35
- echo $GRUBDASH_LOG /order
36
45
}
37
46
38
47
function addInventoryTest() {
39
- # Place order
40
- if wget --http-user grabdish --http-password " $TEST_UI_PASSWORD " --no-check-certificate --post-data " $( inventory " $1 " ' addInventory' ) " \
41
- --header=' Content-Type: application/json' " $( state_get FRONTEND_URL) /command" ; then
42
- echo " showOrder $1 failed"
43
- return 1
48
+ # Add inventory
49
+ local ITEM_ID=" $1 "
50
+ if wget --http-user grabdish --http-password " $TEST_UI_PASSWORD " --no-check-certificate --post-data " $( inventory " $ITEM_ID " ' addInventory' ) " \
51
+ --header=' Content-Type: application/json' " $( state_get FRONTEND_URL) /command" -O $GRABDISH_LOG /inventory; then
52
+ echo " TEST_LOG: $TEST_STEP addInventory $ITEM_ID succeeded"
53
+ else
54
+ echo " TEST_LOG_FAILED: $TEST_STEP addInventory $ITEM_ID request failed"
44
55
fi
45
56
}
46
57
@@ -50,7 +61,7 @@ placeOrderTest $ORDER_ID
50
61
51
62
sleep 5
52
63
53
- showOrderTest $ORDER_ID ' no inventory'
64
+ showOrderTest $ORDER_ID ' failed inventory does not exist '
54
65
55
66
56
67
# Add inventory
@@ -64,4 +75,4 @@ placeOrderTest "$ORDER_ID"
64
75
65
76
sleep 5
66
77
67
- showOrderTest " $ORDER_ID " ' inventory exists'
78
+ showOrderTest " $ORDER_ID " ' success inventory exists'
0 commit comments