|
1 | | -import assert from "node:assert/strict"; |
| 1 | +import { describe, expect, it } from "vitest"; |
2 | 2 |
|
3 | | -import { describe, it, vi } from "vitest"; |
| 3 | +import { DEFAULT_OPENCODE_MODEL_CAPABILITIES, flattenOpenCodeModels } from "./opencodeRuntime.ts"; |
4 | 4 |
|
5 | | -const childProcessMock = vi.hoisted(() => ({ |
6 | | - execFileSync: vi.fn((command: string, args: ReadonlyArray<string>) => { |
7 | | - if (command === "which" && args[0] === "opencode") { |
8 | | - return "/opt/homebrew/bin/opencode\n"; |
9 | | - } |
10 | | - return ""; |
11 | | - }), |
12 | | - spawn: vi.fn(), |
13 | | -})); |
14 | | - |
15 | | -vi.mock("node:child_process", () => childProcessMock); |
16 | | - |
17 | | -describe("resolveOpenCodeBinaryPath", () => { |
18 | | - it("returns absolute binary paths without PATH lookup", async () => { |
19 | | - const { resolveOpenCodeBinaryPath } = await import("./opencodeRuntime.ts"); |
20 | | - |
21 | | - assert.equal(resolveOpenCodeBinaryPath("/usr/local/bin/opencode"), "/usr/local/bin/opencode"); |
22 | | - assert.equal(childProcessMock.execFileSync.mock.calls.length, 0); |
23 | | - }); |
24 | | - |
25 | | - it("resolves command names through PATH", async () => { |
26 | | - const { resolveOpenCodeBinaryPath } = await import("./opencodeRuntime.ts"); |
| 5 | +describe("flattenOpenCodeModels", () => { |
| 6 | + it("keeps the canonical model name separate from the subprovider label", () => { |
| 7 | + const models = flattenOpenCodeModels({ |
| 8 | + providerList: { |
| 9 | + connected: ["github-copilot"], |
| 10 | + all: [ |
| 11 | + { |
| 12 | + id: "github-copilot", |
| 13 | + name: "GitHub Copilot", |
| 14 | + models: { |
| 15 | + "claude-opus-4.5": { |
| 16 | + id: "claude-opus-4.5", |
| 17 | + name: "Claude Opus 4.5", |
| 18 | + variants: {}, |
| 19 | + }, |
| 20 | + }, |
| 21 | + }, |
| 22 | + ], |
| 23 | + }, |
| 24 | + agents: [], |
| 25 | + } as unknown as Parameters<typeof flattenOpenCodeModels>[0]); |
27 | 26 |
|
28 | | - assert.equal(resolveOpenCodeBinaryPath("opencode"), "/opt/homebrew/bin/opencode"); |
29 | | - assert.deepEqual(childProcessMock.execFileSync.mock.calls[0], [ |
30 | | - "which", |
31 | | - ["opencode"], |
| 27 | + expect(models).toEqual([ |
32 | 28 | { |
33 | | - encoding: "utf8", |
34 | | - timeout: 3_000, |
| 29 | + slug: "github-copilot/claude-opus-4.5", |
| 30 | + name: "Claude Opus 4.5", |
| 31 | + subProvider: "GitHub Copilot", |
| 32 | + isCustom: false, |
| 33 | + capabilities: DEFAULT_OPENCODE_MODEL_CAPABILITIES, |
35 | 34 | }, |
36 | 35 | ]); |
37 | 36 | }); |
|
0 commit comments