Skip to main content

MockAssertionError

Enum MockAssertionError 

Source
#[non_exhaustive]
pub enum MockAssertionError { CountMismatch { endpoint: String, expected: usize, actual: usize, }, MinimumCountNotMet { endpoint: String, minimum: usize, actual: usize, }, BodyCountMismatch { endpoint: String, expected: usize, actual: usize, }, BodyMismatch { endpoint: String, index: usize, expected: String, actual: String, }, BodyNotFound { endpoint: String, expected: String, received_count: usize, }, BodyMatcherFailed { endpoint: String, index: usize, matcher: String, received: String, }, HeaderNotFound { endpoint: String, key: String, value: Value, received_count: usize, actual_values: Vec<String>, last_headers: Option<String>, }, HeaderRegexNotMatched { endpoint: String, key: String, pattern: String, received_count: usize, actual_values: Vec<String>, last_headers: Option<String>, }, HeaderMatcherFailed { endpoint: String, key: String, matcher: String, received: String, }, InvalidHeaderPattern { endpoint: String, key: String, pattern: String, source: Box<dyn Error + Send + Sync>, }, InvalidBodyPattern { endpoint: String, pattern: String, source: Box<dyn Error + Send + Sync>, }, }
Expand description

Error returned by MockEndpointInner::try_assert_satisfied when a recorded expectation is not satisfied (or is malformed).

Every assertion branch of MockEndpointInner::assert_satisfied corresponds to exactly one variant. The Display output of each variant equals the panic message the panicking variant produces for the same condition. Body detail fields are pre-formatted ({:?}) strings.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

CountMismatch

Exact count expectation (expect_count) not met.

Fields

§endpoint: String

Endpoint name.

§expected: usize

Expected number of exchanges.

§actual: usize

Actual number of retained exchanges.

§

MinimumCountNotMet

Minimum count expectation (expect_minimum_count) not met.

Fields

§endpoint: String

Endpoint name.

§minimum: usize

Minimum number of exchanges expected.

§actual: usize

Actual number of retained exchanges.

§

BodyCountMismatch

Number of expected bodies differs from the number of received bodies.

Fields

§endpoint: String

Endpoint name.

§expected: usize

Expected number of bodies.

§actual: usize

Actual number of bodies.

§

BodyMismatch

Ordered body at index does not match the expected body.

Fields

§endpoint: String

Endpoint name.

§index: usize

Index of the mismatching body.

§expected: String

{:?}-formatted expected body.

§actual: String

{:?}-formatted actual body.

§

BodyNotFound

Expected body not found in any received exchange (anyOrder mode).

Fields

§endpoint: String

Endpoint name.

§expected: String

{:?}-formatted expected body.

§received_count: usize

Number of received exchanges at evaluation.

§

BodyMatcherFailed

Ordered body matcher at index did not match the received body.

Mismatch-class: trips the fail-fast latch exactly like MockAssertionError::BodyMismatch.

Fields

§endpoint: String

Endpoint name.

§index: usize

Index of the mismatching expectation.

§matcher: String

Display form of the failed matcher (contains its pattern or value).

§received: String

Received body rendered whole (never truncated), plus a (<note>) suffix when the matcher reported a shape mismatch.

§

HeaderNotFound

Expected header key/value pair not found in any received exchange.

Fields

§endpoint: String

Endpoint name.

§key: String

Header key.

§value: Value

Expected header value.

§received_count: usize

Number of received exchanges at evaluation.

§actual_values: Vec<String>

{:?}-formatted values of key across received exchanges that carry it: up to [DIAGNOSTIC_LIST_CAP] values plus a final +N more entry on overflow.

§last_headers: Option<String>

Sorted key list of the last received exchange: up to [DIAGNOSTIC_LIST_CAP] keys plus a +N more suffix on overflow; None when no exchange was received.

§

HeaderRegexNotMatched

No received exchange has the named header matching the regex pattern.

Fields

§endpoint: String

Endpoint name.

§key: String

Header key.

§pattern: String

Regex pattern.

§received_count: usize

Number of received exchanges at evaluation.

§actual_values: Vec<String>

{:?}-formatted values of key across received exchanges that carry it: up to [DIAGNOSTIC_LIST_CAP] values plus a final +N more entry on overflow.

§last_headers: Option<String>

Sorted key list of the last received exchange: up to [DIAGNOSTIC_LIST_CAP] keys plus a +N more suffix on overflow; None when no exchange was received.

§

HeaderMatcherFailed

No received exchange has the named header satisfying the matcher.

Mismatch-class: trips the fail-fast latch exactly like MockAssertionError::HeaderNotFound.

Fields

§endpoint: String

Endpoint name.

§key: String

Header key.

§matcher: String

Display form of the failed matcher (contains its pattern or value).

§received: String

Received-state clause (same shape as MockAssertionError::HeaderNotFound) plus a (<note>) suffix when the matcher reported a shape mismatch.

§

InvalidHeaderPattern

Header regex pattern failed to compile.

A malformed expectation is a caller programming error, not an expectation mismatch: it does not trip the fail-fast latch.

Fields

§endpoint: String

Endpoint name.

§key: String

Header key.

§pattern: String

Regex pattern that failed to compile.

§source: Box<dyn Error + Send + Sync>

Underlying regex compile error.

§

InvalidBodyPattern

Body matcher regex pattern failed to compile.

A malformed expectation is a caller programming error, not an expectation mismatch: it does not trip the fail-fast latch.

Fields

§endpoint: String

Endpoint name.

§pattern: String

Regex pattern that failed to compile.

§source: Box<dyn Error + Send + Sync>

Underlying regex compile error.

Trait Implementations§

Source§

impl Debug for MockAssertionError

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for MockAssertionError

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Error for MockAssertionError

Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FutureExt for T

Source§

fn with_context(self, otel_cx: Context) -> WithContext<Self>

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
Source§

fn with_current_context(self) -> WithContext<Self>

Attaches the current Context to this type, returning a WithContext wrapper. Read more
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more