I have a small service written in Go. I'm already testing it with httptest
et al, but, I'm mocking the database and etc...
What I would like to do:
- Start up the very same server I use in production with an empty database
- Run tests against it using HTTP
- Get the coverage of those tests
The empty database part is not a problem, since I made everything configurable via environment variables.
Make requests to it is also not the problem, as it is just standard Go code...
The problem is: I don't know how to start the server in a way that I could measure the coverage of it (and it's sub-packages). Also, the main server code is inside a main
function... I don't even know if I can call it from somewhere else (I tried the standard way, but not with reflection and stuff like that).
I'm kind of new using Go, so, this I might be talking nonsense.