Macro trillium_testing::assert_response[][src]

macro_rules! assert_response {
    ($conn : expr, $status : expr, $body : expr) => { ... };
    ($conn : expr, $status : expr) => { ... };
    ($conn : expr, $status : expr, $body : expr,
 $($header_name : literal => $header_value : expr,) +) => { ... };
    ($conn : expr, $status : expr, $body : expr,
 $($header_name : literal => $header_value : expr), *) => { ... };
}
Expand description

combines several other assertions. this assertion can be used to assert:

  • just a status code,
  • a status code and a response body, or
  • a status code, a response body, and any number of headers
use trillium_testing::prelude::*;
async fn handler(conn: Conn) -> Conn {
    conn.with_body("just tea stuff here")
        .with_status(418)
        .with_header("server", "zojirushi")
}

assert_response!(get("/").on(&handler), 418);
assert_response!(get("/").on(&handler), Status::ImATeapot);
assert_response!(get("/").on(&handler), 418, "just tea stuff here");
assert_response!(get("/").on(&handler), Status::ImATeapot, "just tea stuff here");

assert_response!(
    get("/").on(&handler),
    Status::ImATeapot,
    "just tea stuff here",
    "server" => "zojirushi",
    "content-length" => "19"
);