I’ve had a hard time to wrap around the stub, mock in golang, but this blog post helped me immensely.
After reading it, my biggest issue was lack of my own interfaces in my program. Without my own interface, it was a big challenge to mock library defined interfaces; thus, making it quite hard to come up with tests.
After writing test, execute it like this:
1 2 |
# Let's assume my golang location is github.com/shinstudio/blahblah go test github.com/shinstudio/blahblah |