-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Make the Provider less powerful #2931
Comments
What is the provider?The
The interface prescribes a powerful struct that provides the ability to interact with various AWS apis, e.g. Whats wrong with it?Used too widelyWe pass a struct implementation of this interface around everywhere- doing a code lookup finds its referenced 36 times. We pass this all-powerful struct into method/functions that only require a very slim subsection of its capabilitys, e.g. in the Hard to testThe provider is the central point for doing almost all of the mocking in the code base. We don't have interfaces sitting at a higher abstraction. If for example I want to test that the How can we fix this?There are main ways we can fix this:
Once the above two are complete we can look into removing the interface and struct itself, if we only ever pass in the subsections of the |
Would this be like a wrapper around each external API, the interface for which can then be passed to packages which need it? Or do you mean that each package would define its own version of the interface it needs? I'm guessing the first but would like to clarify. |
I think the first is the easiest, but the second is the nicest in that its lets you right even smaller interfaces, but its probably not worth the cost of constantly rewriting. |
Yeh I think the second may also end up being a bit confusing: lots of partially duplicated interfaces all over the shop. |
@cPu1 @michaelbeaumont thoughts? |
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days. |
Very happy to see that there is a long-term goal about What is the provider? (Part 2)As pointed out by @aclevername, the The
What's the problem?Interface-less methods are hard to mockSince these methods are not included in any interface, fakes cannot be generated for them, which makes them hard to mock. This contributes to having untested areas in other packages, as was the case for Methods are tightly coupled with the receiver's fields and other methodsAnother issue is that these methods are often making calls to the How can we fix this?
|
The next step was to separate some of the functions out from |
Closing this off since we have split a lot of this work into smaller tickets which we will be working on. |
Adding new things, specifically new things with tests is quite challenging now due to the all powerful Provider.
The Provider contains all AWS interfaces, and is passed around everywhere, meaning that you can pretty much do anything, anywhere in the codebase.
There are few boundaries or tightly scoped components with clear responsibilities delineated by interfaces: nearly everything gets a Provider and needs little else to get things done.
This makes unit tests particularly hard, and not very "unity", as you often end up inadvertently testing things several layers down the stack in neighbouring packages. Unit tests being what they are: you should not need to think about stuff happening elsewhere.
This ticket is about fixing some of this, and namely removing some of the monopoly from the Provider. How that is done is player's choice 😉 .
The text was updated successfully, but these errors were encountered: