test: use narrow config sdk imports · openclaw/openclaw@2216ce3
steipete
·
2026-04-28
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
|
1 | 1 | import { readFileSync } from "node:fs"; |
2 | 2 | import { resolve } from "node:path"; |
3 | | -import type { OpenClawConfig } from "openclaw/plugin-sdk/config-runtime"; |
| 3 | +import type { OpenClawConfig } from "openclaw/plugin-sdk/config-types"; |
4 | 4 | import type { PluginRuntime } from "openclaw/plugin-sdk/core"; |
5 | 5 | import { buildPluginApi } from "openclaw/plugin-sdk/testing"; |
6 | 6 | import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
1 | 1 | import fs from "node:fs/promises"; |
2 | 2 | import net from "node:net"; |
3 | 3 | import path from "node:path"; |
4 | | -import { clearConfigCache, clearRuntimeConfigSnapshot } from "openclaw/plugin-sdk/config-runtime"; |
| 4 | +import { |
| 5 | +clearConfigCache, |
| 6 | +clearRuntimeConfigSnapshot, |
| 7 | +} from "openclaw/plugin-sdk/runtime-config-snapshot"; |
5 | 8 | import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; |
6 | 9 | import { createTempHomeEnv } from "../../test-support.js"; |
7 | 10 | import { stopBrowserControlService } from "../control-service.js"; |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
1 | 1 | import { resolveOpenClawAgentDir } from "openclaw/plugin-sdk/agent-runtime"; |
2 | | -import { loadConfig } from "openclaw/plugin-sdk/config-runtime"; |
| 2 | +import type { OpenClawConfig } from "openclaw/plugin-sdk/config-types"; |
| 3 | +import { getRuntimeConfig } from "openclaw/plugin-sdk/runtime-config-snapshot"; |
3 | 4 | import { isLiveTestEnabled } from "openclaw/plugin-sdk/testing"; |
4 | 5 | import { beforeAll, describe, expect, it } from "vitest"; |
5 | 6 | import { createTestPluginApi } from "../../test/helpers/plugins/plugin-api.js"; |
@@ -31,7 +32,7 @@ function withPluginsEnabled<T>(cfg: T): T {
|
31 | 32 | } |
32 | 33 | |
33 | 34 | describeLive("comfy live", () => { |
34 | | -let cfg = {} as ReturnType<typeof loadConfig>; |
| 35 | +let cfg = {} as OpenClawConfig; |
35 | 36 | let agentDir = ""; |
36 | 37 | const imageProviders: Array<{ id: string; generateImage: Function; isConfigured?: Function }> = |
37 | 38 | []; |
@@ -40,7 +41,7 @@ describeLive("comfy live", () => {
|
40 | 41 | []; |
41 | 42 | |
42 | 43 | beforeAll(async () => { |
43 | | -cfg = withPluginsEnabled(loadConfig()); |
| 44 | +cfg = withPluginsEnabled(getRuntimeConfig()); |
44 | 45 | agentDir = resolveOpenClawAgentDir(); |
45 | 46 | plugin.register( |
46 | 47 | createTestPluginApi({ |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
1 | 1 | import http from "node:http"; |
2 | | -import type { OpenClawConfig } from "openclaw/plugin-sdk/config-runtime"; |
| 2 | +import type { OpenClawConfig } from "openclaw/plugin-sdk/config-types"; |
3 | 3 | import { fetch as undiciFetch } from "undici"; |
4 | 4 | import { beforeEach, describe, expect, it, vi } from "vitest"; |
5 | 5 | import { createDiscordRestClient } from "./client.js"; |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
1 | | -import type { OpenClawConfig } from "openclaw/plugin-sdk/config-runtime"; |
| 1 | +import type { OpenClawConfig } from "openclaw/plugin-sdk/config-types"; |
2 | 2 | import { beforeEach, describe, expect, it, vi } from "vitest"; |
3 | 3 | import { sendWebhookMessageDiscord } from "./send.outbound.js"; |
4 | 4 | |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
1 | | -import type { OpenClawConfig } from "openclaw/plugin-sdk/config-runtime"; |
| 1 | +import type { OpenClawConfig } from "openclaw/plugin-sdk/config-types"; |
2 | 2 | import { withEnv } from "openclaw/plugin-sdk/testing"; |
3 | 3 | import { describe, expect, it } from "vitest"; |
4 | 4 | import { __testing, createGeminiWebSearchProvider } from "./src/gemini-web-search-provider.js"; |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -3,18 +3,10 @@ import { beforeEach, describe, expect, it, vi } from "vitest";
|
3 | 3 | import { createTestPluginApi } from "../../test/helpers/plugins/plugin-api.js"; |
4 | 4 | |
5 | 5 | const mocks = vi.hoisted(() => ({ |
6 | | -loadConfig: vi.fn(() => { |
7 | | -throw new Error("loadConfig should not be called during CLI metadata registration"); |
8 | | -}), |
9 | 6 | registerWikiCli: vi.fn(), |
10 | 7 | resolveMemoryWikiConfig: vi.fn(), |
11 | 8 | })); |
12 | 9 | |
13 | | -vi.mock("openclaw/plugin-sdk/config-runtime", () => ({ |
14 | | -getRuntimeConfig: mocks.loadConfig, |
15 | | -loadConfig: mocks.loadConfig, |
16 | | -})); |
17 | | - |
18 | 10 | vi.mock("./src/cli.js", () => ({ |
19 | 11 | registerWikiCli: mocks.registerWikiCli, |
20 | 12 | })); |
@@ -66,7 +58,6 @@ describe("memory-wiki cli metadata entry", () => {
|
66 | 58 | logger: api.logger, |
67 | 59 | }); |
68 | 60 | |
69 | | -expect(mocks.loadConfig).not.toHaveBeenCalled(); |
70 | 61 | expect(mocks.resolveMemoryWikiConfig).toHaveBeenCalledWith( |
71 | 62 | appConfig.plugins.entries["memory-wiki"].config, |
72 | 63 | ); |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -2,7 +2,8 @@ import {
|
2 | 2 | resolveApiKeyForProvider, |
3 | 3 | resolveOpenClawAgentDir, |
4 | 4 | } from "openclaw/plugin-sdk/agent-runtime"; |
5 | | -import { loadConfig, type OpenClawConfig } from "openclaw/plugin-sdk/config-runtime"; |
| 5 | +import type { OpenClawConfig } from "openclaw/plugin-sdk/config-types"; |
| 6 | +import { getRuntimeConfig } from "openclaw/plugin-sdk/runtime-config-snapshot"; |
6 | 7 | import { |
7 | 8 | DEFAULT_LIVE_MUSIC_MODELS, |
8 | 9 | collectProviderApiKeys, |
@@ -132,7 +133,7 @@ describeLive("music generation provider live", () => {
|
132 | 133 | it( |
133 | 134 | "covers generate plus declared edit paths with shell/profile auth", |
134 | 135 | async () => { |
135 | | -const cfg = withPluginsEnabled(loadConfig()); |
| 136 | +const cfg = withPluginsEnabled(getRuntimeConfig()); |
136 | 137 | const configuredModels = resolveConfiguredLiveMusicModels(cfg); |
137 | 138 | const agentDir = resolveOpenClawAgentDir(); |
138 | 139 | const attempted: string[] = []; |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -2,7 +2,8 @@ import {
|
2 | 2 | resolveApiKeyForProvider, |
3 | 3 | resolveOpenClawAgentDir, |
4 | 4 | } from "openclaw/plugin-sdk/agent-runtime"; |
5 | | -import { loadConfig, type OpenClawConfig } from "openclaw/plugin-sdk/config-runtime"; |
| 5 | +import type { OpenClawConfig } from "openclaw/plugin-sdk/config-types"; |
| 6 | +import { getRuntimeConfig } from "openclaw/plugin-sdk/runtime-config-snapshot"; |
6 | 7 | import { |
7 | 8 | DEFAULT_LIVE_VIDEO_MODELS, |
8 | 9 | canRunBufferBackedImageToVideoLiveLane, |
@@ -326,7 +327,7 @@ function resolveLiveSmokeDurationSeconds(params: {
|
326 | 327 | } |
327 | 328 | |
328 | 329 | async function runLiveVideoProviderCase(testCase: LiveProviderCase): Promise<void> { |
329 | | -const cfg = withPluginsEnabled(loadConfig()); |
| 330 | +const cfg = withPluginsEnabled(getRuntimeConfig()); |
330 | 331 | const configuredModels = resolveConfiguredLiveVideoModels(cfg); |
331 | 332 | const agentDir = resolveOpenClawAgentDir(); |
332 | 333 | const attempted: string[] = []; |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -3,5 +3,9 @@ export {
|
3 | 3 | getRuntimeConfigSnapshot, |
4 | 4 | setRuntimeConfigSnapshot, |
5 | 5 | } from "../config/runtime-snapshot.js"; |
6 | | -export { getRuntimeConfig, getRuntimeConfigSourceSnapshot } from "../config/io.js"; |
| 6 | +export { |
| 7 | +clearConfigCache, |
| 8 | +getRuntimeConfig, |
| 9 | +getRuntimeConfigSourceSnapshot, |
| 10 | +} from "../config/io.js"; |
7 | 11 | export type { OpenClawConfig } from "../config/types.js"; |
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。