mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-10-26 01:34:51 +08:00
test(presets): lock OpenCode Go direct Anthropic access regression
Port the regression coverage from #6196: the Claude Code preset must keep
ANTHROPIC_API_KEY (the Go gateway's /messages endpoint only accepts
x-api-key and silently ignores Bearer), must not reintroduce
ANTHROPIC_AUTH_TOKEN, and must not require local routing. The apiFormat
assertion is adapted to the shape 16cc0d7f landed on main: native
Anthropic presets omit the field entirely.
Co-authored-by: YUZHEthefool <2804776511@qq.com>
Co-authored-by: allenxu09 <s23372.xu@stu.scie.com.cn>
This commit is contained in:
1 parent
0455a92c1f
commit
52745efe40
1 file changed
+40
@@ -1,5 +1,7 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { providerPresets } from "@/config/claudeProviderPresets";
|
||||
import type { Provider } from "@/types";
|
||||
import { providerNeedsRouting } from "@/utils/providerCapabilities";
|
||||
|
||||
describe("Kimi For Coding Provider Preset", () => {
|
||||
const kimiForCoding = providerPresets.find(
|
||||
@@ -47,6 +49,44 @@ describe("Codex Provider Preset", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("OpenCode Go Provider Preset", () => {
|
||||
const openCodeGo = providerPresets.find((p) => p.name === "OpenCode Go");
|
||||
|
||||
it("should use the Go Anthropic compatibility endpoint with x-api-key auth", () => {
|
||||
expect(openCodeGo).toBeDefined();
|
||||
|
||||
const env = (openCodeGo!.settingsConfig as any).env;
|
||||
expect(env).toMatchObject({
|
||||
ANTHROPIC_BASE_URL: "https://opencode.ai/zen/go",
|
||||
ANTHROPIC_API_KEY: "",
|
||||
ANTHROPIC_MODEL: "deepseek-v4-flash",
|
||||
ANTHROPIC_DEFAULT_HAIKU_MODEL: "deepseek-v4-flash",
|
||||
ANTHROPIC_DEFAULT_SONNET_MODEL: "deepseek-v4-flash",
|
||||
ANTHROPIC_DEFAULT_OPUS_MODEL: "deepseek-v4-flash",
|
||||
});
|
||||
// /messages 只认 x-api-key,Bearer 被网关静默忽略——勿换回 AUTH_TOKEN
|
||||
expect(env).not.toHaveProperty("ANTHROPIC_AUTH_TOKEN");
|
||||
// 原生 anthropic 直连的预设不写 apiFormat(缺省即免路由)
|
||||
expect(openCodeGo!.apiFormat).toBeUndefined();
|
||||
expect(openCodeGo!.apiKeyField).toBe("ANTHROPIC_API_KEY");
|
||||
});
|
||||
|
||||
it("should not require local routing in Claude Code", () => {
|
||||
const provider: Provider = {
|
||||
id: "opencode-go",
|
||||
name: openCodeGo!.name,
|
||||
category: openCodeGo!.category,
|
||||
settingsConfig: openCodeGo!.settingsConfig as Record<string, any>,
|
||||
meta: {
|
||||
apiFormat: openCodeGo!.apiFormat,
|
||||
apiKeyField: openCodeGo!.apiKeyField,
|
||||
},
|
||||
};
|
||||
|
||||
expect(providerNeedsRouting("claude", provider)).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("AWS Bedrock Provider Presets", () => {
|
||||
const bedrockAksk = providerPresets.find(
|
||||
(p) => p.name === "AWS Bedrock (AKSK)",
|
||||
|
||||
Reference in new issue
Block a user