test: the managed-dashboard restart now continues the serve scan

test_user_scope_restart_never_falls_back_to_system_or_sudo asserted the
short-circuit (#92145 barrier 5) that this change deliberately removes.
Its real invariant — user scope never falls back to system scope or sudo —
is kept; the scan-continues side is now asserted instead of forbidden.
This commit is contained in:
Teknium
2026-09-01 02:25:55 -07:00
parent 5a677479e9
commit 35f4ababe1

View File

@@ -231,7 +231,15 @@ class TestKillStaleDashboardPosix:
def test_user_scope_restart_never_falls_back_to_system_or_sudo(self, capsys):
"""A user unit is discovered and restarted through ``systemctl --user``."""
"""A user unit is discovered and restarted through ``systemctl --user``.
Since #92145 the managed restart no longer ends the pass — the scan
for OTHER stale serve/dashboard backends continues (with the restarted
unit recorded in ``already_restarted_units``), so the scan being
reached is now part of the contract rather than a violation of it.
The invariant this test pins is unchanged: nothing here may touch the
system scope or sudo.
"""
calls: list[list[str]] = []
def fake_run(args, *a, **kw):
@@ -247,7 +255,7 @@ class TestKillStaleDashboardPosix:
raise AssertionError(f"unexpected subprocess.run call: {args}")
with patch("subprocess.run", side_effect=fake_run), \
patch("hermes_cli.main._find_stale_dashboard_pids", return_value=[12345]) as find_pids, \
patch("hermes_cli.main._find_stale_dashboard_pids", return_value=[]) as find_pids, \
patch("os.kill") as kill:
_kill_stale_dashboard_processes(restart_managed=True)
@@ -258,7 +266,9 @@ class TestKillStaleDashboardPosix:
["systemctl", "--user", "restart", "hermes-dashboard.service"],
]
assert all(call[:1] != ["sudo"] and call[:2] != ["systemctl"] for call in calls)
find_pids.assert_not_called()
# The pass keeps scanning for serve backends the dashboard unit does
# not own (#92145) — but with nothing stale, nothing is killed.
find_pids.assert_called_once()
kill.assert_not_called()
assert "✓ restarted hermes-dashboard.service" in capsys.readouterr().out