mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 17:31:36 +00:00
test(cli): table-drive camera url failure cases
This commit is contained in:
@@ -141,36 +141,44 @@ describe("nodes camera helpers", () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("rejects non-https url payload", async () => {
|
it("rejects invalid url payload responses", async () => {
|
||||||
await expect(writeUrlToFile("/tmp/ignored", "http://example.com/x.bin")).rejects.toThrow(
|
const cases = [
|
||||||
/only https/i,
|
{
|
||||||
);
|
name: "non-https url",
|
||||||
});
|
url: "http://example.com/x.bin",
|
||||||
|
expectedMessage: /only https/i,
|
||||||
it("rejects oversized content-length for url payload", async () => {
|
},
|
||||||
stubFetchResponse(
|
{
|
||||||
new Response("tiny", {
|
name: "oversized content-length",
|
||||||
|
url: "https://example.com/huge.bin",
|
||||||
|
response: new Response("tiny", {
|
||||||
status: 200,
|
status: 200,
|
||||||
headers: { "content-length": String(999_999_999) },
|
headers: { "content-length": String(999_999_999) },
|
||||||
}),
|
}),
|
||||||
);
|
expectedMessage: /exceeds max/i,
|
||||||
await expect(writeUrlToFile("/tmp/ignored", "https://example.com/huge.bin")).rejects.toThrow(
|
},
|
||||||
/exceeds max/i,
|
{
|
||||||
);
|
name: "non-ok status",
|
||||||
});
|
url: "https://example.com/down.bin",
|
||||||
|
response: new Response("down", { status: 503, statusText: "Service Unavailable" }),
|
||||||
|
expectedMessage: /503/i,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "empty response body",
|
||||||
|
url: "https://example.com/empty.bin",
|
||||||
|
response: new Response(null, { status: 200 }),
|
||||||
|
expectedMessage: /empty response body/i,
|
||||||
|
},
|
||||||
|
] as const;
|
||||||
|
|
||||||
it("rejects non-ok https url payload responses", async () => {
|
for (const testCase of cases) {
|
||||||
stubFetchResponse(new Response("down", { status: 503, statusText: "Service Unavailable" }));
|
if (testCase.response) {
|
||||||
await expect(writeUrlToFile("/tmp/ignored", "https://example.com/down.bin")).rejects.toThrow(
|
stubFetchResponse(testCase.response);
|
||||||
/503/i,
|
}
|
||||||
);
|
await expect(writeUrlToFile("/tmp/ignored", testCase.url), testCase.name).rejects.toThrow(
|
||||||
});
|
testCase.expectedMessage,
|
||||||
|
|
||||||
it("rejects empty https response body", async () => {
|
|
||||||
stubFetchResponse(new Response(null, { status: 200 }));
|
|
||||||
await expect(writeUrlToFile("/tmp/ignored", "https://example.com/empty.bin")).rejects.toThrow(
|
|
||||||
/empty response body/i,
|
|
||||||
);
|
);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
it("removes partially written file when url stream fails", async () => {
|
it("removes partially written file when url stream fails", async () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user