-
-
Notifications
You must be signed in to change notification settings - Fork 178
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
Replacing struct references with interface ones #143
Comments
Hello, thanks! In the meantime I would just mock things at a higher level (for example, data repository instead of DB level), or use integration tests against dynamodb-local or a real AWS table. You could also mock the underlying dynamodbiface but I really wouldn't suggest it as you'd have to keep up with internal stuff that might break, probably painful. Also, kind of related: I made a fake SQL driver for mocking purposes https://github.com/guregu/mogi |
@guregu Thank you for the quick response, it is much appreciated. Sure, it is totally understandable that things are not always simple. As for mocking, the 'mocking via data repository' way was the one I went ahead with, by creating a repo struct + interface in the app in question and injecting the mock Similarly to If there was a v2.0 branch at any point in time, I would be happy to help chipping in to the implementation. Also since there is an issue already for v2.0, please feel free to close this one at any point. Thank you again. |
Hi, @Szasza and @guregu . I recently created a wrapper for this library, so it can be unit-testable. Please check it out. https://github.com/kadekutama/dynamodb |
Hi @kadekutama. Awesome, thank you for sharing the info about the wrapper. I will give it a test run in the next few days to see if it simplifies the solution I used. Thank you again. |
Hey @kadekutama, that's very cool! I'll add a link to your project when I get around to improving the readme. |
Hi @guregu ,
Thank you for maintaining the package, it is much appreciated.
I would like to ask if there has been a consideration around using interface types instead of struct types to make it possible that the various parts of the package could be mocked out using
gomock
andmockgen
.For example if there is a method chaining such as
SomeDatabase.SomeTable(...).Scan().AllWithContext(...)
, currently there is no easy way to provide a mock return value forAllWithContext()
.The above could be solved by having interface types used instead of struct types as
Scan()
-like 'factory' function return types which then can be mocked out in tests to return mock object instances.Please don't hesitate to let me know if my use-case above is unclear, I am also happy to contribute with a PR if the above fits the general direction of the package's evolution.
The text was updated successfully, but these errors were encountered: