mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 15:30:47 +00:00
test: use narrow config sdk imports
This commit is contained in:
@@ -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";
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -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({
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -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";
|
||||
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -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,
|
||||
);
|
||||
|
||||
@@ -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[] = [];
|
||||
|
||||
@@ -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[] = [];
|
||||
|
||||
@@ -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";
|
||||
|
||||
Reference in New Issue
Block a user