test: cover plugin runtime diagnostic context · openclaw/openclaw@78b2aee
steipete
·
2026-05-27
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -20,6 +20,38 @@ function createTestRegistry(runtime: PluginRuntime) {
|
20 | 20 | } |
21 | 21 | |
22 | 22 | describe("plugin registry runtime config scope", () => { |
| 23 | +it("adds plugin context to lazy runtime resolution failures", () => { |
| 24 | +const runtime = new Proxy({} as PluginRuntime, { |
| 25 | +get() { |
| 26 | +throw new Error("Unable to resolve plugin runtime module; loader=/tmp/openclaw-loader.js"); |
| 27 | +}, |
| 28 | +}); |
| 29 | +const pluginRegistry = createTestRegistry(runtime); |
| 30 | +const record = createPluginRecord({ |
| 31 | +id: "diagnostic-plugin", |
| 32 | +name: "Diagnostic Plugin", |
| 33 | +source: "/plugins/diagnostic-plugin/index.js", |
| 34 | +origin: "global", |
| 35 | +enabled: true, |
| 36 | +configSchema: false, |
| 37 | +}); |
| 38 | +const api = pluginRegistry.createApi(record, { config: {} as OpenClawConfig }); |
| 39 | + |
| 40 | +let thrown: unknown; |
| 41 | +try { |
| 42 | +void api.runtime.version; |
| 43 | +} catch (error) { |
| 44 | +thrown = error; |
| 45 | +} |
| 46 | + |
| 47 | +expect(thrown).toBeInstanceOf(Error); |
| 48 | +const message = (thrown as Error).message; |
| 49 | +expect(message).toContain("Unable to resolve plugin runtime module"); |
| 50 | +expect(message).toContain("pluginRuntimeContext=pluginId:diagnostic-plugin"); |
| 51 | +expect(message).toContain("property:version"); |
| 52 | +expect(message).toContain("source:/plugins/diagnostic-plugin/index.js"); |
| 53 | +}); |
| 54 | + |
23 | 55 | it("runs config helpers with the owning plugin scope", async () => { |
24 | 56 | let currentScope = getPluginRuntimeGatewayRequestScope(); |
25 | 57 | let mutateScope = getPluginRuntimeGatewayRequestScope(); |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。