Skip to content

Issue #4 - Move to stub/mock based testing.#5

Open
jesseward wants to merge 1 commit intobcicen:masterfrom
jesseward:stub-tests
Open

Issue #4 - Move to stub/mock based testing.#5
jesseward wants to merge 1 commit intobcicen:masterfrom
jesseward:stub-tests

Conversation

@jesseward
Copy link
Copy Markdown

The currently library is strongly coupled HA-Proxy, meaning that in order to execute tests haproxy must be running locally. This change adds an interface (HAProxy) that allows us to then stub out the calls to RunCommand.

Note: If you're to go this route, README will need to be updated as the Info and Stats methods are no longer pointer receivers, but instead receiving the HAProxyClient as an argument. For example

client := HAProxyClient{Addr: "tcp://blah:64738"}
info, err := Info(client) {
    ...
}
...

Your method (or implementation) may vary. Though as @benjic mentioned, decoupling network services from your test cases are the way to go.

The currently library is strongly coupled HA-Proxy, meaning that
in order to execute tests haproxy must be running locally. This
change adds an interface (HAProxy) that allows us to then stub out
the calls to RunCommand.

Note: If you're to go this route, README will need to be updated as
the Info and Stats methods are no longer pointer receivers, but instead
receiving the HAProxyClient as an argument. For example

    client := HAProxyClient{Addr: "tcp://blah:64738"}
    info, err := Info(client) {
        ...
    }
    ...

// Equivalent to HAProxy "show info" command.
func (h *HAProxyClient) Info() (*Info, error) {
func Info(h HAProxy) (*InfoResponse, error) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a breaking change to the existing API. It may be trivial but is worth noting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants