Function preroll::test_utils::assert_status [−][src]
pub async fn assert_status<Status>(
res: impl AsMut<Response>,
status: Status
) -> String where
Status: TryInto<StatusCode>,
Status::Error: Debug,
Assert that a response has a specified status code and return the body as a string.
This helper has better assertion failure messages than doing this manually.
Example:
use preroll::test_utils::{self, assert_status, TestResult}; pub fn setup_routes(mut server: tide::Route<'_, std::sync::Arc<()>>) { // Normally imported from your service's crate (lib.rs). } #[async_std::main] // Would be #[async_std::test] instead. async fn main() -> TestResult<()> { let client = test_utils::create_client((), setup_routes).await.unwrap(); let mut res = client.get("/monitor/ping").await.unwrap(); let body = assert_status(&mut res, 200).await; assert_eq!(body, "preroll_test_utils"); Ok(()) }