pub async fn deliver<T: Send + 'static>(
subscription: &'static Subscription<T>,
) -> Result<usize, Error>Expand description
Delivers all unhandled messages published to subscription’s topic during
the current test, invoking its handler one message at a time in publish
order. Returns the number of messages handled.
Because subscriptions do not run automatically in unit tests, call this to
trigger a handler explicitly. Matching behaves like production delivery:
subscription filters are evaluated, Request Context fields are preserved,
and delivery_attempt starts at 1. Any messages the handler publishes to
the same topic are also delivered during the same call.
Delivery stops on the first handler error and returns it. The failed message
remains unhandled and will be redelivered on the next call with an
incremented delivery_attempt. Retry policies, ack deadlines, and
dead-letter topics are not applied.
signup("ada").await?; // publishes to SIGNUPS
assert_eq!(encore::testing::deliver(&SEND_WELCOME).await?, 1);