LukeMathWalker / wiremock-rs

HTTP mocking to test Rust applications.
Apache License 2.0
620 stars 70 forks source link

enable starting on fixed port #35

Closed beltram closed 3 years ago

beltram commented 3 years ago

Hi, I really liked your crate and started using it to implement mine which aims at turning original Wiremock stubs into mocks.
I have in mind proposing this as a cli or even a Helm chart. So far so good ; the only thing I miss is being able to enforce the server's port at startup.
Something like this would be awesome:

MockServer::start(8080).await

Thanks again for your work !

LukeMathWalker commented 3 years ago

Wow, super cool!
I'd be happy to mention the project in the README of wiremock itself once you have it in a working state :grin:

I would not change start to take a port, but we can definitely add a new method (e.g. start_on) that takes in a std::net::TcpListener as input.

beltram commented 3 years ago

Hi again, I kinda struggle implementing this since servers are now behind a pool. This makes sense since anytime the pool creates a new server it can bind itself to the next available free port. This does not work anymore for a fixed port.

This leaves 2 options for implementing this I'd like to have your opinion on:

Hope this is clear enough, which one do you prefer ?

LukeMathWalker commented 3 years ago

I think there is a third way - let me give it a shot :ok_hand:

LukeMathWalker commented 3 years ago

Released in 0.4.3 :grin: