diff --git a/src/api/debug.go b/src/api/debug.go index f6a0fef..a9fa905 100644 --- a/src/api/debug.go +++ b/src/api/debug.go @@ -25,6 +25,10 @@ func parseResponse(resp string) (agentcheck.Response, error) { return agentcheck.NewStatusResponse(rtype), nil } +func DebugApiFactory(args ApiArguments) ApiInterface { + return NewDebugApi(args.Url) +} + func NewDebugApi(response string) DebugApi { resp, _ := parseResponse(response) diff --git a/src/api/debug_test.go b/src/api/debug_test.go index 12078d1..d262cf3 100644 --- a/src/api/debug_test.go +++ b/src/api/debug_test.go @@ -7,6 +7,18 @@ import ( "github.com/eosswedenorg-go/haproxy/agentcheck" ) +func TestDebugApiFactory(t *testing.T) { + + api := DebugApiFactory(ApiArguments{ + Url: "up", + Host: "host", + NumBlocks: 40, + }) + + assert.IsType(t, DebugApi{}, api) + assert.Equal(t, api.(DebugApi).response, agentcheck.NewStatusResponse(agentcheck.Up)) +} + func TestNewDebugApi(t *testing.T) { type args struct { response string