From 0d873444bb92c031708504be91e831206dda6e01 Mon Sep 17 00:00:00 2001 From: Rafael Fonseca Date: Tue, 29 Jan 2019 20:07:17 +0100 Subject: [PATCH] lockfile: add tests --- tests/compose-tests/test-lockfile.sh | 42 ++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100755 tests/compose-tests/test-lockfile.sh diff --git a/tests/compose-tests/test-lockfile.sh b/tests/compose-tests/test-lockfile.sh new file mode 100755 index 0000000000..2c5b8f071e --- /dev/null +++ b/tests/compose-tests/test-lockfile.sh @@ -0,0 +1,42 @@ +#!/bin/bash +set -xeuo pipefail + +dn=$(cd $(dirname $0) && pwd) +. ${dn}/libcomposetest.sh + +prepare_compose_test "lockfile" +# Add a local rpm-md repo so we can mutate local test packages +pyappendjsonmember "repos" '["test-repo"]' +build_rpm test-pkg \ + files "/usr/bin/test-pkg" \ + install "mkdir -p %{buildroot}/usr/bin && echo localpkg data > %{buildroot}/usr/bin/test-pkg" +# The test suite writes to pwd, but we need repos in composedata +# Also we need to disable gpgcheck +echo gpgcheck=0 >> yumrepo.repo +ln yumrepo.repo composedata/test-repo.repo +pyappendjsonmember "packages" '["test-pkg"]' +pysetjsonmember "documentation" 'False' +mkdir cache +# Create lockfile +runcompose --ex-write-lockfile-to=$PWD/versions.lock --cachedir $(pwd)/cache +npkgs=$(rpm-ostree --repo=${repobuild} db list ${treeref} |grep -v '^ostree commit' | wc -l) +echo "npkgs=${npkgs}" +rpm-ostree --repo=${repobuild} db list ${treeref} test-pkg >test-pkg-list.txt +assert_file_has_content test-pkg-list.txt 'test-pkg-1.0-1.x86_64' +echo "ok compose" + +assert_has_file "versions.lock" +assert_file_has_content $PWD/versions.lock 'packages' +assert_file_has_content $PWD/versions.lock 'test-pkg-1.0-1.x86_64' +echo "lockfile created" +# Read lockfile back +build_rpm test-pkg \ + version 2.0 \ + files "/usr/bin/test-pkg" \ + install "mkdir -p %{buildroot}/usr/bin && echo localpkg data > %{buildroot}/usr/bin/test-pkg" +runcompose --ex-lockfile=$PWD/versions.lock --cachedir $(pwd)/cache +echo "ok compose with lockfile" + +rpm-ostree --repo=${repobuild} db list ${treeref} test-pkg >test-pkg-list.txt +assert_file_has_content test-pkg-list.txt 'test-pkg-1.0-1.x86_64' +echo "lockfile read"