pub struct PublishedAssertions<T> { /* private fields */ }Expand description
Assertions over what was published to one channel, read from the broker’s publish log or from
an Out slot’s view. The type parameter T is the expected payload type for
with.
Implementations§
Source§impl<T> PublishedAssertions<T>
impl<T> PublishedAssertions<T>
Sourcepub fn assert_called_once(self) -> Self
pub fn assert_called_once(self) -> Self
Asserts exactly one message was published to this channel.
§Panics
Panics if zero or more than one message was published.
Sourcepub fn assert_called(self, times: usize) -> Self
pub fn assert_called(self, times: usize) -> Self
Asserts exactly times messages were published to this channel.
§Panics
Panics if the published count differs from times.
Sourcepub fn assert_not_called(self)
pub fn assert_not_called(self)
Sourcepub fn messages(&self) -> &[RawMessage]
pub fn messages(&self) -> &[RawMessage]
Every message published to this channel, in publish order, for custom inspection beyond the
built-in assertions. Bind the assertions to a variable to borrow them:
let pubs = tb.broker::<B>().published::<T>("x"); for m in pubs.messages() { .. }.
Sourcepub fn decoded_as<U>(self) -> PublishedAssertions<U>
pub fn decoded_as<U>(self) -> PublishedAssertions<U>
Re-types the expected payload, for assertion sources that do not name one up front
(tb.out::<Slot>().decoded_as::<Reply>().with(&expected)).
Sourcepub fn with_options<Options>(self, expected: &Options) -> Self
pub fn with_options<Options>(self, expected: &Options) -> Self
Asserts the most recent publish carried exactly expected as the broker’s per-message
options.
The options are what the broker’s builder steps set on that one publish (see
PublishBuilder::options_mut); a publish
no step touched carried none, which
assert_options_default asserts. The harness records
them with every publish the runtime makes (a reply, an Out slot publish, a retry copy),
on the broker it went to, so a broker’s view and a slot view both read them.
§Panics
Panics if nothing was published, the harness cannot say which options the most recent
publish carried (the test published it itself, a publisher the runtime did not pair made
it, or another publish there has the same payload and either the order of the two is
unknown or the harness never saw that one),
it carried none, the broker’s options type is not Options, or the value differs from
expected.
Sourcepub fn assert_options_default(self) -> Self
pub fn assert_options_default(self) -> Self
Asserts the most recent publish carried no per-message options: no builder step ran on it, and the publish policy’s own settings applied.
Recorded for every publish the runtime makes, like with_options.
§Panics
Panics if nothing was published, the harness cannot say which options the most recent
publish carried (see with_options), or a step did set options on
the publish.
Sourcepub fn with_raw(self, bytes: &[u8]) -> Self
pub fn with_raw(self, bytes: &[u8]) -> Self
Asserts the most recent published payload equals bytes.
§Panics
Panics if nothing was published, or the raw payload differs.
Sourcepub fn with_header(self, name: &str, value: impl AsRef<[u8]>) -> Self
pub fn with_header(self, name: &str, value: impl AsRef<[u8]>) -> Self
Asserts the most recent published message carries the header name with value.
What a publish transform or an app-wide
publish_layer put on the message is read
here: the assertion sees the message as it left, so a stamp added on the way out shows up
on the reply channel and on tb.out::<Marker>() alike.
§Panics
Panics if nothing was published, the header is absent, or its value differs.
Source§impl<T> PublishedAssertions<T>
impl<T> PublishedAssertions<T>
Sourcepub fn with(self, expected: &T) -> Self
pub fn with(self, expected: &T) -> Self
Asserts the most recent published payload decodes (with
DefaultCodec) to expected. If the publisher uses a different
codec, use with_codec.
§Panics
Panics if nothing was published, the payload fails to decode, or it differs from expected.
Source§impl<T> PublishedAssertions<T>
impl<T> PublishedAssertions<T>
Source§impl<T: DeserializeOwned> PublishedAssertions<T>
impl<T: DeserializeOwned> PublishedAssertions<T>
Sourcepub fn decoded(&self) -> Vec<T>
pub fn decoded(&self) -> Vec<T>
Decodes every message published to this channel (with
DefaultCodec), in publish order, for custom inspection. Use
decoded_with for a non-default codec.
§Panics
Panics if any published payload fails to decode as T.
Source§impl<T: DeserializeOwned> PublishedAssertions<T>
impl<T: DeserializeOwned> PublishedAssertions<T>
Trait Implementations§
Auto Trait Implementations§
impl<T> !RefUnwindSafe for PublishedAssertions<T>
impl<T> !UnwindSafe for PublishedAssertions<T>
impl<T> Freeze for PublishedAssertions<T>
impl<T> Send for PublishedAssertions<T>
impl<T> Sync for PublishedAssertions<T>
impl<T> Unpin for PublishedAssertions<T>
impl<T> UnsafeUnpin for PublishedAssertions<T>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
Source§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request