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

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

broker_named

TestApp::broker_named addresses a broker by the label it was registered under, which tells apart two brokers of one type.

The label is the one with_broker_labeled gives the broker in the app. The handle is the one broker::<B>() returns: it publishes onto that broker and reads its records, such as subscriber(name). A publish onto one broker reaches only that broker's subscriptions. In the example with shows which handler received the value. broker_named panics when no broker carries the label.

Example​

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

tb.broker_named("eu")
.subscriber("orders")
.assert_called_once()
.with(&Order { id: 7 });
tb.broker_named("us")
.subscriber("orders")
.assert_not_called();
Ok(())
}