55# Fail on error
66set -e
77
8- ORDER_ID=" $1 "
8+ TEST_STEP=" $1 "
9+ ORDER_ID=" $2 "
910
1011function order() {
1112 echo ' {"serviceName": "order", "commandName": "' " $2 " ' ", "orderId": ' " $1 " ' , "orderItem": "sushi", "deliverTo": "780 PANORAMA DR, San francisco, CA"}'
1213}
1314
1415function inventory() {
15- echo ' {"serviceName": "supplier", "commandName": "' " $2 " ' ", "orderId": "-1" , "orderItem": ' " $1 " ' , "deliverTo": ""}'
16+ echo ' {"serviceName": "supplier", "commandName": "' " $2 " ' ", "orderId": -1 , "orderItem": " ' " $1 " ' " , "deliverTo": ""}'
1617}
1718
1819function placeOrderTest() {
1920 # 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"
2427 fi
2528}
2629
2730function 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"
3344 fi
34-
35- echo $GRUBDASH_LOG /order
3645}
3746
3847function 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"
4455 fi
4556}
4657
@@ -50,7 +61,7 @@ placeOrderTest $ORDER_ID
5061
5162sleep 5
5263
53- showOrderTest $ORDER_ID ' no inventory'
64+ showOrderTest $ORDER_ID ' failed inventory does not exist '
5465
5566
5667# Add inventory
@@ -64,4 +75,4 @@ placeOrderTest "$ORDER_ID"
6475
6576sleep 5
6677
67- showOrderTest " $ORDER_ID " ' inventory exists'
78+ showOrderTest " $ORDER_ID " ' success inventory exists'
0 commit comments