#test #async #http #tokio

hyper-mock-client

hyper::client mock to test tower::services such as axum::router

4 releases

0.1.3 Oct 11, 2022
0.1.2 Oct 11, 2022
0.1.1 Oct 11, 2022
0.1.0 Oct 11, 2022

#435 in Testing

Download history 12/week @ 2023-02-09 12/week @ 2023-02-16 6/week @ 2023-02-23 54/week @ 2023-03-02 13/week @ 2023-03-09 15/week @ 2023-03-16 53/week @ 2023-03-23 12/week @ 2023-03-30 16/week @ 2023-04-06 6/week @ 2023-04-13 17/week @ 2023-04-20 2/week @ 2023-04-27 8/week @ 2023-05-04 3/week @ 2023-05-11 22/week @ 2023-05-18 34/week @ 2023-05-25

67 downloads per month

MIT license

5KB
69 lines

hyper::client mock

A mock of hyper::client to test tower::Services like axum::router.

Usage

See the tests of the lib. Create an instance of the Service you want to test and create a new client with MockClient::new(app). The MockClient has an interface similar to hyper::client with MockClient::request(hyper::Request) being your main method but returning a simple Future<Response<Body>>.

License

This project is licensed under the MIT license.


lib.rs:

hyper-mock-client

hyper-mock-client is a hyper::client mock to test tower::services such as axum::router

Example

mod tests {
   use hyper::{Request,Body, StatusCode};
   use axum::{Router};
   use hyper_mock_client::MockClient;

   let app = super::MakeApiApp(); 
   let mut client = MockClient::new(app);

   let resp = client.get("/status").await;

Dependencies

~7–13MB
~216K SLoC