mirror of
https://github.com/eosswedenorg/antelope-api-healthcheck
synced 2026-07-04 12:03:43 +02:00
src/api/debug.go: Adding DebugApiFactory function
This commit is contained in:
parent
6e8ffe718e
commit
39927a2441
2 changed files with 16 additions and 0 deletions
|
|
@ -25,6 +25,10 @@ func parseResponse(resp string) (agentcheck.Response, error) {
|
||||||
return agentcheck.NewStatusResponse(rtype), nil
|
return agentcheck.NewStatusResponse(rtype), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func DebugApiFactory(args ApiArguments) ApiInterface {
|
||||||
|
return NewDebugApi(args.Url)
|
||||||
|
}
|
||||||
|
|
||||||
func NewDebugApi(response string) DebugApi {
|
func NewDebugApi(response string) DebugApi {
|
||||||
|
|
||||||
resp, _ := parseResponse(response)
|
resp, _ := parseResponse(response)
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,18 @@ import (
|
||||||
"github.com/eosswedenorg-go/haproxy/agentcheck"
|
"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) {
|
func TestNewDebugApi(t *testing.T) {
|
||||||
type args struct {
|
type args struct {
|
||||||
response string
|
response string
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue