Skip to content

Commit 486874b

Browse files
authored
Merge pull request #21 from subeshb1/hot-fix/prevent_null_body
Prevent null value being sent in body if it is not provided.
2 parents f729182 + eccb52a commit 486874b

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

.version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0.3.1

api-test.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ function usage() {
139139
# api methods
140140
call_api() {
141141
ROUTE=$(jq -r ".testCases.$1.path" $FILE)
142-
BODY="$(jq -r ".testCases.$1.body" $FILE)"
142+
BODY="$(jq -r ".testCases.$1 | select(.body != null) | .body" $FILE)"
143143
QUERY_PARAMS=$(cat $FILE | jq -r ".testCases.$1 | select(.query != null) | .query | to_entries | map(\"\(.key)=\(.value|tostring)\") | join(\"&\") | \"?\" + . ")
144144
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")
145145
METHOD="$(jq -r ".testCases.$1.method //\"GET\" | ascii_upcase" $FILE)"
@@ -266,7 +266,7 @@ test_factory() {
266266
TEST_SCENARIO=$(jq -r ".testCases.$TEST_CASE.expect.external? | select(. !=null and . != \"\")" $FILE)
267267
if [[ ! -z $TEST_SCENARIO ]]; then
268268
tput cuf 2
269-
echo "${UNDERLINE}Checking condition form external program${RESET}"
269+
echo "${UNDERLINE}Checking condition from external program${RESET}"
270270
external_script "$TEST_SCENARIO" "$TEST_CASE" "$RESPONSE_BODY" "$RESPONSE_HEADER"
271271
TOTAL_TEST_CASE=$((TOTAL_TEST_CASE + 1))
272272
echo ""

0 commit comments

Comments
 (0)