Skip to content

Commit da0e905

Browse files
author
Chris Park
committed
Mod to track the result for each example and pass/fail based on all successful. Also filter on [ to get rid of meaningless jq error
1 parent ec0705a commit da0e905

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

examples/docker/run-examples.sh

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ if [ ! -z ${match} ]; then
5656
fi
5757

5858
badRequest="badRequest"
59+
err=0
5960

6061
if [ "$filename" != "na" ]; then
6162
# single file operation
@@ -70,10 +71,12 @@ if [ "$filename" != "na" ]; then
7071
echo -e "\nUnexpected response\n"
7172
exit 1
7273
fi
73-
responseCount=`echo $result | jq 'del(.requestId) | .[] | length' | awk '{SUM += $1} END { print SUM }'`
74-
if [ $responseCount -eq 0 2>/dev/null]; then
75-
echo -e "\nEmpty response\n"
76-
exit 1
74+
if [[ $result == *"["* ]]; then
75+
responseCount=`echo $result | jq 'del(.requestId) | .[] | length' | awk '{SUM += $1} END { print SUM }'`
76+
if [ $responseCount -eq 0 2>/dev/null]; then
77+
echo -e "\nEmpty response\n"
78+
exit 1
79+
fi
7780
fi
7881
else
7982
# all files with .sh
@@ -89,15 +92,18 @@ else
8992
# Check for bad request and fail the script if matched
9093
if [[ ${result} =~ .*$badRequest.* ]]; then
9194
echo -e "\nUnexpected response\n"
92-
exit 1
95+
err=1
9396
fi
94-
responseCount=`echo $result | jq 'del(.requestId) | .[] | length' | awk '{SUM += $1} END { print SUM }'`
95-
if [ $responseCount -eq 0 2>/dev/null ]; then
96-
echo -e "\nEmpty response\n"
97-
exit 1
97+
if [[ $result == *"["* ]]; then
98+
responseCount=`echo $result | jq 'del(.requestId) | .[] | length' | awk '{SUM += $1} END { print SUM }'`
99+
if [ $responseCount -eq 0 2>/dev/null]; then
100+
echo -e "\nEmpty response\n"
101+
err=1
102+
fi
98103
fi
99104
echo -e "\n---------- $file end -------------"
100105
done
101106
fi
102107

103108
echo $alt_url
109+
exit $err

0 commit comments

Comments
 (0)