pub struct TestRequest { /* private fields */ }Expand description
A fluent request builder used only in tests; invalid requests panic clearly.
Implementations§
Source§impl TestRequest
impl TestRequest
Sourcepub fn json(self, value: impl Serialize) -> Self
pub fn json(self, value: impl Serialize) -> Self
Serialize a JSON body and set the content type.
Sourcepub fn header(self, name: HeaderName, value: HeaderValue) -> Self
pub fn header(self, name: HeaderName, value: HeaderValue) -> Self
Set a header, for example authorization or content type.
Sourcepub fn body(self, body: impl Into<Body>) -> Self
pub fn body(self, body: impl Into<Body>) -> Self
Set a raw body, useful for malformed request tests.
Sourcepub async fn send(self) -> TestResponse
pub async fn send(self) -> TestResponse
Execute the request directly against the service.
Auto Trait Implementations§
impl !Freeze for TestRequest
impl !RefUnwindSafe for TestRequest
impl !Sync for TestRequest
impl !UnwindSafe for TestRequest
impl Send for TestRequest
impl Unpin for TestRequest
impl UnsafeUnpin for TestRequest
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