[][src]Struct dropshot::test_util::ClientTestContext

pub struct ClientTestContext { /* fields omitted */ }

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]

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]

pub async fn make_request_error<'_, '_>(
    &'_ self,
    method: Method,
    path: &'_ str,
    expected_status: StatusCode
) -> HttpErrorResponseBody
[src]

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]

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]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,