-
Notifications
You must be signed in to change notification settings - Fork 2
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 testing guide and add HTTP adapter via Application config #9
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really like this pattern–it allows us to lean into Mox when needed or "stub" out an http response, neat!
Additionally, it takes advantage of the config
injection pattern already established on cars platform.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is awesome. Let's do it!
this looks great! |
@stelane This is backwards compatible, we have different ways of testing across the app now. Mainly:
The approach proposed here is similar but offers the ability to reduce the amount of code and offers a documented way we we progressively move all the HTTP clients to. |
Hey everyone! I just stumbled upon this issue while searching for some previous conversations and yeah, I've been thinking along similar lines for quite some time. I created a proposal for API changes in Req. I also have an early article draft with some more context too. Any feedback welcome! |
I just noticed that this is still open. Is there anything blocking us from moving forward with this implementation? |
@ethangunderson - Given the comments from @wojtekmach we probably should close this in favor of the native implementation in req that is somewhat similar. I didn't want to introduce something temporary that we will rewrite later on. What do you think? |
@codeadict I think that's fair. @wojtekmach What kind of assistance can we give you for the Req implementation? |
@ethangunderson just let me know if wojtekmach/req#287 sounds reasonable enough. :) I implemented parts of the proposal on main already. |
Hey folks, just a heads up that I released Req v0.5 with a focus on testing! We added a way to simulate network errors and set request expectations (e.g. multiple expectations that an endpoint is hit, in order). More details here: https://dashbit.co/blog/req-v0.5. As always, if I can help in any way, let me know! |
Adds a new behavior-based adapter that makes it easier to test HTTP clients with Mox, inspired by how Tesla does it. It also improves the testing documentation based on this new feature.
This will allow us to stop the pattern of creating a higher-level behaviour that requires writing more code and we are mocking the actual implementation instead of the low-level HTTP/TCP calls. See the thread for more details. This will also help with reducing the amount of code we have for a single HTTP client as a side effect since DevAdapters can also be using this behaviour and return faked data by pattern matching in the URL and/or it's parameters as seen in https://github.com/codeadict/testing_carreq/blob/main/lib/colour_lovers/dev_adapter.ex#L6.