mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-12 21:53:00 -06:00
fix(qa): reject duplicate gateway smoke options
This commit is contained in:
@@ -49,9 +49,14 @@ function usage(): string {
|
||||
}
|
||||
|
||||
function validateArgs(argv: readonly string[]): void {
|
||||
const seen = new Set<string>();
|
||||
for (let index = 0; index < argv.length; index += 1) {
|
||||
const arg = argv[index] ?? "";
|
||||
if (BOOLEAN_FLAGS.has(arg)) {
|
||||
if (seen.has(arg)) {
|
||||
throw new GatewaySmokeArgError(`${arg} was provided more than once`);
|
||||
}
|
||||
seen.add(arg);
|
||||
continue;
|
||||
}
|
||||
if (VALUE_FLAGS.has(arg)) {
|
||||
@@ -59,6 +64,10 @@ function validateArgs(argv: readonly string[]): void {
|
||||
if (!value || value.startsWith("-")) {
|
||||
throw new GatewaySmokeArgError(`${arg} requires a value`);
|
||||
}
|
||||
if (seen.has(arg)) {
|
||||
throw new GatewaySmokeArgError(`${arg} was provided more than once`);
|
||||
}
|
||||
seen.add(arg);
|
||||
index += 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -223,6 +223,33 @@ describe("gateway-smoke", () => {
|
||||
}
|
||||
});
|
||||
|
||||
it("rejects duplicate CLI args before connecting", () => {
|
||||
for (const [flag, args] of [
|
||||
[
|
||||
"--url",
|
||||
["--url", "ws://127.0.0.1:9", "--url", "ws://127.0.0.1:10", "--token", "token"],
|
||||
],
|
||||
[
|
||||
"--token",
|
||||
["--url", "ws://127.0.0.1:9", "--token", "one", "--token", "two"],
|
||||
],
|
||||
["--help", ["--help", "--help"]],
|
||||
] as const) {
|
||||
const result = spawnSync(
|
||||
process.execPath,
|
||||
["--import", "tsx", "scripts/dev/gateway-smoke.ts", ...args],
|
||||
{
|
||||
cwd: process.cwd(),
|
||||
encoding: "utf8",
|
||||
},
|
||||
);
|
||||
|
||||
expect(result.status).toBe(1);
|
||||
expect(result.stdout).toBe("");
|
||||
expect(result.stderr.trim()).toBe(`${flag} was provided more than once`);
|
||||
}
|
||||
});
|
||||
|
||||
it("passes against a loopback gateway websocket using the real client", async () => {
|
||||
const stdout: string[] = [];
|
||||
const stderr: string[] = [];
|
||||
|
||||
Reference in New Issue
Block a user