mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-26 20:35:39 -06:00
test: scope post-attach sentinel env
This commit is contained in:
@@ -563,15 +563,19 @@ describe("startGatewayPostAttachRuntime", () => {
|
||||
|
||||
it("skips heavy restart sentinel refresh when no sentinel file exists", async () => {
|
||||
const stateDir = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-no-sentinel-"));
|
||||
vi.stubEnv("OPENCLAW_STATE_DIR", stateDir);
|
||||
hoisted.refreshLatestUpdateRestartSentinel.mockClear();
|
||||
try {
|
||||
await withEnvAsync({ OPENCLAW_STATE_DIR: stateDir }, async () => {
|
||||
hoisted.refreshLatestUpdateRestartSentinel.mockClear();
|
||||
|
||||
const result = await testing.refreshLatestUpdateRestartSentinelIfPresent();
|
||||
const result = await testing.refreshLatestUpdateRestartSentinelIfPresent();
|
||||
|
||||
expect(result).toBeNull();
|
||||
expect(hoisted.refreshLatestUpdateRestartSentinel).not.toHaveBeenCalled();
|
||||
closeOpenClawStateDatabaseForTest();
|
||||
fs.rmSync(stateDir, { recursive: true, force: true });
|
||||
expect(result).toBeNull();
|
||||
expect(hoisted.refreshLatestUpdateRestartSentinel).not.toHaveBeenCalled();
|
||||
});
|
||||
} finally {
|
||||
closeOpenClawStateDatabaseForTest();
|
||||
fs.rmSync(stateDir, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
|
||||
it("refreshes the restart sentinel when the sentinel row exists", async () => {
|
||||
@@ -585,15 +589,16 @@ describe("startGatewayPostAttachRuntime", () => {
|
||||
},
|
||||
{ OPENCLAW_STATE_DIR: stateDir } as NodeJS.ProcessEnv,
|
||||
);
|
||||
vi.stubEnv("OPENCLAW_STATE_DIR", stateDir);
|
||||
const sentinel = { kind: "update", status: "ok", ts: 1 } as const;
|
||||
hoisted.refreshLatestUpdateRestartSentinel.mockClear();
|
||||
hoisted.refreshLatestUpdateRestartSentinel.mockResolvedValue(sentinel);
|
||||
await withEnvAsync({ OPENCLAW_STATE_DIR: stateDir }, async () => {
|
||||
const sentinel = { kind: "update", status: "ok", ts: 1 } as const;
|
||||
hoisted.refreshLatestUpdateRestartSentinel.mockClear();
|
||||
hoisted.refreshLatestUpdateRestartSentinel.mockResolvedValue(sentinel);
|
||||
|
||||
const result = await testing.refreshLatestUpdateRestartSentinelIfPresent();
|
||||
const result = await testing.refreshLatestUpdateRestartSentinelIfPresent();
|
||||
|
||||
expect(result).toBe(sentinel);
|
||||
expect(hoisted.refreshLatestUpdateRestartSentinel).toHaveBeenCalledOnce();
|
||||
expect(result).toBe(sentinel);
|
||||
expect(hoisted.refreshLatestUpdateRestartSentinel).toHaveBeenCalledOnce();
|
||||
});
|
||||
} finally {
|
||||
closeOpenClawStateDatabaseForTest();
|
||||
fs.rmSync(stateDir, { recursive: true, force: true });
|
||||
|
||||
Reference in New Issue
Block a user