Skip to content

Commit 1abe536

Browse files
committed
test(plugins): isolate snapshot memo across tests that mock manifest registry
The snapshot memo is now process-scoped and effective (~98% hit rate). Three test files were depending on cache misses (because the broken cache returned them) — each test would set up its own loadPluginManifestRegistry mock and expect a fresh derive. With the cache fixed, an earlier test's mocked registry now leaks into later tests in the same file. - io.write-config.test.ts: afterEach now clears the snapshot memo so the 'demo' plugin mocked in the first test does not survive into 'keeps shipped plugin install config records when index migration fails', which expects an empty registry to surface the 'plugin not found: demo' warning. - gateway/model-pricing-cache.ts: resetGatewayModelPricingCacheForTest also clears the memo. Tests in model-pricing-cache.test.ts assert loadPluginManifestRegistryForInstalledIndex was called; the memo hit otherwise skips the call. - providers.test.ts: vi.doMock loadPluginMetadataSnapshot to wrap the existing loadPluginManifestRegistryMock fixture. The plumbing commit added an auto-fetch fall-through in resolveOwningPluginIdsForProvider; without the mock, providers tests hit real disk reads and return empty registries (which is what surfaced as 9 unrelated-looking failures in the prior CI run).
1 parent c4663a1 commit 1abe536

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

src/gateway/model-pricing-cache.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@ import type {
1919
PluginManifestModelPricingProvider,
2020
PluginManifestModelPricingSource,
2121
} from "../plugins/manifest.js";
22-
import { resolvePluginMetadataSnapshot } from "../plugins/plugin-metadata-snapshot.js";
22+
import {
23+
clearLoadPluginMetadataSnapshotMemo,
24+
resolvePluginMetadataSnapshot,
25+
} from "../plugins/plugin-metadata-snapshot.js";
2326
import type { PluginMetadataRegistryView } from "../plugins/plugin-metadata-snapshot.types.js";
2427
import type { PluginRegistrySnapshot } from "../plugins/plugin-registry.js";
2528
import { normalizeOptionalString, resolvePrimaryStringValue } from "../shared/string-coerce.js";
@@ -1396,6 +1399,7 @@ export function startGatewayModelPricingRefresh(
13961399

13971400
export function resetGatewayModelPricingCacheForTest(): void {
13981401
clearGatewayModelPricingCacheState();
1402+
clearLoadPluginMetadataSnapshotMemo();
13991403
clearRefreshTimer();
14001404
inFlightRefresh = null;
14011405
}

src/plugins/providers.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,12 @@ describe("resolvePluginProviders", () => {
482482
loadPluginManifestRegistry: (...args: Parameters<LoadPluginManifestRegistry>) =>
483483
loadPluginManifestRegistryMock(...args),
484484
}));
485+
vi.doMock("./plugin-metadata-snapshot.js", () => ({
486+
loadPluginMetadataSnapshot: () => ({
487+
manifestRegistry: loadPluginManifestRegistryMock(),
488+
index: createProviderRegistrySnapshotFixture(),
489+
}),
490+
}));
485491
vi.doMock("./plugin-registry.js", async () => {
486492
const actual =
487493
await vi.importActual<typeof import("./plugin-registry.js")>("./plugin-registry.js");

0 commit comments

Comments
 (0)