rpm-ostree/tests/compose-tests/test-write-commitid.sh
Colin Walters 6f6728b992 compose: Add --write-composejson-to
For higher level tools driving rpm-ostree, the command line arguments
are mostly OK as inputs, but the addition of `--write-commitid-to`
shows that we really want structured data that these tools can parse.
JSON is a good enough interchange format, let's use that.

Most notably this does a pkgdiff in the JSON which several higher
level tools do too.

Closes: #1529
Approved by: jlebon
2018-09-07 18:52:54 +00:00

30 lines
827 B
Bash
Executable File

#!/bin/bash
set -xeuo pipefail
dn=$(cd $(dirname $0) && pwd)
. ${dn}/libcomposetest.sh
prepare_compose_test "write-commitid"
runcompose --write-commitid-to $(pwd)/commitid.txt \
--write-composejson-to $(pwd)/composemeta.json
wc -c < commitid.txt > wc.txt
assert_file_has_content_literal wc.txt 64
echo "ok compose"
# --write-commitid-to should not set the ref
if ostree --repo=${repobuild} rev-parse ${treeref}; then
fatal "Found ${treeref} ?"
fi
echo "ok ref not written"
commitid_txt=$(cat commitid.txt)
json_commit=$(jq -r '.["ostree-commit"]' composemeta.json)
assert_streq "${json_commit}" "${commitid_txt}"
# And verify we have other keys
for key in ostree-version rpm-ostree-inputhash ostree-content-bytes-written; do
jq -r '.["'${key}'"]' composemeta.json >/dev/null
done
echo "ok composejson"