summaryrefslogtreecommitdiffstats
path: root/packages/meshbay-node/tests/test_packaging_units.py
diff options
context:
space:
mode:
Diffstat (limited to 'packages/meshbay-node/tests/test_packaging_units.py')
-rw-r--r--packages/meshbay-node/tests/test_packaging_units.py48
1 files changed, 38 insertions, 10 deletions
diff --git a/packages/meshbay-node/tests/test_packaging_units.py b/packages/meshbay-node/tests/test_packaging_units.py
index bbfb536..2b9ad73 100644
--- a/packages/meshbay-node/tests/test_packaging_units.py
+++ b/packages/meshbay-node/tests/test_packaging_units.py
@@ -17,6 +17,9 @@ import pytest
ROOT = Path(__file__).resolve().parents[3]
SYSTEMD = ROOT / "packaging" / "systemd"
SPEC = ROOT / "packaging" / "rpm" / "meshbay-node.spec"
+# Where the files are actually placed: the spec's %install is a blind copy of
+# this script's output (see test_each_unit_is_installed_where_it_can_run).
+BUILD_NODE = ROOT / "packaging" / "build" / "build-node.sh"
pytestmark = pytest.mark.skipif(not SPEC.exists(), reason="packaging not present")
@@ -59,20 +62,45 @@ def test_the_user_unit_names_no_user():
def test_each_unit_is_installed_where_it_can_run():
- spec = SPEC.read_text(encoding="utf-8")
- install = spec.split("%files")[0]
+ """
+ Read where the units are *staged*, not what the spec says.
+
+ This used to inspect `meshbay-node.spec`'s `%install` for `install -D` lines
+ and their destination on the following line. The packaging overhaul
+ (2026-08-31) replaced that section with `cp -a %{_staging_root}/*
+ %{buildroot}/`: the spec no longer places individual files, `build-node.sh`
+ does, and the spec only declares them in `%files`. The test kept reading the
+ spec and failed for months against packaging that was correct all along —
+ checking a mechanism that no longer existed while the property it defends
+ still held.
+
+ So it now reads the script that actually places them. Same guarantee, aimed
+ at the thing that does the work: the template — the one carrying `User=%i` —
+ into the system directory, and the user unit, which cannot carry `User=`,
+ into the user one. systemd refuses the file outright if these are swapped,
+ which is how the original defect presented.
+ """
+ stage = BUILD_NODE.read_text(encoding="utf-8")
# The template goes to the system directory, instantiated per person.
- assert "%{_unitdir}/meshbay-node@.service" in install
+ assert "usr/lib/systemd/system/meshbay-node@.service" in stage, (
+ "the system template is not staged into the system unit directory")
# The user unit goes to the user directory, enabled without a password.
- assert "%{_userunitdir}/meshbay-node.service" in install
+ assert "usr/lib/systemd/user/meshbay-node.service" in stage, (
+ "the per-user unit is not staged into the user unit directory")
- system_line = next(l for l in install.splitlines()
- if "meshbay-node-user.service" in l)
- idx = install.splitlines().index(system_line)
- destination = install.splitlines()[idx + 1]
- assert "_userunitdir" in destination, (
- "the per-user unit is installed as a system unit")
+ # And each comes from the right source file — the two are one `cp` apart,
+ # so a swap would put `User=%i` where systemd will not load it.
+ for source, destination in (
+ ("packaging/systemd/meshbay-node.service",
+ "usr/lib/systemd/system/meshbay-node@.service"),
+ ("packaging/systemd/meshbay-node-user.service",
+ "usr/lib/systemd/user/meshbay-node.service"),
+ ):
+ i = stage.index(source)
+ assert destination in stage[i:i + 200], (
+ f"{source} is not staged to {destination} — check the cp pair in "
+ "build-node.sh")
def test_both_units_are_listed_in_files():