aboutsummaryrefslogtreecommitdiff
path: root/scripts/testing/maint-scenarios/22-orphan-remove.sh
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/testing/maint-scenarios/22-orphan-remove.sh')
-rw-r--r--scripts/testing/maint-scenarios/22-orphan-remove.sh22
1 files changed, 22 insertions, 0 deletions
diff --git a/scripts/testing/maint-scenarios/22-orphan-remove.sh b/scripts/testing/maint-scenarios/22-orphan-remove.sh
new file mode 100644
index 0000000..8412128
--- /dev/null
+++ b/scripts/testing/maint-scenarios/22-orphan-remove.sh
@@ -0,0 +1,22 @@
+# shellcheck shell=bash disable=SC2034 # sourced by run-maint-scenarios.sh
+# Scenario: a real orphan is created, detected, and removed by name.
+#
+# Installing `tree` --asdeps with no dependents makes it a true orphan
+# (pacman -Qtdq lists it). The remedy is item-based: maint fix orphan_remove
+# tree. Assert covers both the package state and the metric verdict.
+SCENARIO_DESC="orphan package removed via the item-based remedy"
+SCENARIO_GROUP="packages"
+SCENARIO_PROFILES="any"
+
+scenario_break() {
+ mexec "pacman -S --noconfirm --asdeps tree && pacman -Qtdq | grep -qx tree"
+}
+
+scenario_fix() {
+ mfix orphan_remove tree
+}
+
+scenario_assert() {
+ mexec "! pacman -Qi tree >/dev/null 2>&1 && ! pacman -Qtdq | grep -qx tree" \
+ && massert_metric pkg_orphans ok
+}