@@ -870,13 +870,23 @@ describe("marketplace plugins", () => {
|
870 | 870 | |
871 | 871 | it("cleans up a partial download temp dir when streaming the archive fails", async () => { |
872 | 872 | await withTempDir("openclaw-marketplace-test-", async (rootDir) => { |
| 873 | +const beforeTempDirs = await listMarketplaceDownloadTempDirs(); |
| 874 | +const reader = { |
| 875 | +read: vi.fn(async () => ({ |
| 876 | +done: false, |
| 877 | +value: { length: 268_435_457 }, |
| 878 | +})), |
| 879 | +releaseLock: vi.fn(), |
| 880 | +}; |
873 | 881 | fetchWithSsrFGuardMock.mockResolvedValueOnce({ |
874 | | -response: new Response("x".repeat(1024), { |
| 882 | +response: { |
| 883 | +ok: true, |
875 | 884 | status: 200, |
876 | | -headers: { |
877 | | -"content-length": String(300 * 1024 * 1024), |
878 | | -}, |
879 | | -}), |
| 885 | +body: { |
| 886 | +getReader: () => reader, |
| 887 | +} as unknown as Response["body"], |
| 888 | +headers: new Headers(), |
| 889 | +} as unknown as Response, |
880 | 890 | finalUrl: "https://cdn.example.com/releases/frontend-design.tgz", |
881 | 891 | release: vi.fn(async () => undefined), |
882 | 892 | }); |
@@ -898,8 +908,11 @@ describe("marketplace plugins", () => {
|
898 | 908 | ok: false, |
899 | 909 | error: |
900 | 910 | "failed to download https://example.com/frontend-design.tgz: " + |
901 | | -"download too large: 314572800 bytes (limit: 268435456 bytes)", |
| 911 | +"download too large: 268435457 bytes (limit: 268435456 bytes)", |
902 | 912 | }); |
| 913 | +expect(reader.read).toHaveBeenCalledTimes(1); |
| 914 | +expect(reader.releaseLock).toHaveBeenCalledTimes(1); |
| 915 | +expect(await listMarketplaceDownloadTempDirs()).toEqual(beforeTempDirs); |
903 | 916 | expect(installPluginFromPathMock).not.toHaveBeenCalled(); |
904 | 917 | }); |
905 | 918 | }); |
|