test(media): cover timeout request forwarding · openclaw/openclaw@47204a1
obviyus
·
2026-04-29
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -105,6 +105,7 @@ describe("createOllamaStreamFn thinking events", () => {
|
105 | 105 | |
106 | 106 | async function streamOllamaEvents( |
107 | 107 | chunks: Array<Record<string, unknown>>, |
| 108 | +options: Parameters<ReturnType<typeof createOllamaStreamFn>>[2] = {}, |
108 | 109 | ): Promise<Array<{ type: string; [key: string]: unknown }>> { |
109 | 110 | const body = makeNdjsonBody(chunks); |
110 | 111 | fetchWithSsrFGuardMock.mockResolvedValue({ |
@@ -116,7 +117,7 @@ describe("createOllamaStreamFn thinking events", () => {
|
116 | 117 | const stream = streamFn( |
117 | 118 | { api: "ollama", provider: "ollama", id: "qwen3.5", contextWindow: 65536 } as never, |
118 | 119 | { messages: [{ role: "user", content: "test" }] } as never, |
119 | | -{}, |
| 120 | +options, |
120 | 121 | ); |
121 | 122 | |
122 | 123 | const events: Array<{ type: string; [key: string]: unknown }> = []; |
@@ -224,4 +225,14 @@ describe("createOllamaStreamFn thinking events", () => {
|
224 | 225 | const textStart = events.find((e) => e.type === "text_start") as { contentIndex?: number }; |
225 | 226 | expect(textStart?.contentIndex).toBe(0); |
226 | 227 | }); |
| 228 | + |
| 229 | +it("uses generic stream timeout for Ollama request timeout", async () => { |
| 230 | +await streamOllamaEvents([makeOllamaResponse({ content: "ok" })], { timeoutMs: 2500 }); |
| 231 | + |
| 232 | +expect(fetchWithSsrFGuardMock).toHaveBeenCalledWith( |
| 233 | +expect.objectContaining({ |
| 234 | +timeoutMs: 2500, |
| 235 | +}), |
| 236 | +); |
| 237 | +}); |
227 | 238 | }); |
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。