Closed git-noise closed 4 months ago
Thank you for reaching out. I’d like to explain the functionality a bit clearer:
httpmock
makes sure tests that need the mock server run sequentially to prevent multiple tests from trying to use the server at the same time. This approach does allow you to have separate mocks for each test, though.httpmock
uses a pool of mock servers to enable running tests in parallel. However, you can't choose a specific port for these servers because they are created as needed and must pick any available port on the system.Despite the additional dependencies, using a standalone server seems to fit your needs better.
Tip: You can set up a test-specific standalone mock server on a specific port, but I'm not sure if this is going to be helpful in your case. Here’s a test example that uses it: https://github.com/alexliesenfeld/httpmock/blob/master/tests/examples/standalone_tests.rs
Regarding the OpenSSL dependency, there is this PR that should address this in the future.
Closing now. Feel free to reopen if you think there is still a missing feature.
Hello and thanks for httpmock,
I am reaching out to check if there is an alternative way to specify the port to use for a mock server. I found issue #78, however the solution described there - i.e. using a standalone mock server and then connect to it - requires the "remote" capabilities. As per #82, this involves a more significant dependency tree, as well as OpenSSL.
In my specific use-case - httpmock is used within a CI/CD environment that leverages containers. The issue arises for tools that are configured using environment variables, which may not be properly settable after the container has started - hence requiring to know the port beforehand. A standalone mock solves it, but - beyond what I highlighted above - it also limits the ability to have internal mocks per tests set, as one would need to spin one mock "externally", identify its port, configure the test environment, and then run the tests.
Many thanks and let me know if I missed something, Best,