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:
parent
3f722b5005
commit
75f415f09f
@ -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
|
||||
}
|
||||
|
@ -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() {
|
||||
|
Loading…
Reference in New Issue
Block a user