test: use narrow config sdk imports

This commit is contained in:
Peter Steinberger
2026-04-27 22:22:34 +01:00
parent da3d17e1ca
commit 2216ce3018
10 changed files with 23 additions and 22 deletions

View File

@@ -1,6 +1,6 @@
import { readFileSync } from "node:fs";
import { resolve } from "node:path";
import type { OpenClawConfig } from "openclaw/plugin-sdk/config-runtime";
import type { OpenClawConfig } from "openclaw/plugin-sdk/config-types";
import type { PluginRuntime } from "openclaw/plugin-sdk/core";
import { buildPluginApi } from "openclaw/plugin-sdk/testing";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";

View File

@@ -1,7 +1,10 @@
import fs from "node:fs/promises";
import net from "node:net";
import path from "node:path";
import { clearConfigCache, clearRuntimeConfigSnapshot } from "openclaw/plugin-sdk/config-runtime";
import {
clearConfigCache,
clearRuntimeConfigSnapshot,
} from "openclaw/plugin-sdk/runtime-config-snapshot";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import { createTempHomeEnv } from "../../test-support.js";
import { stopBrowserControlService } from "../control-service.js";

View File

@@ -1,5 +1,6 @@
import { resolveOpenClawAgentDir } from "openclaw/plugin-sdk/agent-runtime";
import { loadConfig } from "openclaw/plugin-sdk/config-runtime";
import type { OpenClawConfig } from "openclaw/plugin-sdk/config-types";
import { getRuntimeConfig } from "openclaw/plugin-sdk/runtime-config-snapshot";
import { isLiveTestEnabled } from "openclaw/plugin-sdk/testing";
import { beforeAll, describe, expect, it } from "vitest";
import { createTestPluginApi } from "../../test/helpers/plugins/plugin-api.js";
@@ -31,7 +32,7 @@ function withPluginsEnabled<T>(cfg: T): T {
}
describeLive("comfy live", () => {
let cfg = {} as ReturnType<typeof loadConfig>;
let cfg = {} as OpenClawConfig;
let agentDir = "";
const imageProviders: Array<{ id: string; generateImage: Function; isConfigured?: Function }> =
[];
@@ -40,7 +41,7 @@ describeLive("comfy live", () => {
[];
beforeAll(async () => {
cfg = withPluginsEnabled(loadConfig());
cfg = withPluginsEnabled(getRuntimeConfig());
agentDir = resolveOpenClawAgentDir();
plugin.register(
createTestPluginApi({

View File

@@ -1,5 +1,5 @@
import http from "node:http";
import type { OpenClawConfig } from "openclaw/plugin-sdk/config-runtime";
import type { OpenClawConfig } from "openclaw/plugin-sdk/config-types";
import { fetch as undiciFetch } from "undici";
import { beforeEach, describe, expect, it, vi } from "vitest";
import { createDiscordRestClient } from "./client.js";

View File

@@ -1,4 +1,4 @@
import type { OpenClawConfig } from "openclaw/plugin-sdk/config-runtime";
import type { OpenClawConfig } from "openclaw/plugin-sdk/config-types";
import { beforeEach, describe, expect, it, vi } from "vitest";
import { sendWebhookMessageDiscord } from "./send.outbound.js";

View File

@@ -1,4 +1,4 @@
import type { OpenClawConfig } from "openclaw/plugin-sdk/config-runtime";
import type { OpenClawConfig } from "openclaw/plugin-sdk/config-types";
import { withEnv } from "openclaw/plugin-sdk/testing";
import { describe, expect, it } from "vitest";
import { __testing, createGeminiWebSearchProvider } from "./src/gemini-web-search-provider.js";

View File

@@ -3,18 +3,10 @@ import { beforeEach, describe, expect, it, vi } from "vitest";
import { createTestPluginApi } from "../../test/helpers/plugins/plugin-api.js";
const mocks = vi.hoisted(() => ({
loadConfig: vi.fn(() => {
throw new Error("loadConfig should not be called during CLI metadata registration");
}),
registerWikiCli: vi.fn(),
resolveMemoryWikiConfig: vi.fn(),
}));
vi.mock("openclaw/plugin-sdk/config-runtime", () => ({
getRuntimeConfig: mocks.loadConfig,
loadConfig: mocks.loadConfig,
}));
vi.mock("./src/cli.js", () => ({
registerWikiCli: mocks.registerWikiCli,
}));
@@ -66,7 +58,6 @@ describe("memory-wiki cli metadata entry", () => {
logger: api.logger,
});
expect(mocks.loadConfig).not.toHaveBeenCalled();
expect(mocks.resolveMemoryWikiConfig).toHaveBeenCalledWith(
appConfig.plugins.entries["memory-wiki"].config,
);

View File

@@ -2,7 +2,8 @@ import {
resolveApiKeyForProvider,
resolveOpenClawAgentDir,
} from "openclaw/plugin-sdk/agent-runtime";
import { loadConfig, type OpenClawConfig } from "openclaw/plugin-sdk/config-runtime";
import type { OpenClawConfig } from "openclaw/plugin-sdk/config-types";
import { getRuntimeConfig } from "openclaw/plugin-sdk/runtime-config-snapshot";
import {
DEFAULT_LIVE_MUSIC_MODELS,
collectProviderApiKeys,
@@ -132,7 +133,7 @@ describeLive("music generation provider live", () => {
it(
"covers generate plus declared edit paths with shell/profile auth",
async () => {
const cfg = withPluginsEnabled(loadConfig());
const cfg = withPluginsEnabled(getRuntimeConfig());
const configuredModels = resolveConfiguredLiveMusicModels(cfg);
const agentDir = resolveOpenClawAgentDir();
const attempted: string[] = [];

View File

@@ -2,7 +2,8 @@ import {
resolveApiKeyForProvider,
resolveOpenClawAgentDir,
} from "openclaw/plugin-sdk/agent-runtime";
import { loadConfig, type OpenClawConfig } from "openclaw/plugin-sdk/config-runtime";
import type { OpenClawConfig } from "openclaw/plugin-sdk/config-types";
import { getRuntimeConfig } from "openclaw/plugin-sdk/runtime-config-snapshot";
import {
DEFAULT_LIVE_VIDEO_MODELS,
canRunBufferBackedImageToVideoLiveLane,
@@ -326,7 +327,7 @@ function resolveLiveSmokeDurationSeconds(params: {
}
async function runLiveVideoProviderCase(testCase: LiveProviderCase): Promise<void> {
const cfg = withPluginsEnabled(loadConfig());
const cfg = withPluginsEnabled(getRuntimeConfig());
const configuredModels = resolveConfiguredLiveVideoModels(cfg);
const agentDir = resolveOpenClawAgentDir();
const attempted: string[] = [];

View File

@@ -3,5 +3,9 @@ export {
getRuntimeConfigSnapshot,
setRuntimeConfigSnapshot,
} from "../config/runtime-snapshot.js";
export { getRuntimeConfig, getRuntimeConfigSourceSnapshot } from "../config/io.js";
export {
clearConfigCache,
getRuntimeConfig,
getRuntimeConfigSourceSnapshot,
} from "../config/io.js";
export type { OpenClawConfig } from "../config/types.js";