test: tighten model list auth fixtures

This commit is contained in:
Shakker
2026-04-29 17:00:43 +01:00
parent bfb6b82ffd
commit be1037fd34
2 changed files with 16 additions and 4 deletions

View File

@@ -11,6 +11,18 @@ const emptyStore: AuthProfileStore = {
profiles: {},
};
function modelConfig(id: string) {
return {
id,
name: id,
reasoning: false,
input: ["text" as const],
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
contextWindow: 8192,
maxTokens: 4096,
};
}
describe("createModelListAuthIndex", () => {
it("normalizes auth aliases from profiles", () => {
const index = createModelListAuthIndex({
@@ -54,7 +66,7 @@ describe("createModelListAuthIndex", () => {
api: "openai-completions",
apiKey: "sk-configured",
baseUrl: "https://custom.example/v1",
models: [{ id: "local-model" }],
models: [modelConfig("local-model")],
},
},
},
@@ -74,7 +86,7 @@ describe("createModelListAuthIndex", () => {
"local-openai": {
api: "openai-completions",
baseUrl: "http://127.0.0.1:8080/v1",
models: [{ id: "local-model" }],
models: [modelConfig("local-model")],
},
},
},

View File

@@ -82,7 +82,7 @@ async function buildRow(params: {
availableKeys: params.context.availableKeys,
allowProviderAvailabilityFallback: params.allowProviderAvailabilityFallback ?? false,
hasAuthForProvider: shouldResolveProviderAuth
? params.context.authIndex.hasProviderAuth
? (provider) => params.context.authIndex.hasProviderAuth(provider)
: undefined,
});
}
@@ -466,7 +466,7 @@ export async function appendConfiguredRows(params: {
? !params.context.discoveredKeys.has(modelKey(model.provider, model.id))
: false,
hasAuthForProvider: shouldResolveProviderAuth
? params.context.authIndex.hasProviderAuth
? (provider) => params.context.authIndex.hasProviderAuth(provider)
: undefined,
}),
);