tests/libtest.sh: Lift assert_jq from libvm.sh

We already had this logic, but it was in `libvm.sh`. Prep for using it
elsewhere.

Closes: #1766
Approved by: cgwalters
This commit is contained in:
Jonathan Lebon 2019-02-26 11:04:48 -05:00 committed by Atomic Bot
parent 3f722b5005
commit 75f415f09f
2 changed files with 14 additions and 9 deletions

View File

@ -562,3 +562,16 @@ assert_files_hardlinked() {
fatal "Files '$1' and '$2' are not hardlinked"
fi
}
# $1 - json file
# $2+ - assertions
assert_jq() {
f=$1; shift
for expression in "$@"; do
if ! jq -e "${expression}" >/dev/null < $f; then
jq . < $f | sed -e 's/^/# /' >&2
echo 1>&2 "${expression} failed to match $f"
exit 1
fi
done
}

View File

@ -354,15 +354,7 @@ vm_assert_layered_pkg() {
# and asserts that they are true.
vm_assert_status_jq() {
vm_rpmostree status --json > status.json
vm_rpmostree status > status.txt
for expression in "$@"; do
if ! jq -e "${expression}" >/dev/null < status.json; then
jq . < status.json | sed -e 's/^/# /' >&2
echo 1>&2 "${expression} failed to match status.json"
cat status.txt
exit 1
fi
done
assert_jq status.json "$@"
}
vm_pending_is_staged() {