test: preserve daemon coverage env scope

This commit is contained in:
Shakker
2026-06-25 09:56:16 +01:00
parent 2b8c089b76
commit d693b70bfc

View File

@@ -4,7 +4,7 @@ import os from "node:os";
import path from "node:path";
import { Command } from "commander";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import { captureEnv } from "../test-utils/env.js";
import { captureEnv, deleteTestEnvValue, setTestEnvValue } from "../test-utils/env.js";
import { registerDaemonCli } from "./daemon-cli/register.js";
const probeGatewayStatus = vi.fn(async (..._args: unknown[]) => ({ ok: true }));
@@ -191,10 +191,10 @@ describe("daemon-cli coverage", () => {
"OPENCLAW_GATEWAY_PORT",
"OPENCLAW_PROFILE",
]);
process.env.OPENCLAW_STATE_DIR = tmpDir;
process.env.OPENCLAW_CONFIG_PATH = path.join(tmpDir, "openclaw.json");
delete process.env.OPENCLAW_GATEWAY_PORT;
delete process.env.OPENCLAW_PROFILE;
setTestEnvValue("OPENCLAW_STATE_DIR", tmpDir);
setTestEnvValue("OPENCLAW_CONFIG_PATH", path.join(tmpDir, "openclaw.json"));
deleteTestEnvValue("OPENCLAW_GATEWAY_PORT");
deleteTestEnvValue("OPENCLAW_PROFILE");
serviceReadCommand.mockResolvedValue(null);
resolveGatewayProbeAuthSafeWithSecretInputs.mockClear();
findExtraGatewayServices.mockClear();