@@ -11,22 +11,26 @@ import (
11
11
func TestStatusCategoryService_GetList (t * testing.T ) {
12
12
setup ()
13
13
defer teardown ()
14
- testAPIEdpoint := "/rest/api/2/statuscategory"
14
+ testAPIEndpoint := "/rest/api/2/statuscategory"
15
15
16
16
raw , err := os .ReadFile ("../testing/mock-data/all_statuscategories.json" )
17
17
if err != nil {
18
18
t .Error (err .Error ())
19
19
}
20
- testMux .HandleFunc (testAPIEdpoint , func (w http.ResponseWriter , r * http.Request ) {
20
+
21
+ testMux .HandleFunc (testAPIEndpoint , func (w http.ResponseWriter , r * http.Request ) {
21
22
testMethod (t , r , http .MethodGet )
22
- testRequestURL (t , r , testAPIEdpoint )
23
+ testRequestURL (t , r , testAPIEndpoint )
23
24
fmt .Fprint (w , string (raw ))
24
25
})
25
26
26
27
statusCategory , _ , err := testClient .StatusCategory .GetList (context .Background ())
27
28
if statusCategory == nil {
28
29
t .Error ("Expected statusCategory list. StatusCategory list is nil" )
29
30
}
31
+ if l := len (statusCategory ); l != 4 {
32
+ t .Errorf ("Expected 4 statusCategory list items. Got %d" , l )
33
+ }
30
34
if err != nil {
31
35
t .Errorf ("Error given: %s" , err )
32
36
}
@@ -41,17 +45,22 @@ func TestStatusCategoryService_Get(t *testing.T) {
41
45
if err != nil {
42
46
t .Error (err .Error ())
43
47
}
48
+
44
49
testMux .HandleFunc (testAPIEndpoint , func (w http.ResponseWriter , r * http.Request ) {
45
50
testMethod (t , r , http .MethodGet )
46
51
testRequestURL (t , r , testAPIEndpoint )
47
52
fmt .Fprint (w , string (raw ))
48
53
})
49
54
50
55
statusCategory , _ , err := testClient .StatusCategory .Get (context .Background (), "1" )
51
-
52
56
if err != nil {
53
57
t .Errorf ("Error given: %s" , err )
58
+
54
59
} else if statusCategory == nil {
55
60
t .Error ("Expected status category. StatusCategory is nil" )
61
+
62
+ // Checking testdata
63
+ } else if statusCategory .ColorName != "medium-gray" {
64
+ t .Errorf ("Expected statusCategory.ColorName to be 'medium-gray'. Got '%s'" , statusCategory .ColorName )
56
65
}
57
66
}
0 commit comments