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
7771359dd4
commit
0bc50f76a2
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;
|
||||
}
|
||||
});
|
||||
|
||||
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