#hyper-client #test #async-http #tokio #http #async

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

#34 in #hyper-client

Download history 2/week @ 2024-02-21 2/week @ 2024-02-28 2/week @ 2024-03-06 14/week @ 2024-03-13 10/week @ 2024-03-27 14/week @ 2024-04-03

70 downloads per month

MIT license

6KB
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–20MB
~228K SLoC