-
-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve httpmock's standalone capabilities #6
Conversation
With this variable httpmock won't delete all mocks during the setup/cleanup steps. This is useful when using httpmock as a standalone, shared, service to test multiple services. More importantly, it helps preserving mocks accross runs for later use
Thanks for your PR! What is your use case for this implementation? I am asking because usually tests should be self-contained and isolated, so basically setup all mocks required by the test run themselfes. |
@alexliesenfeld Arguably, this may not fit in the goals you have for this project. Let me elaborate on my use-case and see if you have a better idea on how to do this: I have a set of projects that would benefit from having a "mock server" available where they can define their own mocked APIs, run their queries, etc. I would like this mock server to always be running and to have some APIs persisted as it would help testing the integration of a more complex architecture. Real scenario: I have a Kubernetes cluster that uses I'd like to write tests that would create the mocked API endpoints in Instead of setting it up everytime, I would like httpmock to be always active and accessible not only by me but also other folks in the team. The I could probably also write my own code that doesn't use this macro but I would rather not, especially considering that it would be possible to allow for my use-case by simply adding this option. Although, I realize that the implications of adding an option like this is rarely "simple" in the long run. Let me know what you think, hope I was clear enough. |
I understand. There will be a couple of bigger changes in the next few releases and your requirements might become implicitly met. I recommend to come back and check again in a few weeks. Running a standalone httpmock instance in a Kubernetes cluster would also require some kind of persistence to avoid losing state when the pod gets rescheduled, but that might be a story on top. I will keep this PR open for now. |
that sounds fantastic! I am happy to wait 🙏 Feel free to close this PR too |
Going to close this now, no need to keep it open :) |
This PR does a couple of things:
HTTPMOCK_KEEP_MOCKS
variable__mocks/