-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathstatus_test.go
73 lines (67 loc) · 1.49 KB
/
status_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
package radarr
import (
"encoding/json"
"net/http"
"reflect"
"testing"
)
func Test_newSystemStatusService(t *testing.T) {
type args struct {
s *Service
}
s := &Service{client: http.DefaultClient, url: dummyURL}
tests := []struct {
name string
args args
want *SystemStatusService
}{
{
name: "Constructor",
args: args{s},
want: &SystemStatusService{s},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := newSystemStatusService(tt.args.s); !reflect.DeepEqual(got, tt.want) {
t.Errorf("newSystemStatusService() = %v, want %v", got, tt.want)
}
})
}
}
func TestSystemStatusService_Get(t *testing.T) {
var expectedStatus *SystemStatus
if err := json.NewDecoder(dummySystemStatusResponse().Body).Decode(&expectedStatus); err != nil {
t.Fatal(err)
}
goodService := newSystemStatusService(&Service{
client: dummyHTTPClient,
url: dummyURL,
})
tests := []struct {
name string
service *Service
want *SystemStatus
wantErr bool
}{
{
name: "Same response",
service: goodService.s,
want: expectedStatus,
wantErr: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
s := &SystemStatusService{tt.service}
got, err := s.Get()
if (err != nil) != tt.wantErr {
t.Errorf("SystemStatusService.Get() error = %v, wantErr %v", err, tt.wantErr)
return
}
if !reflect.DeepEqual(got, tt.want) {
t.Errorf("SystemStatusService.Get() = %v, want %v", got, tt.want)
}
})
}
}