You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi,
I want to be able to test a function that does not have the server's url as one of it's arguments. For example - if I have a function like eval_code(code: String) which uses (directly or through yet another function) e.g reqwests POST requests in its body, and let's say the requests are being sent to https://example.com/endpoint - then I want to be able to redirect those requests to the mock server in my tests, automatically.
So theoretically what I want to have is define a mock server on some real address - and then, each time a request/response is being sent to/from that address it will automatically be redirected to my mock server, allowing me to test the functions that interact with that address.
I hope my explanation was clear enough, and maybe that's even possible right now - I just couldn't find a way to do it.
The text was updated successfully, but these errors were encountered:
I thought I could use a standalone server, but I want to do that in code. being able to define the port and the host when starting the server seems very trivial.
Then I can use this same server for multiple tests.
let server = MockServer::start(host="http://localhost", port=12345);
I'm not aware of any method to intercept requests to a certain host. Depending on your concrete use case, you may get away with adding an entry to /etc/hosts. I'll close this issue though, because I don't think it's directly related to httpmock. Let me know if I'm mistaken and we'll reopen this issue.
Hi,
I want to be able to test a function that does not have the server's url as one of it's arguments. For example - if I have a function like
eval_code(code: String)
which uses (directly or through yet another function) e.greqwest
s POST requests in its body, and let's say the requests are being sent tohttps://example.com/endpoint
- then I want to be able to redirect those requests to the mock server in my tests, automatically.So theoretically what I want to have is define a mock server on some real address - and then, each time a request/response is being sent to/from that address it will automatically be redirected to my mock server, allowing me to test the functions that interact with that address.
I hope my explanation was clear enough, and maybe that's even possible right now - I just couldn't find a way to do it.
The text was updated successfully, but these errors were encountered: