Struct axum_test::TestResponse
source · pub struct TestResponse {
pub request_url: String,
pub contents: String,
pub status_code: StatusCode,
}Expand description
This contains the response from the server.
Inside are the contents of the response, the status code, and some debugging information.
You can get the contents out as it’s raw string, or deserialise it.
One can also also use the assert_* functions to test against the
response.
Fields§
§request_url: String§contents: String§status_code: StatusCodeImplementations§
source§impl TestResponse
impl TestResponse
pub fn request_url(&self) -> String
pub fn contents(&self) -> String
pub fn status_code(&self) -> StatusCode
pub fn json<T>(&self) -> Twhere
for<'de> T: Deserialize<'de>,
pub fn assert_contents<C>(self, other: C) -> Selfwhere
C: AsRef<str>,
sourcepub fn assert_json<T>(self, other: &T) -> Selfwhere
for<'de> T: Deserialize<'de> + PartialEq<T> + Debug,
pub fn assert_json<T>(self, other: &T) -> Selfwhere
for<'de> T: Deserialize<'de> + PartialEq<T> + Debug,
Deserializes the contents of the request, and asserts if it matches the value given.
If other does not match, then this will panic.
Other can be your own Serde model that you wish to deserialise
the data into, or it can be a json! blob created using
the ::serde_json::json macro.