Skip to content

Commit 2f71122

Browse files
committed
On premise/Status category: Added an additional test check
1 parent b868203 commit 2f71122

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

onpremise/statuscategory_test.go

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,26 @@ import (
1111
func TestStatusCategoryService_GetList(t *testing.T) {
1212
setup()
1313
defer teardown()
14-
testAPIEdpoint := "/rest/api/2/statuscategory"
14+
testAPIEndpoint := "/rest/api/2/statuscategory"
1515

1616
raw, err := os.ReadFile("../testing/mock-data/all_statuscategories.json")
1717
if err != nil {
1818
t.Error(err.Error())
1919
}
20-
testMux.HandleFunc(testAPIEdpoint, func(w http.ResponseWriter, r *http.Request) {
20+
21+
testMux.HandleFunc(testAPIEndpoint, func(w http.ResponseWriter, r *http.Request) {
2122
testMethod(t, r, http.MethodGet)
22-
testRequestURL(t, r, testAPIEdpoint)
23+
testRequestURL(t, r, testAPIEndpoint)
2324
fmt.Fprint(w, string(raw))
2425
})
2526

2627
statusCategory, _, err := testClient.StatusCategory.GetList(context.Background())
2728
if statusCategory == nil {
2829
t.Error("Expected statusCategory list. StatusCategory list is nil")
2930
}
31+
if l := len(statusCategory); l != 4 {
32+
t.Errorf("Expected 4 statusCategory list items. Got %d", l)
33+
}
3034
if err != nil {
3135
t.Errorf("Error given: %s", err)
3236
}
@@ -41,17 +45,22 @@ func TestStatusCategoryService_Get(t *testing.T) {
4145
if err != nil {
4246
t.Error(err.Error())
4347
}
48+
4449
testMux.HandleFunc(testAPIEndpoint, func(w http.ResponseWriter, r *http.Request) {
4550
testMethod(t, r, http.MethodGet)
4651
testRequestURL(t, r, testAPIEndpoint)
4752
fmt.Fprint(w, string(raw))
4853
})
4954

5055
statusCategory, _, err := testClient.StatusCategory.Get(context.Background(), "1")
51-
5256
if err != nil {
5357
t.Errorf("Error given: %s", err)
58+
5459
} else if statusCategory == nil {
5560
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)
5665
}
5766
}

0 commit comments

Comments
 (0)