
























@@ -9,6 +9,7 @@ import {
99upsertApiKeyProfile,
1010writeOAuthCredentials,
1111} from "../plugins/provider-auth-helpers.js";
12+import { setTestEnvValue } from "../test-utils/env.js";
1213import {
1314createAuthTestLifecycle,
1415readAuthProfilesForAgent,
@@ -162,7 +163,8 @@ describe("writeOAuthCredentials", () => {
162163163164it("writes OAuth credentials to all sibling agent dirs when syncSiblingAgents=true", async () => {
164165tempStateDir = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-oauth-sync-"));
165-process.env.OPENCLAW_STATE_DIR = tempStateDir;
166+lifecycle.setStateDir(tempStateDir);
167+setTestEnvValue("OPENCLAW_STATE_DIR", tempStateDir);
166168167169const mainAgentDir = path.join(tempStateDir, "agents", "main", "agent");
168170const kidAgentDir = path.join(tempStateDir, "agents", "kid", "agent");
@@ -171,7 +173,7 @@ describe("writeOAuthCredentials", () => {
171173await fs.mkdir(kidAgentDir, { recursive: true });
172174await fs.mkdir(workerAgentDir, { recursive: true });
173175174-process.env.OPENCLAW_AGENT_DIR = kidAgentDir;
176+setTestEnvValue("OPENCLAW_AGENT_DIR", kidAgentDir);
175177176178const creds = {
177179refresh: "refresh-sync",
@@ -198,14 +200,15 @@ describe("writeOAuthCredentials", () => {
198200199201it("writes OAuth credentials only to target dir by default", async () => {
200202tempStateDir = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-oauth-nosync-"));
201-process.env.OPENCLAW_STATE_DIR = tempStateDir;
203+lifecycle.setStateDir(tempStateDir);
204+setTestEnvValue("OPENCLAW_STATE_DIR", tempStateDir);
202205203206const mainAgentDir = path.join(tempStateDir, "agents", "main", "agent");
204207const kidAgentDir = path.join(tempStateDir, "agents", "kid", "agent");
205208await fs.mkdir(mainAgentDir, { recursive: true });
206209await fs.mkdir(kidAgentDir, { recursive: true });
207210208-process.env.OPENCLAW_AGENT_DIR = kidAgentDir;
211+setTestEnvValue("OPENCLAW_AGENT_DIR", kidAgentDir);
209212210213const creds = {
211214refresh: "refresh-kid",
@@ -229,7 +232,8 @@ describe("writeOAuthCredentials", () => {
229232230233it("syncs siblings from explicit agentDir outside OPENCLAW_STATE_DIR", async () => {
231234tempStateDir = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-oauth-external-"));
232-process.env.OPENCLAW_STATE_DIR = tempStateDir;
235+lifecycle.setStateDir(tempStateDir);
236+setTestEnvValue("OPENCLAW_STATE_DIR", tempStateDir);
233237234238// Create standard-layout agents tree *outside* OPENCLAW_STATE_DIR
235239const externalRoot = path.join(tempStateDir, "external", "agents");
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。