Files
openclaw/src/agents/models-config.providers.kilocode.test.ts
Josh Lehman adc329b26b test: dedupe extension-owned coverage (#58554)
* test: dedupe extension-owned coverage

* test: remove duplicate coverage files

* test: move helper coverage into extensions

* test: trim duplicate helper assertions

* test: remove cloudflare helper import from agent test

* test: align stale expectations with current main
2026-03-31 15:18:29 -07:00

58 lines
2.0 KiB
TypeScript

import { mkdtempSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { describe, expect, it } from "vitest";
import { captureEnv } from "../test-utils/env.js";
import { resolveImplicitProvidersForTest } from "./models-config.e2e-harness.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"; // pragma: allowlist secret
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"; // pragma: allowlist secret
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();
}
});
});