Skip to main content

Module test_helpers

Module test_helpers 

Source
Expand description

Pre-built helpers for testing code that uses llm-core types.

Available when the test-utils feature is enabled, allowing downstream crates to reuse these utilities in their own test suites. Also compiled during #[cfg(test)] for this crate’s own tests. Provides sample responses, message shorthands, stream collectors, and a quick MockProvider factory.

Functions§

assistant_msg
Shorthand for ChatMessage::assistant.
collect_stream
Collect stream events, panicking on any error. Use collect_stream_results when testing error scenarios.
collect_stream_results
Collect stream events, returning results including errors.
mock_for
Creates a MockProvider with the given name, model, and Capability::Tools.
sample_response
Builds a ChatResponse with a single text block and default usage.
sample_tool_response
Builds a ChatResponse containing the given tool calls.
sample_tool_response_with_text
Builds a ChatResponse containing tool calls AND a text block.
sample_usage
Returns a Usage with 100 input / 50 output tokens.
system_msg
Shorthand for ChatMessage::system.
tool_result_msg
Shorthand for ChatMessage::tool_result.
user_msg
Shorthand for ChatMessage::user.