mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 08:20:43 +00:00
test(media): cover timeout request forwarding
This commit is contained in:
@@ -105,6 +105,7 @@ describe("createOllamaStreamFn thinking events", () => {
|
||||
|
||||
async function streamOllamaEvents(
|
||||
chunks: Array<Record<string, unknown>>,
|
||||
options: Parameters<ReturnType<typeof createOllamaStreamFn>>[2] = {},
|
||||
): Promise<Array<{ type: string; [key: string]: unknown }>> {
|
||||
const body = makeNdjsonBody(chunks);
|
||||
fetchWithSsrFGuardMock.mockResolvedValue({
|
||||
@@ -116,7 +117,7 @@ describe("createOllamaStreamFn thinking events", () => {
|
||||
const stream = streamFn(
|
||||
{ api: "ollama", provider: "ollama", id: "qwen3.5", contextWindow: 65536 } as never,
|
||||
{ messages: [{ role: "user", content: "test" }] } as never,
|
||||
{},
|
||||
options,
|
||||
);
|
||||
|
||||
const events: Array<{ type: string; [key: string]: unknown }> = [];
|
||||
@@ -224,4 +225,14 @@ describe("createOllamaStreamFn thinking events", () => {
|
||||
const textStart = events.find((e) => e.type === "text_start") as { contentIndex?: number };
|
||||
expect(textStart?.contentIndex).toBe(0);
|
||||
});
|
||||
|
||||
it("uses generic stream timeout for Ollama request timeout", async () => {
|
||||
await streamOllamaEvents([makeOllamaResponse({ content: "ok" })], { timeoutMs: 2500 });
|
||||
|
||||
expect(fetchWithSsrFGuardMock).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
timeoutMs: 2500,
|
||||
}),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -551,6 +551,7 @@ describe("describeImageWithModel", () => {
|
||||
await assertion;
|
||||
const [, , options] = completeMock.mock.calls[0] ?? [];
|
||||
expect(options?.signal?.aborted).toBe(true);
|
||||
expect(options?.timeoutMs).toBe(25);
|
||||
});
|
||||
|
||||
it("rejects when image runtime setup exceeds the request timeout", async () => {
|
||||
|
||||
Reference in New Issue
Block a user