























@@ -2,6 +2,7 @@ import fs from "node:fs";
22import os from "node:os";
33import path from "node:path";
44import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
5+import { clearRuntimeAuthProfileStoreSnapshots, ensureAuthProfileStore } from "./auth-profiles.js";
56import { AUTH_STORE_VERSION } from "./auth-profiles/constants.js";
67import type { OAuthCredential } from "./auth-profiles/types.js";
78@@ -19,15 +20,6 @@ vi.mock("../plugins/provider-runtime.js", () => ({
1920resolveExternalAuthProfilesWithPlugins: () => [],
2021}));
212222-let clearRuntimeAuthProfileStoreSnapshots: typeof import("./auth-profiles.js").clearRuntimeAuthProfileStoreSnapshots;
23-let ensureAuthProfileStore: typeof import("./auth-profiles.js").ensureAuthProfileStore;
24-25-async function loadFreshAuthProfilesModuleForTest() {
26-vi.resetModules();
27-({ clearRuntimeAuthProfileStoreSnapshots, ensureAuthProfileStore } =
28-await import("./auth-profiles.js"));
29-}
30-3123async function withAgentDirEnv(prefix: string, run: (agentDir: string) => void | Promise<void>) {
3224const agentDir = fs.mkdtempSync(path.join(os.tmpdir(), prefix));
3325const previousAgentDir = process.env.OPENCLAW_AGENT_DIR;
@@ -75,14 +67,15 @@ function writeAuthStore(agentDir: string, key: string) {
7567}
76687769describe("auth profile store cache", () => {
78-beforeEach(async () => {
79-await loadFreshAuthProfilesModuleForTest();
70+beforeEach(() => {
71+clearRuntimeAuthProfileStoreSnapshots();
72+mocks.resolveExternalCliAuthProfiles.mockReset();
73+mocks.resolveExternalCliAuthProfiles.mockReturnValue([]);
8074});
81758276afterEach(() => {
8377vi.useRealTimers();
8478clearRuntimeAuthProfileStoreSnapshots();
85-vi.clearAllMocks();
8679});
87808881function createRuntimeOnlyOverlay(access: string): RuntimeOnlyOverlay {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。