DummyLiveConnection

A fake LiveConnection that runs steps in order and records every message sent to it.

Only one receive() may run at a time, a turn-complete response ends the current receive(), and the next receive() resumes at the following step. If the steps run out without DummyLiveStep.EndStream, receive() waits up to 5 seconds for closeSession and then fails the test.

Constructors

Link copied to clipboard
constructor(steps: List<DummyLiveStep>)

Creates a connection that waits up to 5 seconds for each DummyLiveStep.AwaitSent and for closeSession once the steps run out.

Properties

Link copied to clipboard

Whether closeSession has been called.

Link copied to clipboard
val sent: List<Any>

All messages sent to this connection in order: a List<Content> from sendHistory, a ContentInput from sendContent, or a RealtimeInput from sendRealtime. Sends made after closeSession are still recorded.

Functions

Link copied to clipboard

Throws AssertionError naming the first DummyLiveStep.AwaitSent that receive() never got past, even if a matching message was sent later. Call it at the end of a test: closing the connection ends a waiting receive() without failing, so an early close would otherwise pass.

Link copied to clipboard
open override fun close()
Link copied to clipboard
open suspend override fun closeSession()
Link copied to clipboard
open override fun receive(): Flow<LlmResponse>
Link copied to clipboard
open suspend override fun sendContent(content: Content, partial: Boolean)
Link copied to clipboard
open suspend override fun sendHistory(history: List<Content>)
Link copied to clipboard
open suspend override fun sendRealtime(input: RealtimeInput)