summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Larsson <alexl@redhat.com>2019-09-18 16:11:50 +0200
committerAtomic Bot <atomic-devel@projectatomic.io>2019-09-19 12:43:18 +0000
commitb89a422ad69dcf4305e7101b0361c63e82d7623b (patch)
tree9403b89f2ee966e04b279e936dfbdcf89d33cd96
parent2fdad8379992901bb15044ef2db41752414366a5 (diff)
downloadflatpak-b89a422ad69dcf4305e7101b0361c63e82d7623b.tar.gz
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 62117308c1dd0f10f82d274d542da0d9b7f7d426) (cherry picked from commit 5db4631a795fc642e9be2c58dd0efb2ef4ff6090) Closes: #3115 Approved by: alexlarsson (cherry picked from commit cf13a1461fc9ed3c2a78d5b4f15466afb5ba87af) Closes: #3117 Approved by: alexlarsson
-rwxr-xr-xtests/make-test-app.sh6
-rwxr-xr-xtests/test-repo.sh57
2 files changed, 62 insertions, 1 deletions
diff --git a/tests/make-test-app.sh b/tests/make-test-app.sh
index 597b6cd3..823411da 100755
--- a/tests/make-test-app.sh
+++ b/tests/make-test-app.sh
@@ -27,6 +27,12 @@ runtime=org.test.Platform/$ARCH/master
sdk=org.test.Platform/$ARCH/master
EOF
+if [ x${REQUIRED_VERSION-} != x ]; then
+cat >> ${DIR}/metadata <<EOF
+required-flatpak=$REQUIRED_VERSION
+EOF
+fi
+
mkdir -p ${DIR}/files/bin
cat > ${DIR}/files/bin/hello.sh <<EOF
#!/bin/sh
diff --git a/tests/test-repo.sh b/tests/test-repo.sh
index bab3e6ea..45f94810 100755
--- a/tests/test-repo.sh
+++ b/tests/test-repo.sh
@@ -23,7 +23,7 @@ set -euo pipefail
skip_without_bwrap
-echo "1..22"
+echo "1..23"
#Regular repo
setup_repo
@@ -157,6 +157,61 @@ assert_file_has_content install-error-log "GPG signatures found, but none are in
echo "ok fail with wrong gpg key"
+if [ x${USE_COLLECTIONS_IN_SERVER-} == xyes ] ; then
+ CID=org.test.Collection.test
+else
+ CID=""
+fi
+
+make_required_version_app () {
+ APP_ID=${1}
+ VERSION=${2}
+
+ REQUIRED_VERSION="${VERSION}" GPGARGS="${FL_GPGARGS}" $(dirname $0)/make-test-app.sh test ${APP_ID} "${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.NeedNewerMajor "$(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 test "${CID}"
+
+${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