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
76cc88a1f9
commit
a00b3134a6
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;
|
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