mirror of
https://github.com/luckyyzh/pi-agent-integrated.git
synced 2026-10-03 19:19:34 +00:00
35 lines
1.2 KiB
TypeScript
35 lines
1.2 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { resolveModelSelection } from "../src/pi-harness.ts";
|
|
|
|
describe("resolveModelSelection", () => {
|
|
it("prefers an explicit harness model over environment defaults", () => {
|
|
expect(
|
|
resolveModelSelection(
|
|
{ provider: "anthropic", id: "claude-opus-4-6" },
|
|
{ PI_PROVIDER: "openai-codex", PI_MODEL: "gpt-5.6-sol" },
|
|
),
|
|
).toEqual({ provider: "anthropic", id: "claude-opus-4-6" });
|
|
});
|
|
|
|
it("uses trimmed environment defaults when the harness has no explicit model", () => {
|
|
expect(resolveModelSelection(undefined, { PI_PROVIDER: " openai-codex ", PI_MODEL: " gpt-5.6-sol " })).toEqual({
|
|
provider: "openai-codex",
|
|
id: "gpt-5.6-sol",
|
|
});
|
|
});
|
|
|
|
it.each([
|
|
[undefined, {}],
|
|
[undefined, { PI_PROVIDER: "openai-codex" }],
|
|
[undefined, { PI_MODEL: "gpt-5.6-sol" }],
|
|
[
|
|
{ provider: "", id: "gpt-5.6-sol" },
|
|
{ PI_PROVIDER: "openai-codex", PI_MODEL: "gpt-5.6-sol" },
|
|
],
|
|
] as const)("rejects an incomplete model selection", (explicitModel, environment) => {
|
|
expect(() => resolveModelSelection(explicitModel, environment)).toThrow(
|
|
"Select a harness model explicitly or set both PI_PROVIDER and PI_MODEL as defaults.",
|
|
);
|
|
});
|
|
});
|