Documentation
¶
Overview ¶
Package testutil provides shared test helpers for Cogo, most notably FakeModel — a deterministic implementation of google.golang.org/adk/model.LLM that lets us drive end-to-end agent tests without burning real tokens.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FakeModel ¶
type FakeModel struct {
ModelName string
Script []ScriptedResponse
// contains filtered or unexported fields
}
FakeModel implements model.LLM with scripted output for tests.
Each call to GenerateContent advances the script by one entry. If the script is exhausted, an empty TurnComplete response is returned.
func (*FakeModel) Calls ¶
Calls returns the number of GenerateContent invocations seen so far. Useful in tests that want to assert on call count.
func (*FakeModel) GenerateContent ¶
func (f *FakeModel) GenerateContent(_ context.Context, _ *model.LLMRequest, stream bool) iter.Seq2[*model.LLMResponse, error]
GenerateContent yields the next scripted response. When stream is true, each TextChunk is emitted as its own Partial event; when false, only the final consolidated event is emitted.
type ScriptedResponse ¶
ScriptedResponse describes one turn of FakeModel output.
TextChunks are emitted as individual streaming Partial events (one per chunk) when the caller asks for a stream. After the chunks, FakeModel emits a single TurnComplete=true event whose Content is the concatenation of all chunks. In non-streaming mode (stream=false) only the final TurnComplete event is emitted.
InputTokens / OutputTokens populate the final event's UsageMetadata when set, so usage-tracking tests don't need a real model.