-
Notifications
You must be signed in to change notification settings - Fork 599
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
How do I test stuff that uses gocql? #415
Comments
#298 might provide some food for thought - there are also a bunch of other threads if you search for In terms of mockability, there hasn't been much traction with isolating a mockable interface. That is not to say we're against it per se, just that there is little motivation on the part of the maintenance team and in the community. That said, we do still have the Generally speaking, the answer to the question of how to test stuff with gocql is to boot a Cassandra instance and just start testing. We use |
The method I use is to mock the layer just above gocql which is the load/store interface |
I'm going to close this as it not really a bug, if you would like assistance then I would be happy to help on the mailing list or in gitter. |
Found this after some googling (and after eventually solving it on my own) and am leaving this here for the next person. I wanted to use gomock to test the code that directly interfaced with gocql, but without the overhead of doing I/O. My approach was to wrap
Now in test code you can pass in mockgen's generated mocks, and your code still reads like it's directly caling the underlying session. Hope that helps. |
Check out https://github.com/willfaught/gockle, it does something similar to enable mocking. |
Thanks! |
Hi, Also, if you wanna more information about how to use it than there are inside the README, you can check this repository which makes use of both of them. Feel free to comment or help with it! |
The most useful thing would be to have an in-memory fake implementation, but I don't even see a mockable interface. Is the best practice to wrap gocql with some kind of load/store interface and mock that instead?
The text was updated successfully, but these errors were encountered: