Available on crate feature
test-utils only.Expand description
Test utilities for deterministic completion-model tests.
Structs§
- Append
Failing Memory - Memory backend that loads empty history and always fails on append.
- Barrier
Mock Tool Index - A vector index that waits at a barrier before returning one tool ID.
- Captured
Http Request - Request data captured by
RecordingHttpClient. - Counting
Memory - Memory backend that records load and append calls while delegating storage to
InMemoryConversationMemory. - Failing
Memory - Memory backend that always fails on load and no-ops append and clear.
- Http
Error Streaming Client - An
HttpClientExtimplementation whosesend_streamingfails immediately with a non-success HTTP status and response body. - Mock
AddTool - A mock tool that adds
xandy. - Mock
Barrier Tool - A mock tool that waits at a barrier before returning
"done". - Mock
Completion Model - A cloneable scripted
CompletionModelfor tests. - Mock
Controlled Tool - A mock tool that notifies when started and waits for an explicit finish signal.
- Mock
Denied Tool - A tool that declares the call denied from inside the tool (via
ToolReturn::denied), producing aToolOutcome::Deniedoutcome — as opposed to a hookFlow::Skip, which isSkipped. Registered under the nameguarded. - Mock
Embedding Model - A deterministic
EmbeddingModelthat returns a fixed vector for each input document. - Mock
Example Tool - A mock tool named
example_toolthat returns"Example answer". - Mock
Extensions Probe Tool - A mock tool that records whatever it observed in its per-call
ToolCallExtensions, so tests can assert the context reached tool execution. - Mock
Failing Tool - A tool that always fails, classifying its error as a configured
ToolFailureKindviaTool::classify_error. Used to exercise structured tool-failure surfacing (timeout, not-found, rate-limited, …) without a live provider. Registered under the nameflaky_tool. - Mock
Failure - Error type for
MockFailingTool, carrying a fixed message. - Mock
Handled Failure Tool - A tool that reports a handled failure via
ToolReturn: the Rust call succeeds, but the returned outcome is a classifiedToolFailurewhile the model still receives useful output. Registered under the namelookup. - Mock
Image Generator Tool - A mock tool named
generate_test_imagethat returns a 1x1 red PNG image payload. - Mock
Image Output Tool - A mock tool that returns image JSON as a string.
- Mock
Metadata Tool - A tool whose success carries a
MockRequestIdin its result extensions. Registered under the namewith_meta. - Mock
Model Lister - A
ModelListerthat returns a preconfigured list of models. - Mock
Multi Text Document - A test document that contributes multiple text fragments to an embedding request.
- Mock
Object Output Tool - A mock tool that returns a JSON object.
- Mock
Operation Args - Arguments for arithmetic mock tools.
- Mock
Request Id - A cloneable extension value a
MockMetadataToolattaches to its result, to verify result extensions reach hooks without being sent to the model. - Mock
Response - Raw mock response used by completion and streaming test utilities.
- Mock
Streaming Client - A mock HTTP client that returns pre-built SSE bytes from
send_streaming. - Mock
String Output Tool - A mock tool that returns a multiline string.
- Mock
Subtract Tool - A mock tool that subtracts
yfromx. - Mock
Text Document - A test document that contributes one text fragment to an embedding request.
- Mock
Tool Error - Shared error type for mock tools.
- Mock
Tool Index - A vector index that returns a predefined list of tool IDs from
top_n_ids. - Mock
Turn - A scripted non-streaming mock completion turn.
- Recording
Http Client - An
HttpClientExtimplementation that records unary requests and returns a fixed response. - Sequenced
Streaming Http Client - An
HttpClientExtimplementation that returns one scripted stream of byte chunks fromsend_streaming. - Session
Id - A caller-injected context value, like a session id or auth token carried in
a
ToolCallExtensions.
Enums§
- Mock
Error - Scripted error returned by
MockCompletionModel. - Mock
Http Response - Response scripted for
RecordingHttpClient. - Mock
Stream Event - Scripted streaming event yielded by
MockCompletionModel.
Functions§
- mock_
math_ toolset - Create a
ToolSetcontainingMockAddToolandMockSubtractTool. - 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_guardfor synchronous tests.