File tree Expand file tree Collapse file tree 1 file changed +32
-7
lines changed
Expand file tree Collapse file tree 1 file changed +32
-7
lines changed Original file line number Diff line number Diff line change @@ -514,20 +514,45 @@ for arg in "$@"; do
514514 esac
515515done
516516
517- if [ ! -f " $FILE " ]; then
518- echo " Please provide an existing file."
517+ command -v curl > /dev/null 2>&1 || {
518+ echo >&2 " This program requires 'curl' to run. Please install 'curl'"
519+ exit 1
520+ }
521+ command -v jq > /dev/null 2>&1 || {
522+ echo >&2 " This program requires 'jq' to run. Please install 'jq'"
519523 exit 1
524+ }
525+
526+ if [ ! -f " $FILE " ]; then
527+ DEFAULT_FILE=(" test.json api-test.json template.json" )
528+ FOUND_FILE=0
529+ for default in $DEFAULT_FILE ; do
530+ if [ -f " $default " ]; then
531+ FOUND_FILE=1
532+ FILE=$default
533+ break
534+ fi
535+ done
536+ if [[ $FOUND_FILE == 0 ]]; then
537+ echo " Please provide an existing file."
538+ exit 1
539+ fi
540+ echo $FILE
520541fi
521542
522- cat $FILE | jq empty
543+ jq empty $FILE
544+
523545if [ $? -ne 0 ]; then
524- echo " Empty file"
525- exit
546+ exit 1
526547fi
548+
527549URL=$( jq -r ' .url' $FILE )
528- ACCESS_TOKEN=$( jq -r ' .accessToken' $FILE )
529- ID_TOKEN=$( jq -r ' .idToken' $FILE )
530550COMMON_HEADER=$( cat $FILE | jq -r -c " . | .header | if . != null then . else {} end | to_entries | map(\" \(.key): \(.value|tostring)\" ) | join(\" \n\" ) | if ( . | length) != 0 then \" -H\" + . else \" -H \" end" )
551+ if [[ -z $( jq -r ' .testCases | select(. != null and . != {})' $FILE ) ]]; then
552+ echo " 'testCases' is a required field in base object of a test file and must have atleast one test case."
553+ exit 1
554+ fi
555+
531556
532557case $ACTION in
533558run)
You can’t perform that action at this time.
0 commit comments