test(hemar): many tests but not pass

This commit is contained in:
2025-12-09 13:49:43 +00:00
parent 73dc9aee9e
commit 6fb3ee1af8
10 changed files with 260 additions and 79 deletions

View File

@@ -6,12 +6,21 @@ json_diff() {
temp1=$(mktemp)
temp2=$(mktemp)
yq -I=0 -o=j -n "$1" >"$temp1"
yq -I=0 -o=j -n "$2" >"$temp2"
# Normalize JSON strings for comparison
printf '%s' "$1" | yq -I=0 -o=j . >"$temp1" 2>/dev/null || {
log error "first argument is not valid JSON: $WHITE$1"
exit 1
}
printf '%s' "$2" | yq -I=0 -o=j . >"$temp2" 2>/dev/null || {
log error "second argument is not valid JSON: $WHITE$2"
exit 1
}
if ! diff -q "$temp1" "$temp2"; then
log error "$(yq -o=j -n "$1")" and "$(yq -o=j -n "$2")"
exit 1
if ! diff -q "$temp1" "$temp2" >/dev/null 2>&1; then
log error "JSON mismatch:"
log error " Expected: $WHITE$(cat "$temp2")"
log error " Got: $WHITE$(cat "$temp1")"
exit 1
fi
}