fix(confidence-engine): expose failed provider path

This commit is contained in:
2026-09-05 17:00:33 +01:00
parent 677f5e5757
commit dabd9e2245
9 changed files with 81 additions and 6 deletions
+21
View File
@@ -29,4 +29,25 @@ describe("OllamaLlmProvider chat capability detection", () => {
else process.env.OLLAMA_BASE_URL = originalBaseUrl;
}
});
it("reports the actually attempted generate path when generation fails", async () => {
const originalBaseUrl = process.env.OLLAMA_BASE_URL;
const fetchSpy = vi.fn()
.mockResolvedValueOnce({ ok: false, status: 501, body: { consume: vi.fn() } })
.mockResolvedValueOnce({ ok: false, status: 500, text: async () => "failure" });
vi.stubGlobal("fetch", fetchSpy);
process.env.OLLAMA_BASE_URL = "http://ollama.test";
try {
const { getProvider } = await import("@/lib/llm/provider.js");
await expect(
getProvider().generateReconstruction("prompt", "configured-model"),
).rejects.toMatchObject({ providerApiPath: "/api/generate" });
expect(fetchSpy.mock.calls[1][0]).toBe("http://ollama.test/api/generate");
} finally {
vi.unstubAllGlobals();
if (originalBaseUrl === undefined) delete process.env.OLLAMA_BASE_URL;
else process.env.OLLAMA_BASE_URL = originalBaseUrl;
}
});
});