Skip to content

Commit b43977c

Browse files
committed
Fix tests
1 parent f93419a commit b43977c

File tree

6 files changed

+19
-7
lines changed

6 files changed

+19
-7
lines changed

src/api/providers/__tests__/glama.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { GlamaHandler } from "../glama"
66
import { ApiHandlerOptions } from "../../../shared/api"
77

88
// Mock dependencies
9-
jest.mock("../fetchers/cache", () => ({
9+
jest.mock("../fetchers/modelCache", () => ({
1010
getModels: jest.fn().mockImplementation(() => {
1111
return Promise.resolve({
1212
"anthropic/claude-3-7-sonnet": {

src/api/providers/__tests__/openrouter.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { ApiHandlerOptions } from "../../../shared/api"
99
// Mock dependencies
1010
jest.mock("openai")
1111
jest.mock("delay", () => jest.fn(() => Promise.resolve()))
12-
jest.mock("../fetchers/cache", () => ({
12+
jest.mock("../fetchers/modelCache", () => ({
1313
getModels: jest.fn().mockImplementation(() => {
1414
return Promise.resolve({
1515
"anthropic/claude-3.7-sonnet": {

src/api/providers/__tests__/requesty.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { ApiHandlerOptions } from "../../../shared/api"
88

99
jest.mock("openai")
1010
jest.mock("delay", () => jest.fn(() => Promise.resolve()))
11-
jest.mock("../fetchers/cache", () => ({
11+
jest.mock("../fetchers/modelCache", () => ({
1212
getModels: jest.fn().mockImplementation(() => {
1313
return Promise.resolve({
1414
"coding/claude-3-7-sonnet": {

src/api/providers/__tests__/unbound.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { ApiHandlerOptions } from "../../../shared/api"
77
import { UnboundHandler } from "../unbound"
88

99
// Mock dependencies
10-
jest.mock("../fetchers/cache", () => ({
10+
jest.mock("../fetchers/modelCache", () => ({
1111
getModels: jest.fn().mockImplementation(() => {
1212
return Promise.resolve({
1313
"anthropic/claude-3-5-sonnet-20241022": {

src/api/providers/fetchers/modelEndpointCache.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,18 @@ async function readModelEndpoints(key: string): Promise<ModelRecord | undefined>
2929
return exists ? JSON.parse(await fs.readFile(filePath, "utf8")) : undefined
3030
}
3131

32-
export const getModelEndpoints = async (router: RouterName, modelId?: string): Promise<ModelRecord> => {
32+
export const getModelEndpoints = async ({
33+
router,
34+
modelId,
35+
endpoint,
36+
}: {
37+
router: RouterName
38+
modelId?: string
39+
endpoint?: string
40+
}): Promise<ModelRecord> => {
3341
// OpenRouter is the only provider that supports model endpoints, but you
3442
// can see how we'd extend this to other providers in the future.
35-
if (router !== "openrouter" || !modelId) {
43+
if (router !== "openrouter" || !modelId || !endpoint) {
3644
return {}
3745
}
3846

src/api/providers/openrouter.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,11 @@ export class OpenRouterHandler extends BaseProvider implements SingleCompletionH
172172
public async fetchModel() {
173173
const [models, endpoints] = await Promise.all([
174174
getModels("openrouter"),
175-
getModelEndpoints("openrouter", this.options.openRouterModelId),
175+
getModelEndpoints({
176+
router: "openrouter",
177+
modelId: this.options.openRouterModelId,
178+
endpoint: this.options.openRouterSpecificProvider,
179+
}),
176180
])
177181

178182
this.models = models

0 commit comments

Comments
 (0)