trillium-rs / trillium

Trillium is a composable toolkit for building internet applications with async rust

Home Page:https://trillium.rs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

make it easy to get the response string

prabirshrestha opened this issue · comments

Seems like take_request_body_string internally uses block on but not take_response_body_string.

#[test]
fn test_html_output() {
    trillium_testing::block_on(async {
        let html = get("/")
            .on(&handler)
            .take_response_body_string()
            .await
            .unwrap();
        assert_eq!(&html, "some html content");
    });
}

I need to get html output and use selector to verify the response output using https://crates.io/crates/nipper. Is it possible to make it easy to get the response body so it is simple as the request body? I would expect the above code to be simple as below.

    let mut conn = TestConn::build("post", "/", "some body")
        .with_request_body("once told me");
    assert_eq!(conn.take_request_body_string(), "once told me");