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: StatusCode
Implementations§
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) -> Self
Sourcepub fn assert_json<T>(self, other: &T) -> Self
pub fn assert_json<T>(self, other: &T) -> Self
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.
pub fn assert_status_bad_request(self) -> Self
pub fn assert_status_not_found(self) -> Self
pub fn assert_status_ok(self) -> Self
pub fn assert_status_not_ok(self) -> Self
pub fn assert_status(self, status_code: StatusCode) -> Self
pub fn assert_not_status(self, status_code: StatusCode) -> Self
Auto Trait Implementations§
impl Freeze for TestResponse
impl RefUnwindSafe for TestResponse
impl Send for TestResponse
impl Sync for TestResponse
impl Unpin for TestResponse
impl UnwindSafe for TestResponse
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more