test: cover Ollama request timeout errors
- Verify generation requests include an abort signal - Assert timeout-related abort errors propagate with the expected error name - Restore the global fetch implementation after the test
This commit is contained in:
parent
a00b3134a6
commit
ed0630bbc1
1 changed files with 17 additions and 0 deletions
|
|
@ -62,3 +62,20 @@ it("propagates an error when Ollama is unreachable", async () => {
|
||||||
globalThis.fetch = originalFetch;
|
globalThis.fetch = originalFetch;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("propagates an error when an Ollama request times out", async () => {
|
||||||
|
const originalFetch = globalThis.fetch;
|
||||||
|
|
||||||
|
globalThis.fetch = async (_input, init) => {
|
||||||
|
assert.ok(init?.signal);
|
||||||
|
throw new DOMException("The operation was aborted", "AbortError");
|
||||||
|
};
|
||||||
|
|
||||||
|
try {
|
||||||
|
await assert.rejects(generateResponse("Explain a REST API."), {
|
||||||
|
name: "AbortError",
|
||||||
|
});
|
||||||
|
} finally {
|
||||||
|
globalThis.fetch = originalFetch;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue