pub struct TestResponse {
pub status: StatusCode,
pub headers: HeaderMap,
pub body: String,
}Expand description
What came back.
Fields§
§status: StatusCode§headers: HeaderMap§body: StringThe raw body. Use TestResponse::json for the typed form.
Implementations§
Source§impl TestResponse
impl TestResponse
Sourcepub fn json<T: DeserializeOwned>(&self) -> T
pub fn json<T: DeserializeOwned>(&self) -> T
The body as T.
§Panics
With the status and body in the message when it doesn’t deserialize — the usual cause is an error response the test didn’t expect, and seeing it beats a bare parse error.
pub fn header(&self, name: &str) -> Option<&str>
pub fn is_success(&self) -> bool
Sourcepub fn assert_status(&self, expected: StatusCode) -> &Self
pub fn assert_status(&self, expected: StatusCode) -> &Self
Assert the status, showing the body when it doesn’t match — which is exactly when a test needs to see it.
pub fn assert_ok(&self) -> &Self
Trait Implementations§
Source§impl Clone for TestResponse
impl Clone for TestResponse
Source§fn clone(&self) -> TestResponse
fn clone(&self) -> TestResponse
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for TestResponse
impl RefUnwindSafe for TestResponse
impl Send for TestResponse
impl Sync for TestResponse
impl Unpin for TestResponse
impl UnsafeUnpin 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