pub struct FakePush { /* private fields */ }Expand description
An in-memory cratefield_core::Push for module tests: records every
(recipient, notification) and answers according to its PushMode.
The mode is global by default and can be overridden per recipient
(FakePush::set_mode_for), so a fan-out test can make exactly one of
five devices dead and assert that only that one is pruned — the thing a
single global mode cannot express (issue #177).
Implementations§
Source§impl FakePush
impl FakePush
pub fn new(mode: PushMode) -> Self
Sourcepub fn sent(&self) -> Vec<(Recipient, Notification)>
pub fn sent(&self) -> Vec<(Recipient, Notification)>
Every (recipient, notification) delivered so far. A send that
answered NotConfigured or failed is not recorded.
Sourcepub fn last(&self) -> Option<(Recipient, Notification)>
pub fn last(&self) -> Option<(Recipient, Notification)>
The most recent (recipient, notification).
Sourcepub fn sent_to(&self, recipient: &Recipient) -> Vec<Notification>
pub fn sent_to(&self, recipient: &Recipient) -> Vec<Notification>
Everything delivered to one recipient.
Sourcepub fn set_mode(&self, mode: PushMode)
pub fn set_mode(&self, mode: PushMode)
Switches the mode every recipient without an override answers with
(e.g. flip to Unregistered mid-test).
Sourcepub fn set_mode_for(&self, recipient: &Recipient, mode: PushMode)
pub fn set_mode_for(&self, recipient: &Recipient, mode: PushMode)
Makes one recipient answer with mode, whatever the global mode is —
one dead token among live ones, say.
Sourcepub fn clear_mode_for(&self, recipient: &Recipient)
pub fn clear_mode_for(&self, recipient: &Recipient)
Drops one recipient’s override, putting it back on the global mode.
Trait Implementations§
Source§impl Push for FakePush
impl Push for FakePush
Source§fn send<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
to: &'life1 Recipient,
notification: &'life2 Notification,
) -> Pin<Box<dyn Future<Output = Result<PushOutcome, PushError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn send<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
to: &'life1 Recipient,
notification: &'life2 Notification,
) -> Pin<Box<dyn Future<Output = Result<PushOutcome, PushError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
notification to to.