Skip to content

Commit a4fbf26

Browse files
committed
fix some posible nil reference
1 parent 3017996 commit a4fbf26

File tree

2 files changed

+7
-21
lines changed

2 files changed

+7
-21
lines changed

organization_test.go

+6-18
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,7 @@ func TestOrganizationService_GetAllOrganizationsWithContext(t *testing.T) {
2222

2323
if result == nil {
2424
t.Error("Expected Organizations. Result is nil")
25-
}
26-
27-
if result.Size != 1 {
25+
} else if result.Size != 1 {
2826
t.Errorf("Expected size to be 1, but got %d", result.Size)
2927
}
3028

@@ -51,9 +49,7 @@ func TestOrganizationService_CreateOrganization(t *testing.T) {
5149

5250
if o == nil {
5351
t.Error("Expected Organization. Result is nil")
54-
}
55-
56-
if o.Name != name {
52+
} else if o.Name != name {
5753
t.Errorf("Expected name to be %s, but got %s", name, o.Name)
5854
}
5955

@@ -82,9 +78,7 @@ func TestOrganizationService_GetOrganization(t *testing.T) {
8278

8379
if o == nil {
8480
t.Error("Expected Organization. Result is nil")
85-
}
86-
87-
if o.Name != "name" {
81+
} else if o.Name != "name" {
8882
t.Errorf("Expected name to be name, but got %s", o.Name)
8983
}
9084
}
@@ -132,9 +126,7 @@ func TestOrganizationService_GetPropertiesKeys(t *testing.T) {
132126

133127
if pk == nil {
134128
t.Error("Expected Keys. Result is nil")
135-
}
136-
137-
if pk.Keys[0].Key != "organization.attributes" {
129+
} else if pk.Keys[0].Key != "organization.attributes" {
138130
t.Errorf("Expected name to be organization.attributes, but got %s", pk.Keys[0].Key)
139131
}
140132
}
@@ -165,9 +157,7 @@ func TestOrganizationService_GetProperty(t *testing.T) {
165157

166158
if ep == nil {
167159
t.Error("Expected Entity. Result is nil")
168-
}
169-
170-
if ep.Key != key {
160+
} else if ep.Key != key {
171161
t.Errorf("Expected name to be %s, but got %s", key, ep.Key)
172162
}
173163
}
@@ -279,9 +269,7 @@ func TestOrganizationService_GetUsers(t *testing.T) {
279269

280270
if users == nil {
281271
t.Error("Expected Organizations. Result is nil")
282-
}
283-
284-
if users.Size != 1 {
272+
} else if users.Size != 1 {
285273
t.Errorf("Expected size to be 1, but got %d", users.Size)
286274
}
287275

servicedesk_test.go

+1-3
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,7 @@ func TestServiceDeskService_GetOrganizations(t *testing.T) {
5656

5757
if orgs == nil {
5858
t.Error("Expected Organizations. Result is nil")
59-
}
60-
61-
if orgs.Size != 3 {
59+
} else if orgs.Size != 3 {
6260
t.Errorf("Expected size to be 3, but got %d", orgs.Size)
6361
}
6462

0 commit comments

Comments
 (0)