Skip to main content

assert_status

Macro assert_status 

Source
macro_rules! assert_status {
    ($response:expr, $expected:expr) => { ... };
    ($response:expr, $expected:expr, $($msg:tt)+) => { ... };
}
Expand description

Asserts that a test response has the expected HTTP status code.

Accepts either a u16 literal or a StatusCode value.

§Examples

use fastapi_core::assert_status;

let response = client.get("/users").send();
assert_status!(response, 200);
assert_status!(response, StatusCode::OK);

With custom message:

assert_status!(response, 404, "User should not be found");