diff --git a/packages/coding-agent/src/cli/list-models.test.ts b/packages/coding-agent/src/cli/list-models.test.ts index b98493d8e..0e7b8a733 100644 --- a/packages/coding-agent/src/cli/list-models.test.ts +++ b/packages/coding-agent/src/cli/list-models.test.ts @@ -7,6 +7,13 @@ import { afterEach, beforeEach, describe, it } from "vitest"; import type { ModelRegistry } from "../core/model-registry.js"; import { listModels } from "./list-models.js"; +/** + * Path to a guaranteed-missing file — used to prevent tests from picking up + * the developer's real ~/.sf/agent/discovery-cache.json and thus seeing + * unexpected models in output. + */ +const NO_CACHE = join(tmpdir(), `no-discovery-cache-${process.pid}.json`); + const model = (provider: string, id: string): Model => ({ id, name: id, @@ -66,7 +73,7 @@ describe("listModels", () => { m.provider === "zai" && m.id === "glm-5.1", } as unknown as ModelRegistry; - await listModels(registry, { searchPattern: "zai" }); + await listModels(registry, { searchPattern: "zai", _discoveryCacheFilePath: NO_CACHE }); const rendered = output.join("\n"); assert.match(rendered, /glm-5\.1/); @@ -91,7 +98,7 @@ describe("listModels", () => { isDiscovered: () => false, } as unknown as ModelRegistry; - await listModels(registry, { discover: true }); + await listModels(registry, { discover: true, _discoveryCacheFilePath: NO_CACHE }); const rendered = output.join("\n"); assert.doesNotMatch(rendered, /zai/);