@@ -563,15 +563,19 @@ describe("startGatewayPostAttachRuntime", () => {
|
563 | 563 | |
564 | 564 | it("skips heavy restart sentinel refresh when no sentinel file exists", async () => { |
565 | 565 | const stateDir = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-no-sentinel-")); |
566 | | -vi.stubEnv("OPENCLAW_STATE_DIR", stateDir); |
567 | | -hoisted.refreshLatestUpdateRestartSentinel.mockClear(); |
| 566 | +try { |
| 567 | +await withEnvAsync({ OPENCLAW_STATE_DIR: stateDir }, async () => { |
| 568 | +hoisted.refreshLatestUpdateRestartSentinel.mockClear(); |
568 | 569 | |
569 | | -const result = await testing.refreshLatestUpdateRestartSentinelIfPresent(); |
| 570 | + const result = await testing.refreshLatestUpdateRestartSentinelIfPresent(); |
570 | 571 | |
571 | | -expect(result).toBeNull(); |
572 | | -expect(hoisted.refreshLatestUpdateRestartSentinel).not.toHaveBeenCalled(); |
573 | | -closeOpenClawStateDatabaseForTest(); |
574 | | -fs.rmSync(stateDir, { recursive: true, force: true }); |
| 572 | +expect(result).toBeNull(); |
| 573 | +expect(hoisted.refreshLatestUpdateRestartSentinel).not.toHaveBeenCalled(); |
| 574 | +}); |
| 575 | +} finally { |
| 576 | +closeOpenClawStateDatabaseForTest(); |
| 577 | +fs.rmSync(stateDir, { recursive: true, force: true }); |
| 578 | +} |
575 | 579 | }); |
576 | 580 | |
577 | 581 | it("refreshes the restart sentinel when the sentinel row exists", async () => { |
@@ -585,15 +589,16 @@ describe("startGatewayPostAttachRuntime", () => {
|
585 | 589 | }, |
586 | 590 | { OPENCLAW_STATE_DIR: stateDir } as NodeJS.ProcessEnv, |
587 | 591 | ); |
588 | | -vi.stubEnv("OPENCLAW_STATE_DIR", stateDir); |
589 | | -const sentinel = { kind: "update", status: "ok", ts: 1 } as const; |
590 | | -hoisted.refreshLatestUpdateRestartSentinel.mockClear(); |
591 | | -hoisted.refreshLatestUpdateRestartSentinel.mockResolvedValue(sentinel); |
| 592 | +await withEnvAsync({ OPENCLAW_STATE_DIR: stateDir }, async () => { |
| 593 | + const sentinel = { kind: "update", status: "ok", ts: 1 } as const; |
| 594 | + hoisted.refreshLatestUpdateRestartSentinel.mockClear(); |
| 595 | + hoisted.refreshLatestUpdateRestartSentinel.mockResolvedValue(sentinel); |
592 | 596 | |
593 | | -const result = await testing.refreshLatestUpdateRestartSentinelIfPresent(); |
| 597 | + const result = await testing.refreshLatestUpdateRestartSentinelIfPresent(); |
594 | 598 | |
595 | | -expect(result).toBe(sentinel); |
596 | | -expect(hoisted.refreshLatestUpdateRestartSentinel).toHaveBeenCalledOnce(); |
| 599 | +expect(result).toBe(sentinel); |
| 600 | +expect(hoisted.refreshLatestUpdateRestartSentinel).toHaveBeenCalledOnce(); |
| 601 | +}); |
597 | 602 | } finally { |
598 | 603 | closeOpenClawStateDatabaseForTest(); |
599 | 604 | fs.rmSync(stateDir, { recursive: true, force: true }); |
|