summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhaedrus Leeds <mwleeds@protonmail.com>2021-10-28 11:42:25 -0700
committerPhaedrus Leeds <mwl458@gmail.com>2022-01-04 11:42:00 -0800
commit8b05f6b36593a7ebb5b3bdb7c9cd16072b2e3e8a (patch)
treeda7bb110b15fd1b5646caa42edeb55fb42511d96
parent2f13aabad6d9ac1aea9af5f7bf94abf4fbbc679a (diff)
downloadflatpak-8b05f6b36593a7ebb5b3bdb7c9cd16072b2e3e8a.tar.gz
Add a unit test for the history command
-rw-r--r--tests/Makefile-test-matrix.am.inc1
-rw-r--r--tests/Makefile.am.inc1
-rwxr-xr-xtests/test-history.sh62
3 files changed, 64 insertions, 0 deletions
diff --git a/tests/Makefile-test-matrix.am.inc b/tests/Makefile-test-matrix.am.inc
index 7f302ca9..7b8b6ca3 100644
--- a/tests/Makefile-test-matrix.am.inc
+++ b/tests/Makefile-test-matrix.am.inc
@@ -35,6 +35,7 @@ TEST_MATRIX_DIST= \
tests/test-config.sh \
tests/test-build-update-repo.sh \
tests/test-http-utils.sh \
+ tests/test-history.sh \
tests/test-default-remotes.sh \
tests/test-extensions.sh \
tests/test-oci.sh \
diff --git a/tests/Makefile.am.inc b/tests/Makefile.am.inc
index 7d1b2029..e5a28529 100644
--- a/tests/Makefile.am.inc
+++ b/tests/Makefile.am.inc
@@ -266,6 +266,7 @@ TEST_MATRIX_SOURCE = \
tests/test-run.sh{{user+system+system-norevokefs},{nodeltas+deltas}} \
tests/test-info.sh{user+system} \
tests/test-repo.sh{{user+system+system-norevokefs}+{{user+system},oldsummary}} \
+ tests/test-history.sh \
tests/test-sideload.sh{user+system} \
tests/test-default-remotes.sh \
tests/test-extensions.sh \
diff --git a/tests/test-history.sh b/tests/test-history.sh
new file mode 100755
index 00000000..78fbf8ba
--- /dev/null
+++ b/tests/test-history.sh
@@ -0,0 +1,62 @@
+#!/bin/bash
+# Copyright (C) 2021 Matthew Leeds <mwleeds@protonmail.com>
+# SPDX-License-Identifier: LGPL-2.0-or-later
+
+set -euo pipefail
+
+USE_SYSTEMDIR=yes
+
+. $(dirname $0)/libtest.sh
+
+skip_without_bwrap
+skip_revokefs_without_fuse
+
+echo "1..1"
+
+sleep 1
+HISTORY_START_TIME=$(date +"%Y-%m-%d %H:%M:%S")
+
+mkdir -p ${TEST_DATA_DIR}/system-history-installation
+mkdir -p ${FLATPAK_CONFIG_DIR}/installations.d
+cat << EOF > ${FLATPAK_CONFIG_DIR}/installations.d/history-installation.conf
+[Installation "history-installation"]
+Path=${TEST_DATA_DIR}/system-history-installation
+EOF
+
+# setup repo and install from it
+setup_repo_no_add
+port=$(cat httpd-port)
+${FLATPAK} --installation=history-installation remote-add \
+ --gpg-import=${FL_GPG_HOMEDIR}/pubring.gpg test-repo "http://127.0.0.1:${port}/test"
+${FLATPAK} --installation=history-installation install -y test-repo org.test.Hello master
+
+# appstream update shouldn't show up in history
+${FLATPAK} ${U} --appstream update test-repo
+
+# update, uninstall, and remote-delete should show up
+EXPORT_ARGS="" make_updated_app
+${FLATPAK} --installation=history-installation update -y org.test.Hello
+${FLATPAK} --installation=history-installation uninstall -y org.test.Platform org.test.Hello
+${FLATPAK} --installation=history-installation remote-delete test-repo
+
+# need --since and --columns here to make the test idempotent
+${FLATPAK} --installation=history-installation history --since="${HISTORY_START_TIME}" \
+ --columns=change,application,branch,installation,remote > history-log 2>&1
+
+diff history-log - << EOF
+add remote system (history-installation) test-repo
+deploy install org.test.Hello.Locale master system (history-installation) test-repo
+deploy install org.test.Platform master system (history-installation) test-repo
+deploy install org.test.Hello master system (history-installation) test-repo
+deploy update org.test.Hello.Locale master system (history-installation) test-repo
+deploy update org.test.Hello master system (history-installation) test-repo
+uninstall org.test.Hello master system (history-installation)
+uninstall org.test.Platform master system (history-installation)
+uninstall org.test.Hello.Locale master system (history-installation)
+remove remote system (history-installation) test-repo
+EOF
+
+rm -f ${FLATPAK_CONFIG_DIR}/installations.d/history-inst.conf
+rm -rf ${TEST_DATA_DIR}/system-history-installation
+
+ok "history looks correct"