mirror of
https://github.com/eosswedenorg/antelope-api-healthcheck
synced 2026-06-17 04:50:02 +02:00
Adding src/api/debug_test.go
This commit is contained in:
parent
0349999540
commit
bc6f857c1e
1 changed files with 56 additions and 0 deletions
56
src/api/debug_test.go
Normal file
56
src/api/debug_test.go
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
package api
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"testing"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/eosswedenorg-go/haproxy/agentcheck"
|
||||
)
|
||||
|
||||
func TestNewDebugApi(t *testing.T) {
|
||||
type args struct {
|
||||
response string
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
args args
|
||||
want DebugApi
|
||||
}{
|
||||
{"Up", args{"up"}, DebugApi{response: agentcheck.NewStatusResponse(agentcheck.Up)}},
|
||||
{"Down", args{"down"}, DebugApi{response: agentcheck.NewStatusResponse("down")}},
|
||||
{"DownMessage", args{"down#some message"}, DebugApi{response: agentcheck.NewStatusMessageResponse(agentcheck.Down, "some message")}},
|
||||
{"Ready", args{"ready"}, DebugApi{response: agentcheck.NewStatusResponse(agentcheck.Ready)}},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
if got := NewDebugApi(tt.args.response); !reflect.DeepEqual(got, tt.want) {
|
||||
t.Errorf("NewDebugApi() = %v, want %v", got, tt.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestDebugApi_LogInfo(t *testing.T) {
|
||||
|
||||
expected := LogParams{"type", "Debug", "response", "up"}
|
||||
|
||||
api := DebugApi{
|
||||
response: agentcheck.NewStatusResponse(agentcheck.Up),
|
||||
}
|
||||
|
||||
assert.Equal(t, api.LogInfo(), expected)
|
||||
}
|
||||
|
||||
func TestDebugApi_Call(t *testing.T) {
|
||||
|
||||
expected := agentcheck.NewStatusMessageResponse(agentcheck.Stopped, "message")
|
||||
|
||||
api := DebugApi{
|
||||
response: expected,
|
||||
}
|
||||
|
||||
response, msg := api.Call()
|
||||
|
||||
assert.Equal(t, response, expected)
|
||||
assert.Equal(t, msg, "")
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue