Skip to content

Commit fe2183e

Browse files
committed
fix(test): update snapshot and skip JSON tests when jq is unavailable
1 parent 76d5376 commit fe2183e

2 files changed

Lines changed: 15 additions & 0 deletions

File tree

tests/acceptance/snapshots/bashunit_test_sh.test_bashunit_should_display_filtered_assert_docs.snapshot

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,11 @@ Reports an error if `expected` and `actual` are not equals.
2323
Reports an error if `expected` and `actual` are not equals.
2424

2525
- assert_files_equals is the inverse of this assertion and takes the same arguments.
26+
27+
28+
## assert_json_equals
29+
--------------
30+
> `assert_json_equals "expected" "actual"`
31+
32+
Reports an error if the two JSON strings are not structurally equal. Key order is ignored. Requires `jq` to be installed; if missing the test is skipped.
33+

tests/unit/assert_json_test.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
#!/usr/bin/env bash
22
# shellcheck disable=SC2329
33

4+
function set_up_before_script() {
5+
if ! command -v jq >/dev/null 2>&1; then
6+
bashunit::skip "jq is required for JSON assertions"
7+
return
8+
fi
9+
}
10+
411
function test_successful_assert_json_key_exists() {
512
assert_empty "$(assert_json_key_exists ".name" '{"name":"bashunit","version":"1.0"}')"
613
}

0 commit comments

Comments
 (0)