Closed nathanprayzo closed 9 years ago
Watching the video you sent me now; stoked to solidify the foundation of the code!
This is an excellent explanation of dependency injection with regards to testing http handlers which touch a database. If you look at the code for the author's app he's working on (found here) there is some really interesting stuff pertaining to creating an interface for the database, creating database mocks for testing, and creating a live database manager for production use. Note the unit tests on both the live manager and the mocked manager. He also has integration type tests on the api. There's certainly a lot to learn from this example, and a plus is that it's a pretty small app so it's not hard to wrap your head around what is going on.
This is also noteworthy (specifically related to testing gorilla/mux), from a comment at the bottom of the blog post: https://groups.google.com/forum/#!msg/golang-nuts/Xs-Ho1feGyg/xg5amXHsM_oJ
If you don't have any objections, I am going to go ahead and close this issue; moving forward we'll create issues for specific tests. I am going to add the dependency injection example to our list of links in the wiki.
Sounds like a good plan to me
:+1: Definitely for this - testing is high on my list of things to learn in Go.