Struct axum_restful::test_helpers::TestClient
source · pub struct TestClient { /* private fields */ }Expand description
A struct for test request
use axum::{Router, routing::get, http::StatusCode};
use axum_restful::test_helpers::TestClient;
let app = Router::new().route("/hello", get(|| async {"Hello, world"}));
let client = TestClient::new(app);
let res = client.get("/hello").send().await;
assert_eq!(res.status(), StatusCode::OK);
assert_eq!(res.text().await, "Hello, world");Implementations§
source§impl TestClient
impl TestClient
pub fn new<S>(svc: S) -> Self
pub fn get(&self, url: &str) -> RequestBuilder
pub fn head(&self, url: &str) -> RequestBuilder
pub fn post(&self, url: &str) -> RequestBuilder
pub fn put(&self, url: &str) -> RequestBuilder
pub fn patch(&self, url: &str) -> RequestBuilder
pub fn delete(&self, url: &str) -> RequestBuilder
Auto Trait Implementations§
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