mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 19:48:27 +00:00
refactor(test): share gateway server plugin mocks
This commit is contained in:
36
src/gateway/server.agent.gateway-server-agent.mocks.ts
Normal file
36
src/gateway/server.agent.gateway-server-agent.mocks.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
import { vi } from "vitest";
|
||||
import type { PluginRegistry } from "../plugins/registry.js";
|
||||
import { setActivePluginRegistry } from "../plugins/runtime.js";
|
||||
|
||||
export const registryState: { registry: PluginRegistry } = {
|
||||
registry: {
|
||||
plugins: [],
|
||||
tools: [],
|
||||
channels: [],
|
||||
providers: [],
|
||||
gatewayHandlers: {},
|
||||
httpHandlers: [],
|
||||
httpRoutes: [],
|
||||
cliRegistrars: [],
|
||||
services: [],
|
||||
diagnostics: [],
|
||||
} as PluginRegistry,
|
||||
};
|
||||
|
||||
export function setRegistry(registry: PluginRegistry) {
|
||||
registryState.registry = registry;
|
||||
setActivePluginRegistry(registry);
|
||||
}
|
||||
|
||||
vi.mock("./server-plugins.js", async () => {
|
||||
const { setActivePluginRegistry } = await import("../plugins/runtime.js");
|
||||
return {
|
||||
loadGatewayPlugins: (params: { baseMethods: string[] }) => {
|
||||
setActivePluginRegistry(registryState.registry);
|
||||
return {
|
||||
pluginRegistry: registryState.registry,
|
||||
gatewayMethods: params.baseMethods ?? [],
|
||||
};
|
||||
},
|
||||
};
|
||||
});
|
||||
Reference in New Issue
Block a user