http://elithrar.github.io/article/testing-http-handlers-go/
Prompted by a number of questions in the Go Slack community (and elsewhere!), I’ve written up a short article on how to:
- Unit test your handlers
- Create
context.Context
s for testing with - Stub out database calls in your tests
I hope it’s useful, and happy to take feedback here.