pub struct MockComponent { /* private fields */ }Expand description
The Mock component is a testing utility that records every exchange it receives via its producer. It exposes helpers to inspect and assert on the recorded exchanges.
URI format: mock:name[?retain=N©=true|false&failFast=true|false&expectedCount=N&anyOrder=true|false]
URI params override the component-level MockConfig fields; absent
params fall back to them. All params are optional.
When create_endpoint is called multiple times with the same name, the
returned endpoints share the same received-exchanges storage and the
first creation’s configuration wins — later calls with different params
do not reconfigure the existing endpoint. This enables
test assertions: create mock, register it, run routes, then inspect via
component.get_endpoint("name").
Implementations§
Source§impl MockComponent
impl MockComponent
pub fn new() -> MockComponent
Sourcepub fn with_config(config: MockConfig) -> MockComponent
pub fn with_config(config: MockConfig) -> MockComponent
Create a MockComponent with a custom MockConfig.
Sourcepub fn get_endpoint(&self, name: &str) -> Option<Arc<MockEndpointInner>>
pub fn get_endpoint(&self, name: &str) -> Option<Arc<MockEndpointInner>>
Retrieve a previously created endpoint’s inner data by name.
This is the primary way to inspect recorded exchanges in tests.
Trait Implementations§
Source§impl Clone for MockComponent
impl Clone for MockComponent
Source§fn clone(&self) -> MockComponent
fn clone(&self) -> MockComponent
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more