Перейти к основному содержимому
Эта страница ещё не переведена

Ниже показан английский оригинал.

published

published::<T>(name) opens the record of one destination on a broker: every message published there, with its name and headers.

T is the payload type that with and decoded decode to; the count and raw assertions ignore it. The assertions are those of PublishedAssertions, such as assert_called_once. In process the record is the broker's own publish log, so it holds replies, Out slot publishes, retry copies and the test's own publishes. out::<M>() shows what left through one slot, across brokers, and subscriber(name) is the record of a handler. Against a running stand it holds the test's publishes and everything a publisher wired by the runtime sent. The record is a snapshot taken when the method is called: call it after the publish that drives the reaction.

Example​

#[tokio::test]
async fn a_receipt_is_published() -> Result<(), Box<dyn Error>> {
let tb = TestApp::start(app()).await?;
let broker = tb.broker::<MemoryBroker>();
broker
.message(&Order { id: 7 })
.to("orders")
.publish()
.await?;

broker
.published::<Receipt>("receipts")
.assert_called_once()
.with(&Receipt { order_id: 7 });
Ok(())
}