Problem. src/daemonState.ts has no isolated unit tests, yet it backs the shared-mode auto-connect story (--shared, daemon --status, daemon --stop). Untested edge-case logic:
pidAlive — the EPERM branch (process exists but not signalable) should count as alive.
readDaemonState — JSON parse + schema validation (malformed/partial state file → null).
httpReachable — timeout and connection-error paths.
A regression here silently breaks all of shared mode, and the cockpit selftest doesn't cover it.
Proposed. Add test/daemonState.test.ts (bun test) exercising those branches with injected fs/probe seams (mirroring the style of the existing pure-logic tests).
Affected: src/daemonState.ts, new test/daemonState.test.ts.
Filed from the weekly repo audit.
Problem.
src/daemonState.tshas no isolated unit tests, yet it backs the shared-mode auto-connect story (--shared,daemon --status,daemon --stop). Untested edge-case logic:pidAlive— theEPERMbranch (process exists but not signalable) should count as alive.readDaemonState— JSON parse + schema validation (malformed/partial state file → null).httpReachable— timeout and connection-error paths.A regression here silently breaks all of shared mode, and the cockpit selftest doesn't cover it.
Proposed. Add
test/daemonState.test.ts(bun test) exercising those branches with injected fs/probe seams (mirroring the style of the existing pure-logic tests).Affected:
src/daemonState.ts, newtest/daemonState.test.ts.Filed from the weekly repo audit.