























@@ -12,6 +12,10 @@ import {
1212validateWindowsSourceRelease,
1313} from "../../scripts/release-candidate-checklist.mjs";
141415+function jsonResponse(body: unknown, init: ResponseInit = {}): Response {
16+return new Response(JSON.stringify(body), init);
17+}
18+1519describe("release candidate checklist", () => {
1620it("infers validation profiles from candidate tags", () => {
1721expect(parseArgs(["--tag", "v2026.5.14-beta.3"]).releaseProfile).toBe("beta");
@@ -201,16 +205,15 @@ describe("release candidate checklist", () => {
201205digest: `sha256:${"b".repeat(64)}`,
202206},
203207];
204-const fetchImpl = vi.fn(async () => ({
205-ok: true,
206-json: async () => ({
208+const fetchImpl = vi.fn(async () => {
209+return jsonResponse({
207210tag_name: "v0.6.3",
208211draft: false,
209212prerelease: false,
210213html_url: "https://github.com/openclaw/openclaw-windows-node/releases/tag/v0.6.3",
211214 assets,
212-}),
213-}));
215+});
216+});
214217215218await expect(
216219validateWindowsSourceRelease("v0.6.3", {
@@ -262,9 +265,8 @@ describe("release candidate checklist", () => {
262265"asset OpenClawCompanion-Setup-x64.exe is missing its SHA-256 digest",
263266],
264267])("rejects an invalid stable Windows source release", async (override, message) => {
265-const fetchImpl = vi.fn(async () => ({
266-ok: true,
267-json: async () => ({
268+const fetchImpl = vi.fn(async () => {
269+return jsonResponse({
268270tag_name: "v0.6.3",
269271draft: false,
270272prerelease: false,
@@ -280,8 +282,8 @@ describe("release candidate checklist", () => {
280282},
281283],
282284 ...override,
283-}),
284-}));
285+});
286+});
285287286288await expect(
287289validateWindowsSourceRelease("v0.6.3", {
@@ -357,10 +359,7 @@ describe("release candidate checklist", () => {
357359Authorization: "Bearer test-token",
358360"X-GitHub-Api-Version": "2022-11-28",
359361});
360-return {
361-ok: true,
362-json: async () => ({ workflow_runs: [] }),
363-};
362+return jsonResponse({ workflow_runs: [] });
364363});
365364366365await expect(
@@ -378,6 +377,42 @@ describe("release candidate checklist", () => {
378377);
379378});
380379380+it("bounds GitHub API error bodies", async () => {
381+const fetchImpl = vi.fn(async () => {
382+return new Response("x".repeat(65), {
383+headers: { "content-length": "65" },
384+status: 500,
385+});
386+});
387+388+await expect(
389+githubApi("repos/openclaw/openclaw/actions/runs", {
390+ fetchImpl,
391+maxBodyBytes: 64,
392+timeoutMs: 1234,
393+token: "test-token",
394+}),
395+).rejects.toThrow(
396+"GitHub API repos/openclaw/openclaw/actions/runs response body exceeded 64 bytes",
397+);
398+});
399+400+it("keeps GitHub API timeouts active while reading response bodies", async () => {
401+const fetchImpl = vi.fn(async () => {
402+return new Response(new ReadableStream<Uint8Array>({ start() {} }), {
403+status: 200,
404+});
405+});
406+407+await expect(
408+githubApi("repos/openclaw/openclaw/actions/runs", {
409+ fetchImpl,
410+timeoutMs: 25,
411+token: "test-token",
412+}),
413+).rejects.toThrow("GitHub API repos/openclaw/openclaw/actions/runs timed out after 25ms");
414+});
415+381416it("includes the GitHub API path when a request times out", async () => {
382417const fetchImpl = vi.fn(async () => {
383418throw new DOMException("request timed out", "TimeoutError");
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。