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§

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.
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.
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.

Constants§

MOCK_PROVIDER
Provider descriptor name reported by the test doubles.

Functions§

mock_final
Build the terminal record the mock model yields, carrying usage.
mock_final_with_total_tokens
Build a terminal record 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.