test(coding-agent): updated model cache tests to resolve provider ids

- Import and use `resolveModelCacheProviderId` for github-copilot in model discovery and cache header tests.
This commit is contained in:
can1357
2026-08-14 07:31:12 +02:00
parent a821f4316a
commit 1e1ee2c330
2 changed files with 9 additions and 5 deletions
@@ -8,7 +8,7 @@ import type { OAuthCredentials } from "@oh-my-pi/pi-ai/oauth/types";
import { buildModel } from "@oh-my-pi/pi-catalog/build";
import { writeModelCache } from "@oh-my-pi/pi-catalog/model-cache";
import { getBundledModel } from "@oh-my-pi/pi-catalog/models";
import { resolveOllamaModelCacheProviderId } from "@oh-my-pi/pi-catalog/provider-models";
import { resolveModelCacheProviderId, resolveOllamaModelCacheProviderId } from "@oh-my-pi/pi-catalog/provider-models";
import type { ModelSpec, OpenAICompat } from "@oh-my-pi/pi-catalog/types";
import {
applyLlamaCppQwenThinking,
@@ -2562,9 +2562,10 @@ providers:
});
// Emulate a legacy write: the variant has no same-id static header source,
// so it is flagged unrestorable even though its base carries the headers.
writeModelCache("github-copilot", Date.now(), [cachedVariant], true, "", cacheDbPath);
const cacheProviderId = resolveModelCacheProviderId("github-copilot");
writeModelCache(cacheProviderId, Date.now(), [cachedVariant], true, "", cacheDbPath);
const db = new Database(cacheDbPath);
db.run("UPDATE model_cache SET header_restore_version = 0 WHERE provider_id = ?", ["github-copilot"]);
db.run("UPDATE model_cache SET header_restore_version = 0 WHERE provider_id = ?", [cacheProviderId]);
db.close();
const registry = new ModelRegistry(authStorage, modelsJsonPath);
@@ -2585,7 +2586,8 @@ providers:
requestModelId: "gpt-5.6-sol",
headers: { "X-Tenant-Route": "tenant-a" },
});
writeModelCache("github-copilot", Date.now(), [cachedAlias], true, "", cacheDbPath, [bundledBase]);
const cacheProviderId = resolveModelCacheProviderId("github-copilot");
writeModelCache(cacheProviderId, Date.now(), [cachedAlias], true, "", cacheDbPath, [bundledBase]);
const registry = new ModelRegistry(authStorage, modelsJsonPath);
@@ -4,6 +4,7 @@ import * as os from "node:os";
import * as path from "node:path";
import { writeModelCache } from "@oh-my-pi/pi-catalog/model-cache";
import { getBundledModels } from "@oh-my-pi/pi-catalog/models";
import { resolveModelCacheProviderId } from "@oh-my-pi/pi-catalog/provider-models";
import { ModelRegistry } from "@oh-my-pi/pi-coding-agent/config/model-registry";
import { AuthStorage } from "@oh-my-pi/pi-coding-agent/session/auth-storage";
import { removeSyncWithRetries } from "@oh-my-pi/pi-utils";
@@ -29,7 +30,8 @@ describe("startup model cache header restoration (#5780)", () => {
expect(withHeaders.length).toBeGreaterThan(0);
// Prior process: cache the live copilot catalog. v10 never persists headers.
writeModelCache("github-copilot", Date.now(), bundled, true, "fp-test", dbPath, bundled);
const cacheProviderId = resolveModelCacheProviderId("github-copilot");
writeModelCache(cacheProviderId, Date.now(), bundled, true, "fp-test", dbPath, bundled);
const raw = fs.readFileSync(dbPath).toString("latin1");
for (const model of withHeaders) {
for (const value of Object.values(model.headers ?? {})) {