




















@@ -1,7 +1,7 @@
11import fs from "node:fs/promises";
22import os from "node:os";
33import path from "node:path";
4-import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
4+import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
55import {
66buildTalkTestProviderConfig,
77TALK_TEST_PROVIDER_API_KEY_PATH,
@@ -10,6 +10,16 @@ import {
1010} from "../test-utils/talk-test-provider.js";
1111import type { SecretsApplyPlan } from "./plan.js";
121213+const { clearSecretsRuntimeSnapshotMock, prepareSecretsRuntimeSnapshotMock } = vi.hoisted(() => ({
14+clearSecretsRuntimeSnapshotMock: vi.fn(),
15+prepareSecretsRuntimeSnapshotMock: vi.fn(async () => undefined),
16+}));
17+18+vi.mock("./runtime.js", () => ({
19+clearSecretsRuntimeSnapshot: clearSecretsRuntimeSnapshotMock,
20+prepareSecretsRuntimeSnapshot: prepareSecretsRuntimeSnapshotMock,
21+}));
22+1323let runSecretsApply: typeof import("./apply.js").runSecretsApply;
1424let applyTesting: typeof import("./apply.js").__testing;
1525let clearSecretsRuntimeSnapshot: typeof import("./runtime.js").clearSecretsRuntimeSnapshot;
@@ -243,6 +253,7 @@ describe("secrets apply", () => {
243253});
244254245255beforeEach(async () => {
256+prepareSecretsRuntimeSnapshotMock.mockClear();
246257clearSecretsRuntimeSnapshot();
247258fixture = await createApplyFixture();
248259await seedDefaultApplyFixture(fixture);
@@ -268,6 +279,7 @@ describe("secrets apply", () => {
268279const applied = await runSecretsApply({ plan, env: fixture.env, write: true });
269280expect(applied.mode).toBe("write");
270281expect(applied.changed).toBe(true);
282+expect(prepareSecretsRuntimeSnapshotMock).toHaveBeenCalledTimes(1);
271283272284const nextConfig = JSON.parse(await fs.readFile(fixture.configPath, "utf8")) as {
273285models: { providers: { openai: { apiKey: unknown } } };
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。