mirror of
https://github.com/moltbot/moltbot.git
synced 2026-04-20 21:23:23 +00:00
test: keep kilocode provider tests on plugin-owned helpers
This commit is contained in:
@@ -1,57 +1,12 @@
|
||||
import { mkdtempSync } from "node:fs";
|
||||
import { tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
import { captureEnv } from "openclaw/plugin-sdk/testing";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { resolveImplicitProvidersForTest } from "../../src/agents/models-config.e2e-harness.js";
|
||||
import { buildKilocodeProvider } from "./provider-catalog.js";
|
||||
|
||||
describe("Kilo Gateway implicit provider", () => {
|
||||
it("should include kilocode when KILOCODE_API_KEY is configured", async () => {
|
||||
const agentDir = mkdtempSync(join(tmpdir(), "openclaw-test-"));
|
||||
const envSnapshot = captureEnv(["KILOCODE_API_KEY"]);
|
||||
process.env.KILOCODE_API_KEY = "test-key";
|
||||
it("publishes the Kilo static provider catalog used by implicit provider setup", () => {
|
||||
const provider = buildKilocodeProvider();
|
||||
|
||||
try {
|
||||
const providers = await resolveImplicitProvidersForTest({ agentDir });
|
||||
expect(providers?.kilocode).toBeDefined();
|
||||
expect(providers?.kilocode?.models?.length).toBeGreaterThan(0);
|
||||
} finally {
|
||||
envSnapshot.restore();
|
||||
}
|
||||
});
|
||||
|
||||
it("should not include kilocode when no API key is configured", async () => {
|
||||
const agentDir = mkdtempSync(join(tmpdir(), "openclaw-test-"));
|
||||
const envSnapshot = captureEnv(["KILOCODE_API_KEY"]);
|
||||
delete process.env.KILOCODE_API_KEY;
|
||||
|
||||
try {
|
||||
const providers = await resolveImplicitProvidersForTest({ agentDir });
|
||||
expect(providers?.kilocode).toBeUndefined();
|
||||
} finally {
|
||||
envSnapshot.restore();
|
||||
}
|
||||
});
|
||||
|
||||
it("should preserve an explicit kilocode provider override", async () => {
|
||||
const agentDir = mkdtempSync(join(tmpdir(), "openclaw-test-"));
|
||||
const envSnapshot = captureEnv(["KILOCODE_API_KEY"]);
|
||||
process.env.KILOCODE_API_KEY = "test-key";
|
||||
|
||||
try {
|
||||
const providers = await resolveImplicitProvidersForTest({
|
||||
agentDir,
|
||||
explicitProviders: {
|
||||
kilocode: {
|
||||
baseUrl: "https://proxy.example.com/v1",
|
||||
api: "openai-completions",
|
||||
models: [],
|
||||
},
|
||||
},
|
||||
});
|
||||
expect(providers?.kilocode?.baseUrl).toBe("https://proxy.example.com/v1");
|
||||
} finally {
|
||||
envSnapshot.restore();
|
||||
}
|
||||
expect(provider.baseUrl).toBe("https://api.kilo.ai/api/gateway/");
|
||||
expect(provider.api).toBe("openai-completions");
|
||||
expect(provider.models?.length).toBeGreaterThan(0);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
import { mkdtempSync } from "node:fs";
|
||||
import { tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
import type { OpenClawConfig } from "openclaw/plugin-sdk/config-runtime";
|
||||
import {
|
||||
resolveApiKeyForProvider,
|
||||
resolveEnvApiKey,
|
||||
} from "openclaw/plugin-sdk/provider-auth-runtime";
|
||||
import { resolveEnvApiKey } from "openclaw/plugin-sdk/provider-auth-runtime";
|
||||
import { resolveAgentModelPrimaryValue } from "openclaw/plugin-sdk/provider-onboard";
|
||||
import { captureEnv } from "openclaw/plugin-sdk/testing";
|
||||
import { describe, expect, it } from "vitest";
|
||||
@@ -172,24 +166,5 @@ describe("Kilo Gateway provider config", () => {
|
||||
envSnapshot.restore();
|
||||
}
|
||||
});
|
||||
|
||||
it("resolves the kilocode api key via resolveApiKeyForProvider", async () => {
|
||||
const agentDir = mkdtempSync(join(tmpdir(), "openclaw-test-"));
|
||||
const envSnapshot = captureEnv(["KILOCODE_API_KEY"]);
|
||||
process.env.KILOCODE_API_KEY = "kilo-provider-test-key";
|
||||
|
||||
try {
|
||||
const auth = await resolveApiKeyForProvider({
|
||||
provider: "kilocode",
|
||||
agentDir,
|
||||
});
|
||||
|
||||
expect(auth.apiKey).toBe("kilo-provider-test-key");
|
||||
expect(auth.mode).toBe("api-key");
|
||||
expect(auth.source).toContain("KILOCODE_API_KEY");
|
||||
} finally {
|
||||
envSnapshot.restore();
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user