From be4a490c237c4de3f39e73fa297f5382e8dde57f Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Mon, 16 Feb 2026 00:16:57 +0000 Subject: [PATCH] refactor(test): fix update-cli env restore --- src/cli/update-cli.test.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/cli/update-cli.test.ts b/src/cli/update-cli.test.ts index 1e1a869eac..550bbbf43e 100644 --- a/src/cli/update-cli.test.ts +++ b/src/cli/update-cli.test.ts @@ -3,6 +3,7 @@ import os from "node:os"; import path from "node:path"; import { afterAll, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; import type { UpdateRunResult } from "../infra/update-runner.js"; +import { captureEnv } from "../test-utils/env.js"; const confirm = vi.fn(); const select = vi.fn(); @@ -597,7 +598,7 @@ describe("update-cli", () => { it("updateWizardCommand offers dev checkout and forwards selections", async () => { const tempDir = await createCaseDir("openclaw-update-wizard"); - const previousGitDir = process.env.OPENCLAW_GIT_DIR; + const envSnapshot = captureEnv(["OPENCLAW_GIT_DIR"]); try { setTty(true); process.env.OPENCLAW_GIT_DIR = tempDir; @@ -627,7 +628,7 @@ describe("update-cli", () => { const call = vi.mocked(runGatewayUpdate).mock.calls[0]?.[0]; expect(call?.channel).toBe("dev"); } finally { - process.env.OPENCLAW_GIT_DIR = previousGitDir; + envSnapshot.restore(); } }); });