mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-09 00:01:17 +00:00
60 lines
1.9 KiB
TypeScript
60 lines
1.9 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { registerSingleProviderPlugin } from "../../test/helpers/plugins/plugin-registration.js";
|
|
import anthropicVertexPlugin from "./index.js";
|
|
|
|
describe("anthropic-vertex provider plugin", () => {
|
|
it("resolves the ADC marker through the provider hook", () => {
|
|
const provider = registerSingleProviderPlugin(anthropicVertexPlugin);
|
|
|
|
expect(
|
|
provider.resolveConfigApiKey?.({
|
|
provider: "anthropic-vertex",
|
|
env: {
|
|
ANTHROPIC_VERTEX_USE_GCP_METADATA: "true",
|
|
} as NodeJS.ProcessEnv,
|
|
} as never),
|
|
).toBe("gcp-vertex-credentials");
|
|
});
|
|
|
|
it("merges the implicit Vertex catalog into explicit provider overrides", async () => {
|
|
const provider = registerSingleProviderPlugin(anthropicVertexPlugin);
|
|
|
|
const result = await provider.catalog?.run({
|
|
config: {
|
|
models: {
|
|
providers: {
|
|
"anthropic-vertex": {
|
|
baseUrl: "https://europe-west4-aiplatform.googleapis.com",
|
|
headers: { "x-test-header": "1" },
|
|
},
|
|
},
|
|
},
|
|
},
|
|
env: {
|
|
ANTHROPIC_VERTEX_USE_GCP_METADATA: "true",
|
|
GOOGLE_CLOUD_LOCATION: "us-east5",
|
|
} as NodeJS.ProcessEnv,
|
|
resolveProviderApiKey: () => ({ apiKey: undefined }),
|
|
resolveProviderAuth: () => ({
|
|
apiKey: undefined,
|
|
discoveryApiKey: undefined,
|
|
mode: "none",
|
|
source: "none",
|
|
}),
|
|
} as never);
|
|
|
|
expect(result).toEqual({
|
|
provider: {
|
|
api: "anthropic-messages",
|
|
apiKey: "gcp-vertex-credentials",
|
|
baseUrl: "https://europe-west4-aiplatform.googleapis.com",
|
|
headers: { "x-test-header": "1" },
|
|
models: [
|
|
expect.objectContaining({ id: "claude-opus-4-6" }),
|
|
expect.objectContaining({ id: "claude-sonnet-4-6" }),
|
|
],
|
|
},
|
|
});
|
|
});
|
|
});
|