mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 03:20:20 +00:00
refactor: finish test cleanup off infra runtime
This commit is contained in:
@@ -905,8 +905,8 @@ const { enqueueSystemEventSpy, resolveAgentRouteMock } = vi.hoisted(() => ({
|
|||||||
})),
|
})),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const infraRuntimeModule = await import("openclaw/plugin-sdk/infra-runtime");
|
const channelRuntimeModule = await import("openclaw/plugin-sdk/channel-runtime");
|
||||||
vi.spyOn(infraRuntimeModule, "enqueueSystemEvent").mockImplementation(enqueueSystemEventSpy);
|
vi.spyOn(channelRuntimeModule, "enqueueSystemEvent").mockImplementation(enqueueSystemEventSpy);
|
||||||
|
|
||||||
const routingModule = await import("openclaw/plugin-sdk/routing");
|
const routingModule = await import("openclaw/plugin-sdk/routing");
|
||||||
vi.spyOn(routingModule, "resolveAgentRoute").mockImplementation(resolveAgentRouteMock);
|
vi.spyOn(routingModule, "resolveAgentRoute").mockImplementation(resolveAgentRouteMock);
|
||||||
|
|||||||
@@ -64,19 +64,6 @@ const resolveStorePathMock = vi.hoisted(() => vi.fn());
|
|||||||
const dispatchPluginInteractiveHandlerMock = vi.hoisted(() => vi.fn());
|
const dispatchPluginInteractiveHandlerMock = vi.hoisted(() => vi.fn());
|
||||||
let lastDispatchCtx: Record<string, unknown> | undefined;
|
let lastDispatchCtx: Record<string, unknown> | undefined;
|
||||||
|
|
||||||
async function createInfraRuntimeMock(
|
|
||||||
importOriginal: () => Promise<typeof import("openclaw/plugin-sdk/infra-runtime")>,
|
|
||||||
) {
|
|
||||||
const actual = await importOriginal();
|
|
||||||
return {
|
|
||||||
...actual,
|
|
||||||
enqueueSystemEvent: (...args: unknown[]) => enqueueSystemEventMock(...args),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
vi.mock("openclaw/plugin-sdk/infra-runtime", createInfraRuntimeMock);
|
|
||||||
vi.mock("openclaw/plugin-sdk/infra-runtime.js", createInfraRuntimeMock);
|
|
||||||
|
|
||||||
async function createChannelRuntimeMock(
|
async function createChannelRuntimeMock(
|
||||||
importOriginal: () => Promise<typeof import("openclaw/plugin-sdk/channel-runtime")>,
|
importOriginal: () => Promise<typeof import("openclaw/plugin-sdk/channel-runtime")>,
|
||||||
) {
|
) {
|
||||||
|
|||||||
@@ -291,7 +291,7 @@ describe("memory plugin e2e", () => {
|
|||||||
dimensions: 1024,
|
dimensions: 1024,
|
||||||
});
|
});
|
||||||
} finally {
|
} finally {
|
||||||
vi.doUnmock("openclaw/plugin-sdk/infra-runtime");
|
vi.doUnmock("openclaw/plugin-sdk/runtime-env");
|
||||||
vi.doUnmock("openai");
|
vi.doUnmock("openai");
|
||||||
vi.doUnmock("./lancedb-runtime.js");
|
vi.doUnmock("./lancedb-runtime.js");
|
||||||
vi.resetModules();
|
vi.resetModules();
|
||||||
|
|||||||
Reference in New Issue
Block a user