Skip to content

Commit a7a60cc

Browse files
committed
Update check_eq to check for basic types
1 parent 6a447f3 commit a7a60cc

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

api-test.sh

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,13 @@ has_key() {
271271

272272
check_eq() {
273273
tput cuf 6
274-
local check=$(jq --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')
274+
local type=$(jq -r --argjson a "$1" -n '$a|type')
275+
local check
276+
if [[ $type == "object" || $type == "array" ]]; then
277+
check=$(jq --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')
278+
else
279+
check=$(jq --argjson a "$1" --argjson b "$2" -n '$a == $b')
280+
fi
275281
if [[ $check == "true" ]]; then
276282
echo "${GREEN}${BOLD}Check Passed${RESET}"
277283
else
@@ -284,6 +290,7 @@ check_eq() {
284290
fi
285291
}
286292

293+
287294
run() {
288295
for arg in "$@"; do
289296
case $arg in

0 commit comments

Comments
 (0)