-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhealth_test.go
43 lines (36 loc) · 992 Bytes
/
health_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package main
import (
"context"
"gopkg.in/h2non/gock.v1"
"testing"
)
func Test_accountClient_GetHealth_up(t *testing.T) {
defer gock.Off()
gock.New("http://server.com").
Get("/v1/health").
Reply(200).
JSON(map[string]string{"status": "up"})
accountClient, err := NewAccountClient("http", "server.com", 80, 1)
if err != nil {
t.Errorf("expected no error but got %v", err)
}
err = accountClient.Health(context.TODO())
if err != nil {
t.Errorf("expected no error but got %v", err)
}
}
func Test_accountClient_GetHealth_down(t *testing.T) {
defer gock.Off()
gock.New("http://server.com").
Get("/v1/health").
Reply(200).
JSON(map[string]string{"status": "down"})
accountClient, err := NewAccountClient("http", "server.com", 80, 1)
if err != nil {
t.Errorf("expected no error but got %v", err)
}
err = accountClient.Health(context.TODO())
if _, ok := err.(ErrRemoteGatewayFailure); ok {
t.Errorf("expected remote gateway failure but was %v", err)
}
}