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:
YeonGyu-Kim
2026-03-26 18:14:51 +09:00
parent 4efc181390
commit b34eab3884
+15 -5
View File
@@ -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 {
getModelCapabilities,
@@ -233,13 +243,13 @@ describe("getModelCapabilities", () => {
expect(result).toMatchObject({
canonicalModelID: "gpt-5.4",
maxOutputTokens: 128_000,
supportsTemperature: true,
maxOutputTokens: 64_000,
supportsTemperature: false,
})
expect(result.diagnostics).toMatchObject({
snapshot: { source: "runtime-snapshot" },
maxOutputTokens: { source: "runtime" },
supportsTemperature: { source: "runtime" },
maxOutputTokens: { source: "runtime-snapshot" },
supportsTemperature: { source: "runtime-snapshot" },
})
})