#[non_exhaustive]pub struct TestResponse { /* private fields */ }Expand description
A wrapper around Axum’s Response that provides fluent assertion methods.
Implementations§
Source§impl TestResponse
impl TestResponse
Sourcepub fn status(&self) -> StatusCode
pub fn status(&self) -> StatusCode
Returns the HTTP status code.
Sourcepub fn body_string(&self) -> String
pub fn body_string(&self) -> String
Returns the response body parsed as a string.
Sourcepub fn json<T: DeserializeOwned>(&self) -> T
pub fn json<T: DeserializeOwned>(&self) -> T
Deserializes the JSON response body.
Returns the value of a specific cookie from the Set-Cookie header.
Sourcepub fn assert_status(&self, expected: u16) -> &Self
pub fn assert_status(&self, expected: u16) -> &Self
Asserts that the response status code matches the expected value.
Sourcepub fn assert_see(&self, expected: &str) -> &Self
pub fn assert_see(&self, expected: &str) -> &Self
Asserts that the response body contains the given text.
Sourcepub fn assert_dont_see(&self, expected: &str) -> &Self
pub fn assert_dont_see(&self, expected: &str) -> &Self
Asserts that the response body does not contain the given text.
Sourcepub fn assert_header(&self, name: &str, expected: &str) -> &Self
pub fn assert_header(&self, name: &str, expected: &str) -> &Self
Asserts that a response header matches the expected value.
Sourcepub fn assert_json<T: Serialize + DeserializeOwned + Debug + PartialEq>(
&self,
expected: &T,
) -> &Self
pub fn assert_json<T: Serialize + DeserializeOwned + Debug + PartialEq>( &self, expected: &T, ) -> &Self
Asserts that the response body matches the given JSON structure.
Asserts that a cookie with the given name is present and matches the expected value.
Asserts that a cookie with the given name exists in the response.
Auto 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