From a0840cad8fb3cae023fd4652b58c1a83d8e67815 Mon Sep 17 00:00:00 2001 From: Shakker Date: Fri, 5 Jun 2026 16:43:32 +0100 Subject: [PATCH] test: scope restart sentinel state env --- src/infra/restart-sentinel.test.ts | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/infra/restart-sentinel.test.ts b/src/infra/restart-sentinel.test.ts index afecd19886a8..416d0814f85d 100644 --- a/src/infra/restart-sentinel.test.ts +++ b/src/infra/restart-sentinel.test.ts @@ -3,7 +3,7 @@ import fs from "node:fs/promises"; import path from "node:path"; import { describe, expect, it } from "vitest"; import { withTempDir } from "../test-helpers/temp-dir.js"; -import { captureEnv } from "../test-utils/env.js"; +import { withEnvAsync } from "../test-utils/env.js"; import { buildRestartSuccessContinuation, consumeRestartSentinel, @@ -25,15 +25,9 @@ import { import { buildUpdateRestartSentinelPayload } from "./update-restart-sentinel-payload.js"; async function withRestartSentinelStateDir(run: () => Promise): Promise { - const envSnapshot = captureEnv(["OPENCLAW_STATE_DIR"]); - try { - await withTempDir({ prefix: "openclaw-sentinel-" }, async (tempDir) => { - process.env.OPENCLAW_STATE_DIR = tempDir; - await run(); - }); - } finally { - envSnapshot.restore(); - } + await withTempDir({ prefix: "openclaw-sentinel-" }, async (tempDir) => { + await withEnvAsync({ OPENCLAW_STATE_DIR: tempDir }, run); + }); } async function expectPathMissing(targetPath: string): Promise {