mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 11:21:23 +00:00
fix: quiet update banner and skip duplicate plugin CLI
This commit is contained in:
45
src/plugins/cli.test.ts
Normal file
45
src/plugins/cli.test.ts
Normal file
@@ -0,0 +1,45 @@
|
||||
import { Command } from "commander";
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
|
||||
const mocks = vi.hoisted(() => ({
|
||||
memoryRegister: vi.fn(),
|
||||
otherRegister: vi.fn(),
|
||||
}));
|
||||
|
||||
vi.mock("./loader.js", () => ({
|
||||
loadClawdbotPlugins: () => ({
|
||||
cliRegistrars: [
|
||||
{
|
||||
pluginId: "memory-core",
|
||||
register: mocks.memoryRegister,
|
||||
commands: ["memory"],
|
||||
source: "bundled",
|
||||
},
|
||||
{
|
||||
pluginId: "other",
|
||||
register: mocks.otherRegister,
|
||||
commands: ["other"],
|
||||
source: "bundled",
|
||||
},
|
||||
],
|
||||
}),
|
||||
}));
|
||||
|
||||
import { registerPluginCliCommands } from "./cli.js";
|
||||
|
||||
describe("registerPluginCliCommands", () => {
|
||||
beforeEach(() => {
|
||||
mocks.memoryRegister.mockClear();
|
||||
mocks.otherRegister.mockClear();
|
||||
});
|
||||
|
||||
it("skips plugin CLI registrars when commands already exist", () => {
|
||||
const program = new Command();
|
||||
program.command("memory");
|
||||
|
||||
registerPluginCliCommands(program, {} as any);
|
||||
|
||||
expect(mocks.memoryRegister).not.toHaveBeenCalled();
|
||||
expect(mocks.otherRegister).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user