test: guard media fetch call · openclaw/openclaw@41cd36f
steipete
·
2026-05-12
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -45,6 +45,14 @@ function makeLookupFn(): LookupFn {
|
45 | 45 | return vi.fn(async () => ({ address: "149.154.167.220", family: 4 })) as unknown as LookupFn; |
46 | 46 | } |
47 | 47 | |
| 48 | +function requireFetchGuardRequest(): unknown { |
| 49 | +const [call] = fetchWithSsrFGuardMock.mock.calls; |
| 50 | +if (!call) { |
| 51 | +throw new Error("expected fetchWithSsrFGuard call"); |
| 52 | +} |
| 53 | +return call[0]; |
| 54 | +} |
| 55 | + |
48 | 56 | async function expectRemoteMediaMaxBytesError(params: { |
49 | 57 | fetchImpl: Parameters<typeof fetchRemoteMedia>[0]["fetchImpl"]; |
50 | 58 | maxBytes: number; |
@@ -342,7 +350,7 @@ describe("fetchRemoteMedia", () => {
|
342 | 350 | }); |
343 | 351 | |
344 | 352 | expect(fetchWithSsrFGuardMock).toHaveBeenCalledTimes(1); |
345 | | -expect(fetchWithSsrFGuardMock.mock.calls[0]?.[0]).toStrictEqual({ |
| 353 | +expect(requireFetchGuardRequest()).toStrictEqual({ |
346 | 354 | url: "https://files.example.test/file/bot123/photos/test.jpg", |
347 | 355 | fetchImpl, |
348 | 356 | init: undefined, |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。