-
Notifications
You must be signed in to change notification settings - Fork 50
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
Theory behind setMock in the Application factories #90
Comments
G'day @rygramer Thanks for reaching out. Well, if you don't have a default binding configuration, then there is no dependency injection that is occurring for your application in normal operations. If that is the case, then I don't see a point in trying to set up a mock for something that doesn't exist normally. Can you elaborate on your use case please? |
@ImJohnMDaniel - so sorry for the delay! Taking at4dx-sample-code as an example: the
Now to the To solve this, I've duplicated the custom metadata mappings as unpackagedMetadata. Works fine! Just duplicative and confusing for devs. That's a lot to unpack! Let me know if anything is unclear 😀 |
Well, the intent was that the Sales, Service, and Marketing "packages" would all depend on the "Common" package. Granted, in the same code project, it is difficult to represent that idea as all of the code exists in the same GIT repo, but that is the example. So, the "Common" package would serve as the layer that you are referring to as a the "microservice interface package"..... that is assuming that I am understanding your example correctly. Also, I am happy to get on a call to discuss this concept further if that would help. |
When you call the
setMock
method in the Application factories, it turns around and instantiates a new force-di injector, which ultimately callsreplaceBindingsWith
. This replaces the binding in the current list of bindings with the mock instance. But if there is no binding configured (ie there’s no custom metadata record), the mock isn’t set.I would assume that if I call
setMock
, the current binding would be replaced if there is a binding configured OR if a binding doesn’t exist, the mock would be set as the binding. Basically, no matter what, a call tosetMock
results in the mock that is passed in being set as the binding used by force-di.What am I missing?
The text was updated successfully, but these errors were encountered: