Skip to content

Commit 93192bb

Browse files
committed
test(doctor): satisfy lint for session lock checks
1 parent 1da1d68 commit 93192bb

2 files changed

Lines changed: 22 additions & 11 deletions

File tree

src/commands/doctor-session-locks.test.ts

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -153,15 +153,18 @@ describe("noteSessionLockHealth", () => {
153153
staleMs: 30_000,
154154
readOwnerProcessArgs: () => ["node", "/opt/openclaw/openclaw.mjs", "doctor"],
155155
});
156+
if (!lock) {
157+
throw new Error("expected stale session lock");
158+
}
156159

157-
expect(sessionLockToHealthFinding(lock!)).toEqual(
160+
expect(sessionLockToHealthFinding(lock)).toEqual(
158161
expect.objectContaining({
159162
checkId: "core/doctor/session-locks",
160163
severity: "warning",
161164
path: lockPath,
162165
}),
163166
);
164-
expect(sessionLockToRepairEffect(lock!)).toEqual({
167+
expect(sessionLockToRepairEffect(lock)).toEqual({
165168
kind: "state",
166169
action: "would-remove-stale-session-lock",
167170
target: lockPath,
@@ -180,11 +183,14 @@ describe("noteSessionLockHealth", () => {
180183
staleMs: 30_000,
181184
readOwnerProcessArgs: () => ["node", "/opt/openclaw/openclaw.mjs", "doctor"],
182185
});
186+
if (!lock) {
187+
throw new Error("expected stale session lock");
188+
}
183189

184-
expect(lock?.staleReasons).toEqual(["missing-pid", "invalid-createdAt"]);
185-
expect(lock?.removable).toBe(false);
186-
expect(sessionLockToHealthFinding(lock!).fixHint).toContain("after the cleanup grace period");
187-
expect(sessionLockToRepairEffect(lock!)).toEqual({
190+
expect(lock.staleReasons).toEqual(["missing-pid", "invalid-createdAt"]);
191+
expect(lock.removable).toBe(false);
192+
expect(sessionLockToHealthFinding(lock).fixHint).toContain("after the cleanup grace period");
193+
expect(sessionLockToRepairEffect(lock)).toEqual({
188194
kind: "state",
189195
action: "would-preserve-mtime-gated-stale-session-lock",
190196
target: malformedLock,
@@ -235,12 +241,15 @@ describe("noteSessionLockHealth", () => {
235241
staleMs: 30_000,
236242
readOwnerProcessArgs: () => ["node", "/opt/openclaw/openclaw.mjs", "doctor"],
237243
});
244+
if (!lock) {
245+
throw new Error("expected stale session lock");
246+
}
238247

239-
expect(lock?.staleReasons).toEqual(["too-old"]);
240-
expect(sessionLockToHealthFinding(lock!).fixHint).toBe(
248+
expect(lock.staleReasons).toEqual(["too-old"]);
249+
expect(sessionLockToHealthFinding(lock).fixHint).toBe(
241250
"OpenClaw is preserving this live owned lock; inspect the owning process if it appears stuck.",
242251
);
243-
expect(sessionLockToRepairEffect(lock!)).toEqual({
252+
expect(sessionLockToRepairEffect(lock)).toEqual({
244253
kind: "state",
245254
action: "would-preserve-report-only-stale-session-lock",
246255
target: reportOnlyLock,

src/flows/doctor-core-checks.test.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -752,9 +752,11 @@ describe("CORE_HEALTH_CHECKS", () => {
752752
it("registers stale session locks as a legacy-owned structured check", async () => {
753753
const check = getCheck(createCoreHealthChecks(createDeps()), "core/doctor/session-locks");
754754

755-
expect(check.repair).toBeTypeOf("function");
755+
if (typeof check.repair !== "function") {
756+
throw new Error("expected session lock check repair");
757+
}
756758
await expect(
757-
check.repair?.(
759+
check.repair(
758760
{
759761
mode: "fix",
760762
runtime,

0 commit comments

Comments
 (0)