mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-24 08:09:31 +00:00
fix(qa): reject duplicate telegram proof controls
This commit is contained in:
@@ -326,13 +326,20 @@ export function parseArgs(argvInput: string[]): Options {
|
||||
argv = argv.slice(0, commandSeparator);
|
||||
}
|
||||
let expectWasPassed = false;
|
||||
const seenSingleValueOptions = new Set<string>();
|
||||
for (let index = 0; index < argv.length; index += 1) {
|
||||
const arg = argv[index];
|
||||
const readValue = () => {
|
||||
const readValue = (options: { repeatable?: boolean } = {}) => {
|
||||
const value = argv[index + 1];
|
||||
if (isMissingOptionValue(value)) {
|
||||
usage();
|
||||
}
|
||||
if (!options.repeatable) {
|
||||
if (seenSingleValueOptions.has(arg)) {
|
||||
throw new Error(`${arg} was provided more than once`);
|
||||
}
|
||||
seenSingleValueOptions.add(arg);
|
||||
}
|
||||
index += 1;
|
||||
return value;
|
||||
};
|
||||
@@ -351,7 +358,7 @@ export function parseArgs(argvInput: string[]): Options {
|
||||
opts.expect = [];
|
||||
expectWasPassed = true;
|
||||
}
|
||||
opts.expect.push(readValue());
|
||||
opts.expect.push(readValue({ repeatable: true }));
|
||||
} else if (arg === "--gateway-port") {
|
||||
opts.gatewayPort = parseTcpPort(readValue(), "--gateway-port");
|
||||
} else if (arg === "--id") {
|
||||
|
||||
@@ -157,6 +157,17 @@ describe("telegram user Crabbox proof log polling", () => {
|
||||
expect(parseArgs(["--text", "-ping"]).text).toBe("-ping");
|
||||
});
|
||||
|
||||
it("rejects duplicate single-value proof controls while keeping repeated expectations", () => {
|
||||
expect(() =>
|
||||
parseArgs(["--output-dir", ".artifacts/one", "--output-dir", ".artifacts/two"]),
|
||||
).toThrow("--output-dir was provided more than once");
|
||||
|
||||
expect(parseArgs(["--expect", "OpenClaw", "--expect", "ready"]).expect).toEqual([
|
||||
"OpenClaw",
|
||||
"ready",
|
||||
]);
|
||||
});
|
||||
|
||||
it("uses unique default output dirs", () => {
|
||||
const firstOutputDir = parseArgs([]).outputDir;
|
||||
const secondOutputDir = parseArgs([]).outputDir;
|
||||
|
||||
Reference in New Issue
Block a user