pub struct TestClient { /* private fields */ }Expand description
Sends requests to an App directly.
Implementations§
Source§impl TestClient
impl TestClient
Sourcepub fn new(routes: Routes) -> TestClient
pub fn new(routes: Routes) -> TestClient
Build the app with the project’s configuration (discovered from
CARGO_MANIFEST_DIR) in the test environment.
Sourcepub fn production(routes: Routes) -> TestClient
pub fn production(routes: Routes) -> TestClient
Like TestClient::new but in production mode (static caching,
generic error messages).
pub fn with(builder: AppBuilder, env: Environment) -> TestClient
pub fn from_app(app: App) -> TestClient
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.
Sourcepub fn action_url(&self, id: &str) -> String
pub fn action_url(&self, id: &str) -> String
URL of server action id ("src/actions.rs::create_user"), signed
for this client like the URLs in the pages it loads. Adds the binding
cookie to the client’s jar when it has none yet.
pub async fn get(&self, uri: &str) -> TestResponse
Sourcepub async fn get_with_headers(
&self,
uri: &str,
headers: &[(&str, &str)],
) -> TestResponse
pub async fn get_with_headers( &self, uri: &str, headers: &[(&str, &str)], ) -> TestResponse
GET with extra request headers.
GET as a client-side navigation from a page whose HTML is
from_html: sends the layouts it shows, like the browser runtime.
pub async fn post_json<T>(&self, uri: &str, body: &T) -> TestResponsewhere
T: Serialize,
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
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more