Mocking tokio, hyper and reqwest without using trait or changing production code by using injectorpp
Hi, We have recently added tests in injectorpp to demonstrate how to fake tokio, hyper and reqwest requests without using trait or changing production code. See tokio.rs, hyper.rs and reqwest.rs Since reqwest uses hyper, hyper is built on top of tokio, The basic steps are all the same: Create a mock TcpStream. Fake dns function to make it always success. Fake TcpSocket::connect to return the mock TcpStream. If it's a https request, fake Uri::scheme_str to make it always return http to bypass...
The Rust Programming Language Forum