pub struct TestClient { /* private fields */ }
Expand description
HTTP test client for making requests in tests
Implementations§
Source§impl TestClient
impl TestClient
Sourcepub fn with_base_url(base_url: impl Into<String>) -> Self
pub fn with_base_url(base_url: impl Into<String>) -> Self
Create a test client with a custom base URL
Sourcepub fn header(self, name: impl Into<String>, value: impl Into<String>) -> Self
pub fn header(self, name: impl Into<String>, value: impl Into<String>) -> Self
Set a header for all requests
Sourcepub fn authenticated_with_token(self, token: impl Into<String>) -> Self
pub fn authenticated_with_token(self, token: impl Into<String>) -> Self
Set authentication token (JWT)
Sourcepub fn authenticated_as<T>(self, _user: &T) -> Selfwhere
T: AuthenticatedUser,
pub fn authenticated_as<T>(self, _user: &T) -> Selfwhere
T: AuthenticatedUser,
Authenticate as a specific user (requires user to implement auth traits)
Sourcepub fn get(self, path: impl Into<String>) -> RequestBuilder
pub fn get(self, path: impl Into<String>) -> RequestBuilder
Make a GET request
Sourcepub fn post(self, path: impl Into<String>) -> RequestBuilder
pub fn post(self, path: impl Into<String>) -> RequestBuilder
Make a POST request
Sourcepub fn put(self, path: impl Into<String>) -> RequestBuilder
pub fn put(self, path: impl Into<String>) -> RequestBuilder
Make a PUT request
Sourcepub fn patch(self, path: impl Into<String>) -> RequestBuilder
pub fn patch(self, path: impl Into<String>) -> RequestBuilder
Make a PATCH request
Sourcepub fn delete(self, path: impl Into<String>) -> RequestBuilder
pub fn delete(self, path: impl Into<String>) -> RequestBuilder
Make a DELETE request
Trait Implementations§
Source§impl Clone for TestClient
impl Clone for TestClient
Source§fn clone(&self) -> TestClient
fn clone(&self) -> TestClient
Returns a duplicate of the value. Read more
1.0.0 · 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 TestClient
impl RefUnwindSafe for TestClient
impl Send for TestClient
impl Sync for TestClient
impl Unpin for TestClient
impl UnwindSafe for TestClient
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more