| 9 | |
| 10 | #[wstd::test] |
| 11 | async fn main() -> Result<(), Box<dyn Error>> { |
| 12 | let request = Request::get("https://postman-echo.com/get").body(Body::empty())?; |
| 13 | |
| 14 | let response = Client::new().send(request).await?; |
| 15 | |
| 16 | let content_type = response |
| 17 | .headers() |
| 18 | .get("Content-Type") |
| 19 | .ok_or("response expected to have Content-Type header")?; |
| 20 | assert_eq!(content_type, "application/json; charset=utf-8"); |
| 21 | |
| 22 | let Echo { url } = response.into_body().json::<Echo>().await?; |
| 23 | assert!( |
| 24 | url.contains("postman-echo.com/get"), |
| 25 | "expected body url to contain the authority and path, got: {url}" |
| 26 | ); |
| 27 | |
| 28 | Ok(()) |
| 29 | } |