Skip to main content

assert_header

Macro assert_header 

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

Asserts that a test response has a header with the expected value.

§Examples

use fastapi_core::assert_header;

let response = client.get("/api").send();
assert_header!(response, "Content-Type", "application/json");

With custom message:

assert_header!(response, "X-Custom", "value", "Custom header should be set");