pub struct TestClient { /* private fields */ }Expand description
Sends requests to an App directly.
Implementations§
Source§impl TestClient
impl TestClient
Sourcepub fn new(routes: Routes) -> Self
pub fn new(routes: Routes) -> Self
Build the app with the project’s configuration (discovered from
CARGO_MANIFEST_DIR) in the test environment.
Sourcepub fn production(routes: Routes) -> Self
pub fn production(routes: Routes) -> Self
Like TestClient::new but in production mode (static caching,
generic error messages).
pub fn with(builder: AppBuilder, env: Environment) -> Self
pub fn from_app(app: App) -> Self
pub fn app(&self) -> &App
Sourcepub async fn send(&self, req: Request<Bytes>) -> TestResponse
pub async fn send(&self, req: Request<Bytes>) -> TestResponse
Send an arbitrary request. Cookies set by earlier responses are sent
along (a minimal cookie jar), unless the request already has a
Cookie header.
pub async fn get(&self, uri: &str) -> TestResponse
pub async fn post_json<T: Serialize>(&self, uri: &str, body: &T) -> TestResponse
Sourcepub async fn post_form(&self, uri: &str, body: &str) -> TestResponse
pub async fn post_form(&self, uri: &str, body: &str) -> TestResponse
application/x-www-form-urlencoded POST, e.g. "name=Ada&email=a%40b.c".
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 (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 !RefUnwindSafe for TestClient
impl !UnwindSafe for TestClient
impl Freeze for TestClient
impl Send for TestClient
impl Sync for TestClient
impl Unpin for TestClient
impl UnsafeUnpin 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