refactor(test): consolidate duplicated requireRecord and provider HTTP mock helpers (#119982)

* refactor(test): consolidate duplicated test helpers

* test: remove stale record guard import

* fix(test): remove orphaned record guards

* refactor(test): keep record requirement messages exhaustively typed

* fix(test): keep packages/ai record guard package-local
This commit is contained in:
Peter Steinberger
2026-08-06 14:48:01 -07:00
committed by GitHub
parent f5e3b5ef54
commit b4a26783f7
203 changed files with 798 additions and 1591 deletions
+3 -7
View File
@@ -1,4 +1,3 @@
// Opencode tests cover index plugin behavior.
import { readFileSync } from "node:fs";
import type { ProviderRuntimeModel } from "openclaw/plugin-sdk/plugin-entry";
import {
@@ -9,17 +8,14 @@ import {
import { NON_ENV_SECRETREF_MARKER } from "openclaw/plugin-sdk/provider-auth-runtime";
import { clearLiveCatalogCacheForTests } from "openclaw/plugin-sdk/provider-catalog-live-runtime";
import { expectPassthroughReplayPolicy } from "openclaw/plugin-sdk/provider-test-contracts";
// Opencode tests cover index plugin behavior.
import { createRequireRecord } from "openclaw/plugin-sdk/test-fixtures";
import { beforeEach, describe, expect, it, vi } from "vitest";
import plugin from "./index.js";
import manifest from "./openclaw.plugin.json" with { type: "json" };
import { buildOpencodeZenLiveProviderConfig } from "./provider-catalog.js";
function requireRecord(value: unknown, label: string): Record<string, unknown> {
if (value === null || typeof value !== "object" || Array.isArray(value)) {
throw new Error(`expected ${label} to be a record`);
}
return value as Record<string, unknown>;
}
const requireRecord = createRequireRecord("record", "expected-label-record");
function requireMapEntry<T>(map: Map<string, T>, id: string): T {
const entry = map.get(id);