Skip to main content

Module test_utils

Module test_utils 

Source
Available on crate feature test-utils only.
Expand description

Test utilities for deterministic completion-model tests.

Structs§

AppendFailingMemory
Memory backend that loads empty history and always fails on append.
CapturedHttpRequest
Request data captured by RecordingHttpClient.
CountingMemory
Memory backend that records load and append calls while delegating storage to InMemoryConversationMemory.
FailingMemory
Memory backend that always fails on load and no-ops append and clear.
HttpErrorStreamingClient
An HttpClientExt implementation whose send_streaming fails immediately with a non-success HTTP status and response body.
MockCompletionModel
A cloneable scripted CompletionModel for tests.
MockEmbeddingModel
A deterministic EmbeddingModel that returns a fixed vector for each input document.
MockModelLister
A ModelLister that returns a preconfigured list of models.
MockMultiTextDocument
A test document that contributes multiple text fragments to an embedding request.
MockResponse
Raw mock response used by completion and streaming test utilities.
MockStreamingClient
A mock HTTP client that returns pre-built SSE bytes from send_streaming.
MockTextDocument
A test document that contributes one text fragment to an embedding request.
MockTurn
A scripted non-streaming mock completion turn.
RecordingHttpClient
An HttpClientExt implementation that records unary requests and returns a fixed response.
SequencedHttpClient
An HttpClientExt implementation that records unary requests and returns one scripted response per request.
SequencedStreamingHttpClient
An HttpClientExt implementation that returns one scripted stream of byte chunks from send_streaming.

Enums§

MockError
Scripted error returned by MockCompletionModel.
MockHttpResponse
Response scripted for RecordingHttpClient.
MockStreamEvent
Scripted streaming event yielded by MockCompletionModel.

Functions§

scoped_tracing_subscriber_guard
Serializes tests that install scoped tracing subscribers (tracing::subscriber::set_default / with_default).
scoped_tracing_subscriber_guard_blocking
Blocking variant of scoped_tracing_subscriber_guard for synchronous tests.