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.

Modules§

observations
Helpers for comparing deterministic observation test fixtures. These checks are not an execution-equivalence contract.
streaming_conformanceNot (target_os=unknown and WebAssembly)
Wire-sequence conformance scenarios for provider streaming pipelines.

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.
MockDecoder
The decoder of MockScript: each scripted step is written through the completion writer’s part handles.
MockEmbeddings
The mock embedding runtime: every text embeds to one fixed vector, five texts to a request at ten dimensions. It is the transport of a Local embedding wire (Self::model).
MockMultiTextDocument
A test document that contributes multiple text fragments to an embedding request.
MockRelay
A completion handler under label that relays each scripted turn as a host’s handler may: decoded by the scripted wire, its items, then the response. Each dispatch consumes one turn; a unary dispatch takes the response.
MockRuntime
The scripted runtime behind MockCompletionModel: the transport of a MockScript wire named MOCK_PROVIDER.
MockScript
The scripted completion wire: its payload is the request, and each frame is a scripted step its decoder writes through the completion writer’s part handles, as any wire’s decoder does. A runtime that answers from a script (MockRuntime, or a test’s own) is its transport.
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.
NonSuccessStreamingClient
An HttpClientExt whose send_streaming hands a non-success reply back as an Ok response — the fourth non-success cell: a custom transport that does not reject on status, so the driver must.
RecordingHttpClient
An HttpClientExt implementation that records unary requests and returns a fixed response.
SequencedHttpClient
An HttpClientExt implementation that records requests and returns one scripted response per request. A streamed request’s reply body arrives as one chunk.
SequencedStreamingHttpClient
An HttpClientExt implementation that returns one scripted stream of byte chunks from send_streaming.

Enums§

MockError
Scripted error returned by MockCompletionModel.
MockFrame
One step of a mock reply: a scripted event, or a whole response.
MockHttpResponse
Response scripted for RecordingHttpClient.
MockStreamEvent
Scripted streaming event yielded by MockCompletionModel.

Constants§

MOCK_PROVIDER
Provider descriptor name reported by the test doubles.

Functions§

mock_final
The end the mock model’s reply finishes with, carrying usage.
mock_final_with_total_tokens
The end of a reply whose usage has only total_tokens set.
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.

Type Aliases§

MockCompletionModel
A cloneable scripted completion model for tests: the scripted wire over its runtime. Clones share the script and the recorded requests.
MockEmbeddingModel
A deterministic embedding model that returns a fixed vector for each input document.