47 lines
1.4 KiB
Python
47 lines
1.4 KiB
Python
from __future__ import annotations
|
|
|
|
import plistlib
|
|
from pathlib import Path
|
|
|
|
from k1link.local_service_launchd import plan_mission_core_launch_agent
|
|
|
|
|
|
def test_launch_agent_plan_disables_sync_and_enables_watchdog(tmp_path: Path) -> None:
|
|
repository = tmp_path / "repo"
|
|
repository.mkdir()
|
|
uv_entrypoint = tmp_path / "uv"
|
|
uv_entrypoint.write_text("#!/bin/sh\n")
|
|
uv_entrypoint.chmod(0o700)
|
|
agent = tmp_path / "agent.plist"
|
|
agent.write_bytes(
|
|
plistlib.dumps(
|
|
{
|
|
"Label": "com.nodedc.mission-core.local",
|
|
"ProgramArguments": [str(uv_entrypoint), "run", "k1link", "serve"],
|
|
"WorkingDirectory": str(repository),
|
|
"EnvironmentVariables": {"PATH": "/usr/bin:/bin"},
|
|
}
|
|
)
|
|
)
|
|
agent.chmod(0o600)
|
|
|
|
plan = plan_mission_core_launch_agent(
|
|
repository_root=repository,
|
|
agent_path=agent,
|
|
)
|
|
desired = plistlib.loads(plan.desired_payload)
|
|
|
|
assert desired["ProgramArguments"] == [
|
|
str(uv_entrypoint),
|
|
"run",
|
|
"--no-sync",
|
|
"k1link",
|
|
"serve",
|
|
]
|
|
assert desired["EnvironmentVariables"]["MISSIONCORE_SERVICE_WATCHDOG"] == "1"
|
|
assert desired["KeepAlive"] is True
|
|
assert desired["RunAtLoad"] is True
|
|
assert desired["AbandonProcessGroup"] is False
|
|
assert desired["ExitTimeOut"] == 20
|
|
assert plan.current_sha256 != plan.desired_sha256
|