mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-30 09:13:36 +00:00
fix: reject partial numeric CLI options
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { Command } from "commander";
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
|
||||
const mocks = vi.hoisted(() => {
|
||||
@@ -35,6 +36,7 @@ vi.mock("../infra/clawhub.js", () => ({
|
||||
}));
|
||||
|
||||
const { runPluginsSearchCommand } = await import("./plugins-search-command.js");
|
||||
const { registerPluginsCli } = await import("./plugins-cli.js");
|
||||
|
||||
describe("plugins search command", () => {
|
||||
beforeEach(() => {
|
||||
@@ -107,4 +109,15 @@ describe("plugins search command", () => {
|
||||
|
||||
expect(mocks.runtime.writeJson).toHaveBeenCalledWith({ results: [] }, 2);
|
||||
});
|
||||
|
||||
it("rejects partial numeric search limits", async () => {
|
||||
const program = new Command();
|
||||
program.exitOverride();
|
||||
registerPluginsCli(program);
|
||||
|
||||
await expect(
|
||||
program.parseAsync(["plugins", "search", "calendar", "--limit", "10ms"], { from: "user" }),
|
||||
).rejects.toThrow("--limit must be a positive integer.");
|
||||
expect(mocks.searchClawHubPackages).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user