[−][src]Struct dropshot::test_util::ClientTestContext
ClientTestContext encapsulates several facilities associated with using an HTTP client for testing.
Implementations
impl ClientTestContext
[src]
pub fn new(server_addr: SocketAddr, log: Logger) -> ClientTestContext
[src]
Set up a ClientTestContext
for running tests against an API server.
pub fn url(&self, path: &str) -> Uri
[src]
Given the path for an API endpoint (e.g., "/projects"), return a Uri that we can use to invoke this endpoint from the client. This essentially appends the path to a base URL constructed from the server's IP address and port.
pub async fn make_request<RequestBodyType: Serialize + Debug, '_, '_>(
&'_ self,
method: Method,
path: &'_ str,
request_body: Option<RequestBodyType>,
expected_status: StatusCode
) -> Result<Response<Body>, HttpErrorResponseBody>
[src]
&'_ self,
method: Method,
path: &'_ str,
request_body: Option<RequestBodyType>,
expected_status: StatusCode
) -> Result<Response<Body>, HttpErrorResponseBody>
Execute an HTTP request against the test server and perform basic validation of the result, including:
- the expected status code
- the expected Date header (within reason)
- for error responses: the expected body content
- header names are in allowed list
- any other semantics that can be verified in general
pub async fn make_request_no_body<'_, '_>(
&'_ self,
method: Method,
path: &'_ str,
expected_status: StatusCode
) -> Result<Response<Body>, HttpErrorResponseBody>
[src]
&'_ self,
method: Method,
path: &'_ str,
expected_status: StatusCode
) -> Result<Response<Body>, HttpErrorResponseBody>
pub async fn make_request_error<'_, '_>(
&'_ self,
method: Method,
path: &'_ str,
expected_status: StatusCode
) -> HttpErrorResponseBody
[src]
&'_ self,
method: Method,
path: &'_ str,
expected_status: StatusCode
) -> HttpErrorResponseBody
Fetches a resource for which we expect to get an error response.
pub async fn make_request_error_body<T: Serialize + Debug, '_, '_>(
&'_ self,
method: Method,
path: &'_ str,
body: T,
expected_status: StatusCode
) -> HttpErrorResponseBody
[src]
&'_ self,
method: Method,
path: &'_ str,
body: T,
expected_status: StatusCode
) -> HttpErrorResponseBody
Fetches a resource for which we expect to get an error response. TODO-cleanup the make_request_error* interfaces are slightly different than the non-error ones (and probably a bit more ergonomic).
pub async fn make_request_with_body<'_, '_>(
&'_ self,
method: Method,
path: &'_ str,
body: Body,
expected_status: StatusCode
) -> Result<Response<Body>, HttpErrorResponseBody>
[src]
&'_ self,
method: Method,
path: &'_ str,
body: Body,
expected_status: StatusCode
) -> Result<Response<Body>, HttpErrorResponseBody>
Auto Trait Implementations
impl !RefUnwindSafe for ClientTestContext
impl Send for ClientTestContext
impl Sync for ClientTestContext
impl Unpin for ClientTestContext
impl !UnwindSafe for ClientTestContext
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,