summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhaedrus Leeds <mwleeds@protonmail.com>2021-12-28 14:14:36 -0800
committerPhaedrus Leeds <mwleeds@protonmail.com>2021-12-28 14:26:39 -0800
commit539adb7812cb4744cd51d401661ebbee64b5106f (patch)
tree3cfc50f7c23dcd6afd4c2cf1f1569847979c2316
parent3220bc6e1805f8eef81db680e26f756fd39d9111 (diff)
downloadflatpak-539adb7812cb4744cd51d401661ebbee64b5106f.tar.gz
Add a test for the repair commandfix-4618-repair-commitpartial
This should ensure that https://github.com/flatpak/flatpak/issues/4618 stays fixed.
-rw-r--r--tests/Makefile-test-matrix.am.inc1
-rw-r--r--tests/Makefile.am.inc1
-rwxr-xr-xtests/test-repair.sh35
3 files changed, 37 insertions, 0 deletions
diff --git a/tests/Makefile-test-matrix.am.inc b/tests/Makefile-test-matrix.am.inc
index 7f302ca9..1b9e52ab 100644
--- a/tests/Makefile-test-matrix.am.inc
+++ b/tests/Makefile-test-matrix.am.inc
@@ -43,6 +43,7 @@ TEST_MATRIX_DIST= \
tests/test-unused.sh \
tests/test-prune.sh \
tests/test-seccomp.sh \
+ tests/test-repair.sh \
$(NULL)
TEST_MATRIX_EXTRA_DIST= \
tests/test-run.sh \
diff --git a/tests/Makefile.am.inc b/tests/Makefile.am.inc
index 7d1b2029..32f61474 100644
--- a/tests/Makefile.am.inc
+++ b/tests/Makefile.am.inc
@@ -281,6 +281,7 @@ TEST_MATRIX_SOURCE = \
tests/test-subset.sh{user+system} \
tests/test-prune.sh \
tests/test-seccomp.sh \
+ tests/test-repair.sh \
$(NULL)
update-test-matrix:
diff --git a/tests/test-repair.sh b/tests/test-repair.sh
new file mode 100755
index 00000000..8f0fdfd0
--- /dev/null
+++ b/tests/test-repair.sh
@@ -0,0 +1,35 @@
+#!/bin/bash
+#
+# Copyright (C) 2021 Matthew Leeds <mwleeds@protonmail.com>
+#
+# SPDX-License-Identifier: LGPL-2.0-or-later
+
+set -euo pipefail
+
+. $(dirname $0)/libtest.sh
+
+echo "1..1"
+
+setup_repo
+${FLATPAK} ${U} install -y test-repo org.test.Hello
+
+# delete the object for files/bin/hello.sh
+rm ${FL_DIR}/repo/objects/0d/30582c0ac8a2f89f23c0f62e548ba7853f5285d21848dd503460a567b5d253.file
+
+# dry run repair shouldn't replace the missing file
+${FLATPAK} ${U} repair --dry-run
+assert_not_has_file ${FL_DIR}/repo/objects/0d/30582c0ac8a2f89f23c0f62e548ba7853f5285d21848dd503460a567b5d253.file
+
+# normal repair should replace the missing file
+${FLATPAK} ${U} repair
+assert_has_file ${FL_DIR}/repo/objects/0d/30582c0ac8a2f89f23c0f62e548ba7853f5285d21848dd503460a567b5d253.file
+
+# app should've been reinstalled
+${FLATPAK} ${U} list -d > list-log
+assert_file_has_content list-log "org\.test\.Hello/"
+
+# clean up
+${FLATPAK} ${U} uninstall -y org.test.Platform org.test.Hello
+${FLATPAK} ${U} remote-delete test-repo
+
+ok "repair command handles missing files"