bcicen/go-haproxy

Mock HAProxy for Tests

benjic opened this issue · 1 comments

As a developer I would like to be able to assert the interfaces of the client without having to install, configure, and maintain an instance of HAProxy. Currently the tests require a live instance of HAProxy to run.

This is a blog post is an example of how the pattern of Dependency Injection is used to break up elaborate internal state into manageable pieces. DI may be overkill in this situation as it's just a library but it hopefully sheds some light into how an implementation like the client could subsume a general net.Conn struct and operate independently of how that connection is created. This would make it easier in a test to construct a Mock or stub connection that can be generally asserted or configured to return static responses without ever having to set up a HAProxy instance.