@@ -10,8 +10,9 @@ import (
10
10
"encoding/json"
11
11
"fmt"
12
12
"net/http"
13
- "reflect"
14
13
"testing"
14
+
15
+ "github.com/google/go-cmp/cmp"
15
16
)
16
17
17
18
func TestOrganizationsService_GetCodeSecurityConfigurations (t * testing.T ) {
@@ -43,7 +44,7 @@ func TestOrganizationsService_GetCodeSecurityConfigurations(t *testing.T) {
43
44
{ID : Ptr (int64 (1 )), Name : Ptr ("config1" ), CodeScanningDefaultSetup : Ptr ("enabled" )},
44
45
{ID : Ptr (int64 (2 )), Name : Ptr ("config2" ), PrivateVulnerabilityReporting : Ptr ("enabled" )},
45
46
}
46
- if ! reflect . DeepEqual (configurations , want ) {
47
+ if ! cmp . Equal (configurations , want ) {
47
48
t .Errorf ("Organizations.GetCodeSecurityConfigurations returned %+v, want %+v" , configurations , want )
48
49
}
49
50
const methodName = "GetCodeSecurityConfigurations"
@@ -80,7 +81,7 @@ func TestOrganizationsService_GetCodeSecurityConfiguration(t *testing.T) {
80
81
}
81
82
82
83
want := & CodeSecurityConfiguration {ID : Ptr (int64 (1 )), Name : Ptr ("config1" ), CodeScanningDefaultSetup : Ptr ("enabled" )}
83
- if ! reflect . DeepEqual (configuration , want ) {
84
+ if ! cmp . Equal (configuration , want ) {
84
85
t .Errorf ("Organizations.GetCodeSecurityConfiguration returned %+v, want %+v" , configuration , want )
85
86
}
86
87
@@ -113,7 +114,7 @@ func TestOrganizationsService_CreateCodeSecurityConfiguration(t *testing.T) {
113
114
v := new (CodeSecurityConfiguration )
114
115
assertNilError (t , json .NewDecoder (r .Body ).Decode (v ))
115
116
116
- if ! reflect . DeepEqual (v , input ) {
117
+ if ! cmp . Equal (v , input ) {
117
118
t .Errorf ("Organizations.CreateCodeSecurityConfiguration request body = %+v, want %+v" , v , input )
118
119
}
119
120
@@ -130,7 +131,7 @@ func TestOrganizationsService_CreateCodeSecurityConfiguration(t *testing.T) {
130
131
}
131
132
132
133
want := & CodeSecurityConfiguration {ID : Ptr (int64 (1 )), Name : Ptr ("config1" ), CodeScanningDefaultSetup : Ptr ("enabled" )}
133
- if ! reflect . DeepEqual (configuration , want ) {
134
+ if ! cmp . Equal (configuration , want ) {
134
135
t .Errorf ("Organizations.CreateCodeSecurityConfiguration returned %+v, want %+v" , configuration , want )
135
136
}
136
137
@@ -178,7 +179,7 @@ func TestOrganizationsService_GetDefaultCodeSecurityConfigurations(t *testing.T)
178
179
{ID : Ptr (int64 (1 )), Name : Ptr ("config1" ), CodeScanningDefaultSetup : Ptr ("enabled" )},
179
180
{ID : Ptr (int64 (2 )), Name : Ptr ("config2" ), PrivateVulnerabilityReporting : Ptr ("enabled" )},
180
181
}
181
- if ! reflect . DeepEqual (configurations , want ) {
182
+ if ! cmp . Equal (configurations , want ) {
182
183
t .Errorf ("Organizations.GetDefaultCodeSecurityConfigurations returned %+v, want %+v" , configurations , want )
183
184
}
184
185
@@ -243,7 +244,7 @@ func TestOrganizationsService_UpdateCodeSecurityConfiguration(t *testing.T) {
243
244
v := new (CodeSecurityConfiguration )
244
245
assertNilError (t , json .NewDecoder (r .Body ).Decode (v ))
245
246
246
- if ! reflect . DeepEqual (v , input ) {
247
+ if ! cmp . Equal (v , input ) {
247
248
t .Errorf ("Organizations.UpdateCodeSecurityConfiguration request body = %+v, want %+v" , v , input )
248
249
}
249
250
@@ -260,7 +261,7 @@ func TestOrganizationsService_UpdateCodeSecurityConfiguration(t *testing.T) {
260
261
}
261
262
262
263
want := & CodeSecurityConfiguration {ID : Ptr (int64 (1 )), Name : Ptr ("config1" ), CodeScanningDefaultSetup : Ptr ("enabled" )}
263
- if ! reflect . DeepEqual (configuration , want ) {
264
+ if ! cmp . Equal (configuration , want ) {
264
265
t .Errorf ("Organizations.UpdateCodeSecurityConfiguration returned %+v, want %+v" , configuration , want )
265
266
}
266
267
@@ -327,7 +328,7 @@ func TestOrganizationsService_AttachCodeSecurityConfigurationsToRepositories(t *
327
328
if v .Scope != "selected" {
328
329
t .Errorf ("Organizations.AttachCodeSecurityConfigurationsToRepositories request body scope = %s, want selected" , v .Scope )
329
330
}
330
- if ! reflect . DeepEqual (v .SelectedRepositoryIDs , []int64 {5 , 20 }) {
331
+ if ! cmp . Equal (v .SelectedRepositoryIDs , []int64 {5 , 20 }) {
331
332
t .Errorf ("Organizations.AttachCodeSecurityConfigurationsToRepositories request body selected_repository_ids = %+v, want %+v" , v .SelectedRepositoryIDs , []int64 {5 , 20 })
332
333
}
333
334
w .WriteHeader (http .StatusAccepted )
@@ -387,7 +388,7 @@ func TestOrganizationsService_SetDefaultCodeSecurityConfiguration(t *testing.T)
387
388
ID : Ptr (int64 (1 )), Name : Ptr ("config1" ), CodeScanningDefaultSetup : Ptr ("enabled" ),
388
389
},
389
390
}
390
- if ! reflect . DeepEqual (got , want ) {
391
+ if ! cmp . Equal (got , want ) {
391
392
t .Errorf ("Organizations.SetDefaultCodeSecurityConfiguration returned %+v, want %+v" , got , want )
392
393
}
393
394
@@ -433,7 +434,7 @@ func TestOrganizationsService_GetRepositoriesForCodeSecurityConfiguration(t *tes
433
434
{ID : Ptr (int64 (8 )), Name : Ptr ("repo8" )},
434
435
{ID : Ptr (int64 (42 )), Name : Ptr ("repo42" )},
435
436
}
436
- if ! reflect . DeepEqual (repositories , want ) {
437
+ if ! cmp . Equal (repositories , want ) {
437
438
t .Errorf ("Organizations.GetRepositoriesForCodeSecurityConfiguration returned %+v, want %+v" , repositories , want )
438
439
}
439
440
@@ -478,7 +479,7 @@ func TestOrganizationsService_GetCodeSecurityConfigurationForRepository(t *testi
478
479
State : Ptr ("attached" ),
479
480
Configuration : c ,
480
481
}
481
- if ! reflect . DeepEqual (rc , want ) {
482
+ if ! cmp . Equal (rc , want ) {
482
483
t .Errorf ("Organizations.GetCodeSecurityConfigurationForRepository returned %+v, want %+v" , rc , want )
483
484
}
484
485
0 commit comments