mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-02 17:30:21 +00:00
Plugins: reuse shared bootstrap registry resolution
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
|
||||
const loadOpenClawPluginsMock = vi.fn();
|
||||
const resolveRuntimePluginRegistryMock = vi.fn();
|
||||
const applyPluginAutoEnableMock = vi.fn();
|
||||
const getMemoryRuntimeMock = vi.fn();
|
||||
|
||||
@@ -9,7 +9,7 @@ vi.mock("../config/plugin-auto-enable.js", () => ({
|
||||
}));
|
||||
|
||||
vi.mock("./loader.js", () => ({
|
||||
loadOpenClawPlugins: (...args: unknown[]) => loadOpenClawPluginsMock(...args),
|
||||
resolveRuntimePluginRegistry: (...args: unknown[]) => resolveRuntimePluginRegistryMock(...args),
|
||||
}));
|
||||
|
||||
vi.mock("./memory-state.js", () => ({
|
||||
@@ -23,7 +23,7 @@ let closeActiveMemorySearchManagers: typeof import("./memory-runtime.js").closeA
|
||||
describe("memory runtime auto-enable loading", () => {
|
||||
beforeEach(async () => {
|
||||
vi.resetModules();
|
||||
loadOpenClawPluginsMock.mockReset();
|
||||
resolveRuntimePluginRegistryMock.mockReset();
|
||||
applyPluginAutoEnableMock.mockReset();
|
||||
getMemoryRuntimeMock.mockReset();
|
||||
applyPluginAutoEnableMock.mockImplementation((params: { config: unknown }) => ({
|
||||
@@ -66,7 +66,7 @@ describe("memory runtime auto-enable loading", () => {
|
||||
config: rawConfig,
|
||||
env: process.env,
|
||||
});
|
||||
expect(loadOpenClawPluginsMock).toHaveBeenCalledWith({
|
||||
expect(resolveRuntimePluginRegistryMock).toHaveBeenCalledWith({
|
||||
config: autoEnabledConfig,
|
||||
});
|
||||
});
|
||||
@@ -97,7 +97,7 @@ describe("memory runtime auto-enable loading", () => {
|
||||
});
|
||||
|
||||
expect(result).toEqual({ backend: "builtin" });
|
||||
expect(loadOpenClawPluginsMock).toHaveBeenCalledWith({
|
||||
expect(resolveRuntimePluginRegistryMock).toHaveBeenCalledWith({
|
||||
config: autoEnabledConfig,
|
||||
});
|
||||
});
|
||||
@@ -112,7 +112,7 @@ describe("memory runtime auto-enable loading", () => {
|
||||
await closeActiveMemorySearchManagers(rawConfig as never);
|
||||
|
||||
expect(applyPluginAutoEnableMock).not.toHaveBeenCalled();
|
||||
expect(loadOpenClawPluginsMock).not.toHaveBeenCalled();
|
||||
expect(resolveRuntimePluginRegistryMock).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("closes an already-registered memory runtime without reloading plugins", async () => {
|
||||
@@ -124,6 +124,6 @@ describe("memory runtime auto-enable loading", () => {
|
||||
await closeActiveMemorySearchManagers({} as never);
|
||||
|
||||
expect(runtime.closeAllMemorySearchManagers).toHaveBeenCalledTimes(1);
|
||||
expect(loadOpenClawPluginsMock).not.toHaveBeenCalled();
|
||||
expect(resolveRuntimePluginRegistryMock).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { OpenClawConfig } from "../config/config.js";
|
||||
import { applyPluginAutoEnable } from "../config/plugin-auto-enable.js";
|
||||
import { loadOpenClawPlugins } from "./loader.js";
|
||||
import { resolveRuntimePluginRegistry } from "./loader.js";
|
||||
import { getMemoryRuntime } from "./memory-state.js";
|
||||
|
||||
function ensureMemoryRuntime(cfg?: OpenClawConfig) {
|
||||
@@ -9,7 +9,7 @@ function ensureMemoryRuntime(cfg?: OpenClawConfig) {
|
||||
return current;
|
||||
}
|
||||
const resolvedConfig = applyPluginAutoEnable({ config: cfg, env: process.env }).config;
|
||||
loadOpenClawPlugins({ config: resolvedConfig });
|
||||
resolveRuntimePluginRegistry({ config: resolvedConfig });
|
||||
return getMemoryRuntime();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user