-
-
Notifications
You must be signed in to change notification settings - Fork 14
/
general_test.go
82 lines (68 loc) · 1.84 KB
/
general_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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
package cachet
import (
"fmt"
"net/http"
"reflect"
"testing"
)
func TestGeneralService_Ping(t *testing.T) {
setup()
defer teardown()
testMux.HandleFunc("/api/v1/ping", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
fmt.Fprint(w, `{"data": "Pong!"}`)
})
got, _, err := testClient.General.Ping()
if err != nil {
t.Errorf("General.Ping returned error: %v", err)
}
expected := "Pong!"
if !reflect.DeepEqual(got, expected) {
t.Errorf("General.Ping returned %+v, want %+v", got, expected)
}
}
func TestGeneralService_Version(t *testing.T) {
setup()
defer teardown()
testMux.HandleFunc("/api/v1/version", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
fmt.Fprint(w, `{"meta":{"on_latest":true,"latest":{"tag_name":"v2.4.0","prelease":false,"draft":false}},"data":"2.4.0"}`)
})
got, _, err := testClient.General.Version()
if err != nil {
t.Errorf("General.Version returned error: %v", err)
}
expected := &VersionResponse{
Meta: MetaVersion{
OnLatest: true,
Latest: Latest{
TagName: "v2.4.0",
Prelease: false,
Draft: false,
},
},
Data: "2.4.0",
}
if !reflect.DeepEqual(got, expected) {
t.Errorf("General.Version returned %+v, want %+v", got, expected)
}
}
func TestGeneralService_Status(t *testing.T) {
setup()
defer teardown()
testMux.HandleFunc("/api/v1/status", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
fmt.Fprint(w, `{"data":{"status":"info","message":"Some systems are experiencing issues"}}`)
})
got, _, err := testClient.General.Status()
if err != nil {
t.Errorf("General.Status returned error: %v", err)
}
expected := &Status{
Status: "info",
Message: "Some systems are experiencing issues",
}
if !reflect.DeepEqual(got, expected) {
t.Errorf("General.Status returned %+v, want %+v", got, expected)
}
}