Provide mock `HttpClient`
- Dominant language
- Rust
- Stars
- 1.5k
- Forks
- 128
- PR merge metrics
- No merged PRs in 30d
Description
This would make testing anything using a REST API simpler as one could just mock out the responses.
[`yup_hyper_mock`](https://github.com/Byron/yup-hyper-mock) lets you create a mock `Connector` implementation that responds to various hostnames:
mock_connector!(MockRedirectPolicy {
"http://127.0.0.1" => "HTTP/1.1 301 Redirect\r\n\
Location: http://127.0.0.2\r\n\
Server: mock1\r\n\
\r\n\
"
"http://127.0.0.2" => "HTTP/1.1 302 Found\r\n\
Location: https://127.0.0.3\r\n\
Server: mock2\r\n\
\r\n\
"
"https://127.0.0.3" => "HTTP/1.1 200 OK\r\n\
Server: mock3\r\n\
\r\n\
"
});
Since we have access to the full request in `HttpClient` we have a lot more flexibility with matching requests; ideally it should be able to match on paths and body contents.
Contributor guide
Assessment
This issue has not been assessed yet.