Skip to main content

run_result

TestApp::run_result returns what the service run would return now: Ok while it is healthy, an error once a fail-fast failure stopped it.

A fail-fast failure is a handler panic under the default failure policy, or a decode failure under a fail_fast decode policy. After one the result is RustStreamError::Dispatch with the subscription and the reason. run_result reads the harness without consuming it, so a test can check it between publishes. assert_running and assert_shut_down state the same as an assertion. shutdown returns the same result at the end of a test.

Example​

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

tb.message(&Order { id: 0 }).publish().await?;
assert!(matches!(tb.run_result(), Err(RustStreamError::Dispatch(_))));
Ok(())
}