From 5db4631a795fc642e9be2c58dd0efb2ef4ff6090 Mon Sep 17 00:00:00 2001 From: Alexander Larsson Date: Wed, 18 Sep 2019 16:11:50 +0200 Subject: [PATCH] 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) --- tests/make-test-app.sh | 8 ++++++ tests/test-repo.sh | 56 +++++++++++++++++++++++++++++++++++++++++- 2 files changed, 63 insertions(+), 1 deletion(-) diff --git a/tests/make-test-app.sh b/tests/make-test-app.sh index 0a0a28f1..e86d16f3 100755 --- a/tests/make-test-app.sh +++ b/tests/make-test-app.sh @@ -27,7 +27,15 @@ cat > ${DIR}/metadata <> ${DIR}/metadata <> ${DIR}/metadata < /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