Skip to content

Commit 814d9b1

Browse files
authored
Merge pull request #26 from badevos/master
Fix check_eq when comparing values (no json data)
2 parents c645375 + ba30673 commit 814d9b1

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

api-test.sh

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -386,12 +386,18 @@ has_key() {
386386

387387
check_eq() {
388388
tput cuf 6
389-
local type=$(jq -r -c --argjson a "$1" -n '$a|type')
389+
local type=$(jq -r -c --argjson a "$1" -n '$a|type' 2>/dev/null)
390390
local check
391391
if [[ $type == "object" || $type == "array" ]]; then
392392
check=$(jq -c --argjson a "$1" --argjson b "$2" -n 'def post_recurse(f): def r: (f | select(. != null) | r), .; r; def post_recurse: post_recurse(.[]?); ($a | (post_recurse | arrays) |= sort) as $a | ($b | (post_recurse | arrays) |= sort) as $b | $a == $b')
393-
else
393+
elif [[ $type == "number" || $type == "boolean" || $type == "null" || $type == "string" ]]; then
394394
check=$(jq -c --argjson a "$1" --argjson b "$2" -n '$a == $b')
395+
else
396+
if [[ $1 == $2 ]]; then
397+
check="true"
398+
else
399+
check="false"
400+
fi
395401
fi
396402
if [[ $check == "true" ]]; then
397403
echo "${GREEN}${BOLD}Check Passed${RESET}"

0 commit comments

Comments
 (0)