Skip to content

Commit a11eba3

Browse files
committed
test(deepseek): add test for API error handling in createMessage
Cover the catch block that wraps API errors via handleOpenAIError, fixing 0% patch coverage on the error path. Signed-off-by: daewoongoh <[email protected]>
1 parent ec3a89c commit a11eba3

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

‎src/api/providers/__tests__/deepseek.spec.ts‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,14 @@ describe("DeepSeekHandler", () => {
426426
expect(chunks).toContainEqual({ type: "reasoning", text: "router-style thought" })
427427
})
428428

429+
it("should throw a wrapped error when the API call fails", async () => {
430+
const apiError = Object.assign(new Error("Invalid API key"), { status: 401 })
431+
mockCreate.mockRejectedValueOnce(apiError)
432+
433+
const stream = handler.createMessage(systemPrompt, messages)
434+
await expect(stream.next()).rejects.toThrow("DeepSeek completion error: Invalid API key")
435+
})
436+
429437
it("prefers delta.reasoning_content over delta.reasoning when both are present", async () => {
430438
mockCreate.mockImplementationOnce(async () => ({
431439
[Symbol.asyncIterator]: async function* () {

0 commit comments

Comments
 (0)