test: cover unreachable Ollama service errors
- Verify network-level fetch failures propagate from the generation client - Assert the original error type and message are preserved - Restore the global fetch implementation after the test
This commit is contained in:
parent
8cfcb1a3cf
commit
7771359dd4
1 changed files with 17 additions and 0 deletions
|
|
@ -45,3 +45,20 @@ it("throws an error when Ollama returns a non-OK status", async () => {
|
|||
globalThis.fetch = originalFetch;
|
||||
}
|
||||
});
|
||||
|
||||
it("propagates an error when Ollama is unreachable", async () => {
|
||||
const originalFetch = globalThis.fetch;
|
||||
|
||||
globalThis.fetch = async () => {
|
||||
throw new TypeError("fetch failed");
|
||||
};
|
||||
|
||||
try {
|
||||
await assert.rejects(generateResponse("Explain a REST API."), {
|
||||
name: "TypeError",
|
||||
message: "fetch failed",
|
||||
});
|
||||
} finally {
|
||||
globalThis.fetch = originalFetch;
|
||||
}
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue