Skip to content

Commit

Permalink
Merge pull request #21 from subeshb1/hot-fix/prevent_null_body
Browse files Browse the repository at this point in the history
Prevent null value being sent in body if it is not provided.
  • Loading branch information
subeshb1 authored Jun 11, 2020
2 parents f729182 + eccb52a commit 486874b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions .version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.3.1
4 changes: 2 additions & 2 deletions api-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ function usage() {
# api methods
call_api() {
ROUTE=$(jq -r ".testCases.$1.path" $FILE)
BODY="$(jq -r ".testCases.$1.body" $FILE)"
BODY="$(jq -r ".testCases.$1 | select(.body != null) | .body" $FILE)"
QUERY_PARAMS=$(cat $FILE | jq -r ".testCases.$1 | select(.query != null) | .query | to_entries | map(\"\(.key)=\(.value|tostring)\") | join(\"&\") | \"?\" + . ")
REQUEST_HEADER=$(cat $FILE | jq -r ".testCases.$1 | .header | if . != null then . else {} end | to_entries | map(\"\(.key): \(.value|tostring)\") | join(\"\n\") | if ( . | length) != 0 then \"-H\" + . else \"-H \" end")
METHOD="$(jq -r ".testCases.$1.method //\"GET\" | ascii_upcase" $FILE)"
Expand Down Expand Up @@ -266,7 +266,7 @@ test_factory() {
TEST_SCENARIO=$(jq -r ".testCases.$TEST_CASE.expect.external? | select(. !=null and . != \"\")" $FILE)
if [[ ! -z $TEST_SCENARIO ]]; then
tput cuf 2
echo "${UNDERLINE}Checking condition form external program${RESET}"
echo "${UNDERLINE}Checking condition from external program${RESET}"
external_script "$TEST_SCENARIO" "$TEST_CASE" "$RESPONSE_BODY" "$RESPONSE_HEADER"
TOTAL_TEST_CASE=$((TOTAL_TEST_CASE + 1))
echo ""
Expand Down

0 comments on commit 486874b

Please sign in to comment.