Эта страница ещё не переведена
Ниже показан английский оригинал.
assert_not_called
assert_not_called checks that nothing was published to the destination.
The assertion passes on an empty record, published::<T>(name), and panics with the count otherwise.
It returns nothing, so it ends the chain.
A handler that settles with HandlerOutcome::drop() publishes no reply, which is what the example checks.
assert_called_once and assert_called(n) expect messages.
Example
- Macros
- Manual
#[tokio::test]
async fn an_empty_order_gets_no_receipt() -> Result<(), Box<dyn Error>> {
let tb = TestApp::start(app()).await?;
let broker = tb.broker::<MemoryBroker>();
broker
.message(&Order { id: 7, seats: 0 })
.to("orders")
.publish()
.await?;
broker.published::<Receipt>("receipts").assert_not_called();
Ok(())
}
#[tokio::test]
async fn an_empty_order_gets_no_receipt() -> Result<(), Box<dyn Error>> {
let tb = TestApp::start(app()).await?;
let broker = tb.broker::<MemoryBroker>();
broker
.message(&Order { id: 7, seats: 0 })
.to("orders")
.publish()
.await?;
broker.published::<Receipt>("receipts").assert_not_called();
Ok(())
}