mirror of
https://github.com/moltbot/moltbot.git
synced 2026-05-13 15:47:28 +00:00
test: tighten litellm setup assertions
This commit is contained in:
@@ -5,6 +5,21 @@ import { capturePluginRegistration } from "openclaw/plugin-sdk/plugin-test-runti
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import plugin from "./index.js";
|
||||
|
||||
const LITELLM_DEFAULT_MODEL = {
|
||||
id: "claude-opus-4-6",
|
||||
name: "Claude Opus 4.6",
|
||||
reasoning: true,
|
||||
input: ["text", "image"],
|
||||
cost: {
|
||||
input: 0,
|
||||
output: 0,
|
||||
cacheRead: 0,
|
||||
cacheWrite: 0,
|
||||
},
|
||||
contextWindow: 128_000,
|
||||
maxTokens: 8_192,
|
||||
};
|
||||
|
||||
function registerProvider() {
|
||||
const captured = capturePluginRegistration(plugin);
|
||||
const provider = captured.providers[0];
|
||||
@@ -43,29 +58,48 @@ describe("litellm plugin", () => {
|
||||
toApiKeyCredential,
|
||||
} as never);
|
||||
|
||||
expect(result?.models?.providers?.litellm?.baseUrl).toBe("https://litellm.example/v1");
|
||||
expect(result?.models?.providers?.litellm?.api).toBe("openai-completions");
|
||||
expect(result?.auth?.profiles?.["litellm:default"]).toEqual({
|
||||
expect(result).toStrictEqual({
|
||||
auth: {
|
||||
profiles: {
|
||||
"litellm:default": {
|
||||
provider: "litellm",
|
||||
mode: "api_key",
|
||||
},
|
||||
},
|
||||
},
|
||||
agents: {
|
||||
defaults: {
|
||||
models: {
|
||||
"litellm/claude-opus-4-6": {
|
||||
alias: "LiteLLM",
|
||||
},
|
||||
},
|
||||
model: {
|
||||
primary: "litellm/claude-opus-4-6",
|
||||
},
|
||||
},
|
||||
},
|
||||
models: {
|
||||
mode: "merge",
|
||||
providers: {
|
||||
litellm: {
|
||||
baseUrl: "https://litellm.example/v1",
|
||||
api: "openai-completions",
|
||||
models: [LITELLM_DEFAULT_MODEL],
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
expect(resolveApiKey).toHaveBeenCalledWith({
|
||||
provider: "litellm",
|
||||
mode: "api_key",
|
||||
flagValue: "litellm-test-key",
|
||||
flagName: "--litellm-api-key",
|
||||
envVar: "LITELLM_API_KEY",
|
||||
});
|
||||
expect(result?.agents?.defaults?.model).toMatchObject({
|
||||
primary: "litellm/claude-opus-4-6",
|
||||
expect(toApiKeyCredential).toHaveBeenCalledWith({
|
||||
provider: "litellm",
|
||||
resolved: { key: "litellm-test-key", source: "flag" },
|
||||
});
|
||||
expect(resolveApiKey).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
provider: "litellm",
|
||||
flagValue: "litellm-test-key",
|
||||
flagName: "--litellm-api-key",
|
||||
envVar: "LITELLM_API_KEY",
|
||||
}),
|
||||
);
|
||||
expect(toApiKeyCredential).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
provider: "litellm",
|
||||
resolved: { key: "litellm-test-key", source: "flag" },
|
||||
}),
|
||||
);
|
||||
} finally {
|
||||
rmSync(agentDir, { recursive: true, force: true });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user