aboutsummaryrefslogtreecommitdiff
path: root/tests/installer-steps/test_pacman_hook_order.py
blob: 49acdbe5f170924166d4f8d9efadf91ac46b882a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
"""Regression tests for the pacman hook ordering safety invariant."""

import os
import unittest


REPO_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", ".."))
ARCHSETUP = os.path.join(REPO_ROOT, "archsetup")


class PacmanHookOrderTests(unittest.TestCase):
    def test_safety_hooks_precede_mkinitcpio_removal(self):
        with open(ARCHSETUP, encoding="utf-8") as source:
            text = source.read()

        self.assertIn(
            "cat << 'EOF' > /etc/pacman.d/hooks/05-zfs-snapshot.hook", text)
        self.assertIn(
            "cat > /etc/pacman.d/hooks/10-hypr-live-update-guard.hook", text)
        self.assertLess("05-zfs-snapshot.hook", "60-mkinitcpio-remove.hook")
        self.assertLess("10-hypr-live-update-guard.hook", "60-mkinitcpio-remove.hook")
        self.assertIn("rm -f /etc/pacman.d/hooks/zfs-snapshot.hook", text)
        self.assertIn("rm -f /etc/pacman.d/hooks/hypr-live-update-guard.hook", text)


if __name__ == "__main__":
    unittest.main()