Open phstc opened 10 years ago
Hi @phstc
I wrote some route tests, and realizing the I was writing the same boilerplate code over and over again, I factorized that into https://github.com/ant0ine/go-json-rest/blob/master/test/util.go
You can see some tests using this here: https://github.com/ant0ine/go-json-rest/blob/master/handler_test.go
Hope that helps.
Antoine
Hey @ant0ine
How do you usually test your routes (status code, body etc)? A go-json-rest route expects
w *rest.ResponseWriter
andr *rest.Request
, but usingNewResquest
andNewRecorder
we gethttptest.ResponseRecorder
andhttp.Request
.