pub struct QueueFake { /* private fields */ }Expand description
An active queue fake and its typed assertions.
The handle isn’t cloneable, because its lifetime decides when the fake is active.
Implementations§
Source§impl QueueFake
impl QueueFake
Sourcepub fn only<J>(self) -> QueueFakewhere
J: Job,
pub fn only<J>(self) -> QueueFakewhere
J: Job,
Fake only the selected job types.
Jobs of other types are pushed normally, and the fake doesn’t record them. The first call switches the fake from all jobs to a selection, and each later call adds a type. Configure the selection before you dispatch jobs.
Sourcepub fn except<J>(self) -> QueueFakewhere
J: Job,
pub fn except<J>(self) -> QueueFakewhere
J: Job,
Fake every job type except this one.
Jobs of the excluded types are pushed normally, and the fake doesn’t record them. Each later call excludes another type. Configure the selection before you dispatch jobs.
Sourcepub fn pushed<J>(&self) -> Vec<Pushed<J>>where
J: Job,
pub fn pushed<J>(&self) -> Vec<Pushed<J>>where
J: Job,
Return the recorded jobs of this type in dispatch order, each decoded as a worker would read it.
§Panics
Panics when a recorded job’s payload doesn’t decode.
Sourcepub fn assert_pushed<J>(&self) -> &QueueFakewhere
J: Job,
pub fn assert_pushed<J>(&self) -> &QueueFakewhere
J: Job,
Assert that at least one job of this type was dispatched.
§Panics
Panics when no job of this type was recorded. The message names the expected job and the recorded jobs.
Sourcepub fn assert_pushed_where<J>(
&self,
predicate: impl Fn(&Pushed<J>) -> bool,
) -> &QueueFakewhere
J: Job,
pub fn assert_pushed_where<J>(
&self,
predicate: impl Fn(&Pushed<J>) -> bool,
) -> &QueueFakewhere
J: Job,
Sourcepub fn assert_pushed_times<J>(&self, expected: usize) -> &QueueFakewhere
J: Job,
pub fn assert_pushed_times<J>(&self, expected: usize) -> &QueueFakewhere
J: Job,
Assert that jobs of this type were dispatched exactly expected times, which may be zero.
§Panics
Panics when the count differs.
Sourcepub fn assert_not_pushed<J>(&self) -> &QueueFakewhere
J: Job,
pub fn assert_not_pushed<J>(&self) -> &QueueFakewhere
J: Job,
Assert that no job of this type was dispatched.
§Panics
Panics when one or more jobs of this type were recorded.
Sourcepub fn assert_not_pushed_where<J>(
&self,
predicate: impl Fn(&Pushed<J>) -> bool,
) -> &QueueFakewhere
J: Job,
pub fn assert_not_pushed_where<J>(
&self,
predicate: impl Fn(&Pushed<J>) -> bool,
) -> &QueueFakewhere
J: Job,
Assert that no job of this type satisfies the predicate.
Other jobs of the same type may still have been dispatched.
§Panics
Panics when a matching job was recorded, or if the predicate panics.
Sourcepub fn assert_chained<C>(&self) -> &QueueFakewhere
C: JobTypes,
pub fn assert_chained<C>(&self) -> &QueueFakewhere
C: JobTypes,
Assert that a chain of these job types was dispatched.
The assertion looks for a job of the first type whose chain holds the other types in order,
as in assert_chained::<(ShipOrder, RecordShipment)>(). To check the jobs’ data, read
Pushed::chain in assert_pushed_where.
§Panics
Panics when no job of the first type was recorded with that chain. The message names the recorded chains.
Sourcepub fn assert_pushed_without_chain<J>(&self) -> &QueueFakewhere
J: Job,
pub fn assert_pushed_without_chain<J>(&self) -> &QueueFakewhere
J: Job,
Assert that a job of this type was dispatched without a chain.
§Panics
Panics when every recorded job of this type has a chain, or when no job of this type was recorded.
Sourcepub fn batches(&self) -> Vec<PushedBatch>
pub fn batches(&self) -> Vec<PushedBatch>
Sourcepub fn assert_batched(
&self,
predicate: impl Fn(&PushedBatch) -> bool,
) -> &QueueFake
pub fn assert_batched( &self, predicate: impl Fn(&PushedBatch) -> bool, ) -> &QueueFake
Assert that a batch satisfying the predicate was dispatched.
The predicate receives a PushedBatch, which reports the batch’s jobs, name, and options.
§Panics
Panics when no matching batch was recorded, or if the predicate panics.
Sourcepub fn assert_batch_count(&self, expected: usize) -> &QueueFake
pub fn assert_batch_count(&self, expected: usize) -> &QueueFake
Assert that exactly expected batches were dispatched, which may be zero.
§Panics
Panics when the count differs.
Sourcepub fn assert_nothing_batched(&self) -> &QueueFake
pub fn assert_nothing_batched(&self) -> &QueueFake
Assert that no batch was dispatched.
§Panics
Panics when a batch was recorded. The message names the jobs of each recorded batch.
Trait Implementations§
Auto Trait Implementations§
impl Forget for QueueFake
impl Freeze for QueueFake
impl Move for QueueFake
impl RefUnwindSafe for QueueFakewhere
Atomic<usize>: RefUnwindSafe,
Mutex<Vec<Arc<Recording>>>: RefUnwindSafe,
Mutex<State>: RefUnwindSafe,
impl Send for QueueFake
impl Sync for QueueFake
impl Unpin for QueueFake
impl UnsafeUnpin for QueueFakewhere
*const ArcInner<Mutex<Vec<Arc<Recording>>>> is !null: UnsafeUnpin,
PhantomData<ArcInner<Mutex<Vec<Arc<Recording>>>>>: UnsafeUnpin,
*const ArcInner<Recording> is !null: UnsafeUnpin,
PhantomData<ArcInner<Recording>>: UnsafeUnpin,
impl UnwindSafe for QueueFake
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
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<K> ForeignKey<K> for K
impl<K> ForeignKey<K> for K
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 more