Skip to content

Claude Code. Any Model. The most powerful AI coding agent now speaks every language.

test: an empty catalog means no-route, not a guessed chain

Jack Rudenko008c494c354f
diff --git a/packages/cli/src/providers/routing-rules.test.ts b/packages/cli/src/providers/routing-rules.test.ts
index 4db4d6a1..8447a7b6 100644
--- a/packages/cli/src/providers/routing-rules.test.ts
+++ b/packages/cli/src/providers/routing-rules.test.ts
@@ -689,26 +689,16 @@ describe("route()", () => {
expect(plan.primary.provider).toBe("openai");
});
- test("gpt-5 (bare) with OPENAI_CODEX_API_KEY → primary openai-codex", async () => {
- // Assert rule composition with an empty catalog (an absent cache file),
- // not Codex model support: live Codex returns 400 with "The 'gpt-5' model
- // is not supported when using Codex with a ChatGPT account".
- //
- // In a dev environment where codex-oauth.json exists, codex is genuinely
- // credentialed regardless of the fake env key. Skip the strict assertion
- // there, matching the sibling credential test. openai-codex declares no
- // modelDiscovery, so only the catalog cache, not live discovery, is a factor.
- const codexOauth = join(homedir(), ".claudish", "codex-oauth.json");
- if (existsSync(codexOauth)) return;
-
+ test("gpt-5 (bare) with OPENAI_CODEX_API_KEY and no catalog → no-route", async () => {
const dir = mkdtempSync(join(tmpdir(), "claudish-routing-empty-catalog-test-"));
const cachePath = join(dir, "all-models.json");
try {
process.env.OPENAI_CODEX_API_KEY = "sk-codex-test";
const plan = await route("gpt-5", {}, undefined, cachePath);
- expect(plan.kind).toBe("ok");
- if (plan.kind !== "ok") return;
- expect(plan.primary.provider).toBe("openai-codex");
+ expect(plan.kind).toBe("no-route");
+ if (plan.kind !== "no-route") return;
+ expect(plan.reason).toContain("No model catalog available");
+ expect(plan.hint).toContain("claudish --models-refresh");
} finally {
rmSync(dir, { recursive: true, force: true });
}
@@ -966,18 +956,7 @@ describe("route()", () => {
expect(plan.kind).toBe("no-route");
});
- test("ok plan returns primary plus fallbacks in order", async () => {
- // Assert rule composition with an empty catalog (an absent cache file),
- // not Codex model support: live Codex returns 400 with "The 'gpt-5' model
- // is not supported when using Codex with a ChatGPT account".
- //
- // In a dev environment where codex-oauth.json exists, codex is genuinely
- // credentialed regardless of the fake env key. Skip the strict assertion
- // there, matching the sibling credential test. openai-codex declares no
- // modelDiscovery, so only the catalog cache, not live discovery, is a factor.
- const codexOauth = join(homedir(), ".claudish", "codex-oauth.json");
- if (existsSync(codexOauth)) return;
-
+ test("gpt-5 (bare) with all fallback credentials and no catalog → no-route", async () => {
const dir = mkdtempSync(join(tmpdir(), "claudish-routing-empty-catalog-test-"));
const cachePath = join(dir, "all-models.json");
try {
@@ -985,10 +964,10 @@ describe("route()", () => {
process.env.OPENAI_API_KEY = "oai-test";
process.env.OPENROUTER_API_KEY = "or-test";
const plan = await route("gpt-5", {}, undefined, cachePath);
- expect(plan.kind).toBe("ok");
- if (plan.kind !== "ok") return;
- expect(plan.primary.provider).toBe("openai-codex");
- expect(plan.fallbacks.map((r) => r.provider)).toEqual(["openai", "openrouter"]);
+ expect(plan.kind).toBe("no-route");
+ if (plan.kind !== "no-route") return;
+ expect(plan.reason).toContain("No model catalog available");
+ expect(plan.hint).toContain("claudish --models-refresh");
} finally {
rmSync(dir, { recursive: true, force: true });
}