tests: Implement MockLLMProvider for tier 2 integration tests

This commit is contained in:
2026-07-06 10:22:41 +05:30
parent 05e5d77c6d
commit 085d141903
3 changed files with 88 additions and 0 deletions

View File

@@ -1,3 +1,4 @@
export * from "./llm.js";
export * from "./config.js";
export * from "./providers/google-genai.js";
export * from "./providers/mock.js";

View File

@@ -0,0 +1,24 @@
import { z } from "zod";
import { ILLMProvider, LLMRequest, LLMResponse } from "../llm.js";
export class MockLLMProvider implements ILLMProvider {
providerName = "mock";
private callCount = 0;
constructor(private responses: unknown[]) {}
async generateStructuredResponse<T extends z.ZodTypeAny>(
request: LLMRequest<T>,
): Promise<LLMResponse<z.infer<T>>> {
const next = this.responses[this.callCount++];
if (next === undefined) {
return { success: false, error: "Mock responses exhausted" };
}
try {
const parsed = request.schema.parse(next);
return { success: true, data: parsed };
} catch (e) {
return { success: false, error: e instanceof Error ? e.message : String(e) };
}
}
}