Function preroll::test_utils::assert_json_error[][src]

pub async fn assert_json_error<Status>(
    res: impl AsMut<Response>,
    status: Status,
    err_msg: &str
) where
    Status: TryInto<StatusCode>,
    Status::Error: Debug

A test helper to check all fields of a JsonError.

Example:

use preroll::test_utils::{self, assert_json_error, 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("/not_found").await.unwrap();

    assert_json_error(
        &mut res,
        404,
        "(no additional context)",
    )
    .await;

    Ok(())
}