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§

history
Checks every completion family runs against its own wire: a reply decoded whole and the same reply restated as a stream fold into one assistant turn, and a wire enum’s every variant is sampled.
history_conformance
Decoding a wire’s frames the way the driver does, for tests: a whole reply, or the partial response a reply cut off leaves. The history conformance suite (the unpublished rig-history-conformance crate) and provider tests build on these.
observations
Helpers for comparing deterministic observation test fixtures. These checks are not an execution-equivalence contract.
raw_parityNot (target_os=unknown and WebAssembly)
Whole-document parity of a reply’s raw: the unary body of a turn and the document a stream of the same turn rebuilds, decoded as live calls decode them and compared after comparable.
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.
CapturedEvent
One event as TraceCapture saw it.
CapturedHttpRequest
Request data captured by RecordingHttpClient.
CapturedSpan
One span as TraceCapture saw it.
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.
MockDocument
The reply document of MockScript: a whole response’s raw, or a stream’s scripted end, serialized. A stream that failed before its end has none.
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.
TraceCapture
Records every span and event it sees. Clones share one record, so a test keeps a clone and installs another with TraceCapture::subscriber.

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_API
The wire format the scripted wire names.
MOCK_MODEL
The model a scripted wire addresses when it names none.
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.
refuse_options
Every set option refused, for a test target that takes none.
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.
sent_documents
The documents a prepared request sent, as (id, text): prepare folds a request’s documents into its first user message as <file id: ...> text documents.

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.