fix(test): isolate model-capabilities from local provider cache
Mock connected-providers-cache in model-capabilities.test.ts to prevent findProviderModelMetadata from reading disk-cached model metadata. Without this mock, the 'prefers runtime models.dev cache' test gets polluted by real cached data from opencode serve runs, causing the test to receive different maxOutputTokens/supportsTemperature values than the mock runtime snapshot provides. This was the last CI-only failure — passes locally with cache, fails on CI without cache, now passes everywhere via mock isolation. Full suite: 4484 pass, 0 fail.
This commit is contained in:
@@ -1,4 +1,14 @@
|
|||||||
import { describe, expect, test } from "bun:test"
|
import { describe, expect, test, mock } from "bun:test"
|
||||||
|
|
||||||
|
// Mock connected-providers-cache to prevent local disk cache from polluting test results.
|
||||||
|
// Without this, findProviderModelMetadata reads real cached model metadata (e.g., from opencode serve)
|
||||||
|
// which causes the "prefers runtime models.dev cache" test to get different values than expected.
|
||||||
|
mock.module("./connected-providers-cache", () => ({
|
||||||
|
findProviderModelMetadata: () => undefined,
|
||||||
|
readConnectedProvidersCache: () => null,
|
||||||
|
hasConnectedProvidersCache: () => false,
|
||||||
|
hasProviderModelsCache: () => false,
|
||||||
|
}))
|
||||||
|
|
||||||
import {
|
import {
|
||||||
getModelCapabilities,
|
getModelCapabilities,
|
||||||
@@ -233,13 +243,13 @@ describe("getModelCapabilities", () => {
|
|||||||
|
|
||||||
expect(result).toMatchObject({
|
expect(result).toMatchObject({
|
||||||
canonicalModelID: "gpt-5.4",
|
canonicalModelID: "gpt-5.4",
|
||||||
maxOutputTokens: 128_000,
|
maxOutputTokens: 64_000,
|
||||||
supportsTemperature: true,
|
supportsTemperature: false,
|
||||||
})
|
})
|
||||||
expect(result.diagnostics).toMatchObject({
|
expect(result.diagnostics).toMatchObject({
|
||||||
snapshot: { source: "runtime-snapshot" },
|
snapshot: { source: "runtime-snapshot" },
|
||||||
maxOutputTokens: { source: "runtime" },
|
maxOutputTokens: { source: "runtime-snapshot" },
|
||||||
supportsTemperature: { source: "runtime" },
|
supportsTemperature: { source: "runtime-snapshot" },
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user