httpmock icon indicating copy to clipboard operation
httpmock copied to clipboard

Simulate server unreachable

Open sr-gi opened this issue 2 years ago • 2 comments

I was wondering whether it is currently possible to simulate a MockServer being unreachable so client functionality that deals with such issues can be tested.

I can kind of replicate this by just starting the server whenever I'd like it to be reachable, but stopping it and starting it again using the same address / port is what seems tricky.

sr-gi avatar Jun 08 '22 09:06 sr-gi

I fear there is currently no built-in functionality for this case.

Would a MockServer::stop method and the possibility to set a custom port when starting a test-local mock server (something like MockServer::start_with_port(port)) be enough for you?

Related: There is a dalay function that (depending on the settings of your HTTP client) may result in a request timeout on the client side. This could already be sufficient to simulate unreachability.

alexliesenfeld avatar Jun 27 '22 08:06 alexliesenfeld

Would a MockServer::stop method and the possibility to set a custom port when starting a test-local mock server (something like MockServer::start_with_port(port)) be enough for you?

That would be exactly what I'm looking for actually.

Related: There is a dalay function that (depending on the settings of your HTTP client) may result in a request timeout on the client side. This could already be sufficient to simulate unreachability.

I tried this already, but unfortunately it does not work for what I'm intending to do :(

sr-gi avatar Jun 27 '22 09:06 sr-gi

Just checking in. Is there any ETA for MockServer::start_with_port(port) in case you're considering adding it?

No pressure at all, but it will be really helpful.

sr-gi avatar Dec 29 '22 11:12 sr-gi

There is currently no ETA for this, unfortunately. I'd be very happy to accept a pull request though!

alexliesenfeld avatar Jan 11 '23 21:01 alexliesenfeld

This issue is stale because it has been open for 30 days with no activity.

github-actions[bot] avatar Apr 18 '23 01:04 github-actions[bot]

This issue was closed because it has been inactive for 14 days since being marked as stale.

github-actions[bot] avatar May 02 '23 01:05 github-actions[bot]