gruntwork-io / health-checker

A simple HTTP server that will return 200 OK if all configured health checks pass.
MIT License
102 stars 37 forks source link

Project missing automated tests #7

Open sarkis opened 6 years ago

sarkis commented 6 years ago

I know this is on the radar, however, I wanted to open an issue to track discussion/Qs/thoughts on how to proceed.

Unit Tests: I'm thinking of ways to mock the tcp "part" for the unit tests - I found this: https://golang.org/pkg/net/#Pipe. Using this will allow unit tests to run in parallel and not require messing with ports on the system.

Integration Tests: since we need to actually test the server part here - mocking is less useful. This would consist of testing health-checker with different number of args and ensure it is starting and then returning the expected http codes for different requests.

brikis98 commented 6 years ago

Yep, adding tests is a big TODO and quite important :)

I haven't used Pipe, but that looks like an interesting option. We also have a simple helper function in Terratest for picking an available port on the system which works well enough to allow tests to run in parallel on a variety of ports.