mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-29 16:25:16 +00:00
fix(cli): reject malformed timeout options
This commit is contained in:
@@ -10,6 +10,9 @@ describe("parseTimeoutMs", () => {
|
||||
expect(parseTimeoutMs(undefined)).toBeUndefined();
|
||||
expect(parseTimeoutMs("")).toBeUndefined();
|
||||
expect(parseTimeoutMs("nope")).toBeUndefined();
|
||||
expect(parseTimeoutMs("10abc")).toBeUndefined();
|
||||
expect(parseTimeoutMs("1.5")).toBeUndefined();
|
||||
expect(parseTimeoutMs("0")).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -40,4 +43,12 @@ describe("parseTimeoutMsWithFallback", () => {
|
||||
expect(() => parseTimeoutMsWithFallback("0", 3000)).toThrow('Received: "0"');
|
||||
expect(() => parseTimeoutMsWithFallback("-1", 3000)).toThrow('Received: "-1"');
|
||||
});
|
||||
|
||||
it("throws on malformed or unsafe parsed values", () => {
|
||||
expect(() => parseTimeoutMsWithFallback("10abc", 3000)).toThrow('Received: "10abc"');
|
||||
expect(() => parseTimeoutMsWithFallback("1.5", 3000)).toThrow('Received: "1.5"');
|
||||
expect(() => parseTimeoutMsWithFallback(String(Number.MAX_SAFE_INTEGER + 1), 3000)).toThrow(
|
||||
"Received",
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user