Struct axum_test::TestRequest
source · pub struct TestRequest { /* private fields */ }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.
Implementations§
source§impl TestRequest
impl TestRequest
By default, when this reuest finishes it will save all received cookies into the TestServer
for future requests. This is done to help test environments with things like authentication.
Call this method to opt out and turn this feature off, for just this request.
sourcepub fn expect_fail(self) -> Self
pub fn expect_fail(self) -> Self
Marks that this request should expect to fail. Failiure is deemend as any response that isn’t a 200.
By default, requests are expct to always succeed.
sourcepub fn json<J>(self, body: &J) -> Selfwhere
J: Serialize,
pub fn json<J>(self, body: &J) -> Selfwhere J: Serialize,
Set the body of the request to send up as Json.
sourcepub fn text<S>(self, raw_body: S) -> Selfwhere
S: AsRef<str>,
pub fn text<S>(self, raw_body: S) -> Selfwhere S: AsRef<str>,
Set the body of the request to send up as raw test.
sourcepub fn bytes(self, body_bytes: Bytes) -> Self
pub fn bytes(self, body_bytes: Bytes) -> Self
Set the body of the request to send up as raw bytes.