alexliesenfeld / httpmock

HTTP mocking library for Rust
https://httpmock.rs
MIT License
471 stars 42 forks source link

Simulate server unreachable #67

Closed sr-gi closed 1 year ago

sr-gi commented 2 years ago

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.

alexliesenfeld commented 2 years ago

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.

sr-gi commented 2 years ago

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 commented 1 year ago

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.

alexliesenfeld commented 1 year ago

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

github-actions[bot] commented 1 year ago

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

github-actions[bot] commented 1 year ago

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