fix(cli): mock systemd preflight in gateway service tests for non-systemd environments (#15187)

Mock _preflight_user_systemd and _select_systemd_scope in
test_systemd_start_refreshes_outdated_unit and
test_systemd_restart_refreshes_outdated_unit. These tests target
unit-file refresh logic, not D-Bus reachability, so the preflight
check was causing spurious UserSystemdUnavailableError on macOS,
WSL, and Docker where systemd is unavailable.
This commit is contained in:
Tranquil-Flow 2026-04-25 08:53:10 +10:00
parent 00c3d848d8
commit 2eab04fd84

View file

@ -44,6 +44,10 @@ class TestSystemdServiceRefresh:
monkeypatch.setattr(gateway_cli, "get_systemd_unit_path", lambda system=False: unit_path)
monkeypatch.setattr(gateway_cli, "generate_systemd_unit", lambda system=False, run_as_user=None: "new unit\n")
# Bypass systemd availability checks — this test targets unit-file
# refresh logic, not D-Bus reachability (fails on macOS/WSL/Docker).
monkeypatch.setattr(gateway_cli, "_preflight_user_systemd", lambda **kw: None)
monkeypatch.setattr(gateway_cli, "_select_systemd_scope", lambda system=False: False)
calls = []
@ -67,6 +71,10 @@ class TestSystemdServiceRefresh:
monkeypatch.setattr(gateway_cli, "get_systemd_unit_path", lambda system=False: unit_path)
monkeypatch.setattr(gateway_cli, "generate_systemd_unit", lambda system=False, run_as_user=None: "new unit\n")
# Bypass systemd availability checks — this test targets unit-file
# refresh logic, not D-Bus reachability (fails on macOS/WSL/Docker).
monkeypatch.setattr(gateway_cli, "_preflight_user_systemd", lambda **kw: None)
monkeypatch.setattr(gateway_cli, "_select_systemd_scope", lambda system=False: False)
calls = []