pub struct AsyncHarness { /* private fields */ }Expand description
Executes handlers the way production does, minus the polling.
ⓘ
let harness = AsyncHarness::builder()
.command(SendEmailHandler::__handler_entry(&container))
.container(container)
.build();
harness.execute(&SendEmail { to: "ada@example.com".into() })
.await
.assert_succeeded();Implementations§
Source§impl AsyncHarness
impl AsyncHarness
pub fn builder() -> AsyncHarnessBuilder
Sourcepub fn container(&self) -> &Container
pub fn container(&self) -> &Container
The container handlers resolve from — register their dependencies here before building.
Sourcepub async fn execute<C: CommandData + Serialize>(
&self,
command: &C,
) -> FinishedJob
pub async fn execute<C: CommandData + Serialize>( &self, command: &C, ) -> FinishedJob
Enqueue and run one command through the real runner, returning the finished job.
§Panics
If no handler is registered for the command. A test that runs a command nothing handles is testing nothing, and in production that is a boot-time misconfiguration rather than a runtime branch.
Sourcepub async fn execute_named(
&self,
command_name: &str,
payload: Value,
) -> FinishedJob
pub async fn execute_named( &self, command_name: &str, payload: Value, ) -> FinishedJob
AsyncHarness::execute with the command named directly — for
a cron’s command, or a payload built as raw JSON.
Sourcepub async fn run_cron(&self, command_name: &str) -> FinishedJob
pub async fn run_cron(&self, command_name: &str) -> FinishedJob
Run one cron handler’s body immediately — the tick without the clock.
Auto Trait Implementations§
impl !Freeze for AsyncHarness
impl !RefUnwindSafe for AsyncHarness
impl !UnwindSafe for AsyncHarness
impl Send for AsyncHarness
impl Sync for AsyncHarness
impl Unpin for AsyncHarness
impl UnsafeUnpin for AsyncHarness
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
Mutably borrows from an owned value. Read more