tests: Add test for required-flatpak versioning

This sets required-flatpak in the metadata to some different versions
and ensure we're properly able or not able to install it.

Additionally it uses some options with multiple versions. This is not
yet supported but I want to test the existing code and make sure it
properly falls back to just using the first element of the list.

Closes: #3112
Approved by: alexlarsson

(cherry picked from commit 62117308c1)
This commit is contained in:
Alexander Larsson
2019-09-18 16:11:50 +02:00
committed by Alexander Larsson
parent 2c273131af
commit 5db4631a79
2 changed files with 63 additions and 1 deletions

View File

@@ -27,7 +27,15 @@ cat > ${DIR}/metadata <<EOF
name=$APP_ID
runtime=org.test.Platform/$ARCH/$BRANCH
sdk=org.test.Platform/$ARCH/$BRANCH
EOF
if [ x${REQUIRED_VERSION-} != x ]; then
cat >> ${DIR}/metadata <<EOF
required-flatpak=$REQUIRED_VERSION
EOF
fi
cat >> ${DIR}/metadata <<EOF
[Extension $APP_ID.Locale]
directory=share/runtime/locale
autodelete=true

View File

@@ -24,7 +24,7 @@ set -euo pipefail
skip_without_bwrap
skip_revokefs_without_fuse
echo "1..33"
echo "1..34"
#Regular repo
setup_repo
@@ -243,6 +243,60 @@ assert_file_has_content install-error-log "GPG signatures found, but none are in
echo "ok fail with wrong gpg key"
make_required_version_app () {
APP_ID=${1}
VERSION=${2}
if [ x${USE_COLLECTIONS_IN_SERVER-} == xyes ] ; then
CID=org.test.Collection.test
else
CID=""
fi
REQUIRED_VERSION="${VERSION}" GPGARGS="${FL_GPGARGS}" $(dirname $0)/make-test-app.sh repos/test ${APP_ID} master "${CID}" > /dev/null
}
CURRENT_VERSION=`cat "$test_builddir/package_version.txt"`
V=( ${CURRENT_VERSION//./ } ) # Split parts to array
make_required_version_app org.test.SameVersion "${V[0]}.${V[1]}.${V[2]}"
make_required_version_app org.test.NeedNewerMicro "${V[0]}.${V[1]}.$(expr ${V[2]} + 1)"
make_required_version_app org.test.NeedNewerMinor "${V[0]}.$(expr ${V[1]} + 1).${V[2]}"
make_required_version_app org.test.NeedNewerMaster "$(expr ${V[0]} + 1).${V[1]}.${V[2]}"
make_required_version_app org.test.NeedOlderMinor "${V[0]}.$(expr ${V[1]} - 1).${V[2]}"
make_required_version_app org.test.MultiVersionFallback "${V[0]}.${V[1]}.${V[2]};1.0.0;"
make_required_version_app org.test.MultiVersionFallbackFail "${V[0]}.$(expr ${V[1]} + 1).${V[2]};1.0.0;"
update_repo $REPONAME "${COLLECTION_ID}"
${FLATPAK} ${U} install -y test-repo org.test.SameVersion
${FLATPAK} ${U} install -y test-repo org.test.NeedOlderMinor
if ${FLATPAK} ${U} install -y test-repo org.test.NeedNewerMicro 2> install-error-log; then
assert_not_reached "Should not be able to install with wrong micro version"
fi
assert_file_has_content install-error-log "needs a later flatpak version"
if ${FLATPAK} ${U} install -y test-repo org.test.NeedNewerMinor 2> install-error-log; then
assert_not_reached "Should not be able to install with wrong minor version"
fi
assert_file_has_content install-error-log "needs a later flatpak version"
if ${FLATPAK} ${U} install -y test-repo org.test.NeedNewerMajor 2> install-error-log; then
assert_not_reached "Should not be able to install with wrong micro version"
fi
assert_file_has_content install-error-log "needs a later flatpak version"
${FLATPAK} ${U} install -y test-repo org.test.MultiVersionFallback
if ${FLATPAK} ${U} install -y test-repo org.test.MultiVersionFallbackFail 2> install-error-log; then
assert_not_reached "Should not be able to install with wrong fallback version"
fi
assert_file_has_content install-error-log "needs a later flatpak version"
${FLATPAK} ${U} uninstall -y --all
echo "ok handles version requirements"
${FLATPAK} ${U} remotes -d | grep ^test-repo > repo-info
assert_not_file_has_content repo-info "new-title"
UPDATE_REPO_ARGS=--title=new-title update_repo