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 |
#755 in Testing
70 downloads per month
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–16MB
~210K SLoC