@@ -10,8 +10,9 @@ import (
1010 "encoding/json"
1111 "fmt"
1212 "net/http"
13- "reflect"
1413 "testing"
14+
15+ "github.com/google/go-cmp/cmp"
1516)
1617
1718func TestOrganizationsService_GetCodeSecurityConfigurations (t * testing.T ) {
@@ -43,7 +44,7 @@ func TestOrganizationsService_GetCodeSecurityConfigurations(t *testing.T) {
4344 {ID : Ptr (int64 (1 )), Name : Ptr ("config1" ), CodeScanningDefaultSetup : Ptr ("enabled" )},
4445 {ID : Ptr (int64 (2 )), Name : Ptr ("config2" ), PrivateVulnerabilityReporting : Ptr ("enabled" )},
4546 }
46- if ! reflect . DeepEqual (configurations , want ) {
47+ if ! cmp . Equal (configurations , want ) {
4748 t .Errorf ("Organizations.GetCodeSecurityConfigurations returned %+v, want %+v" , configurations , want )
4849 }
4950 const methodName = "GetCodeSecurityConfigurations"
@@ -80,7 +81,7 @@ func TestOrganizationsService_GetCodeSecurityConfiguration(t *testing.T) {
8081 }
8182
8283 want := & CodeSecurityConfiguration {ID : Ptr (int64 (1 )), Name : Ptr ("config1" ), CodeScanningDefaultSetup : Ptr ("enabled" )}
83- if ! reflect . DeepEqual (configuration , want ) {
84+ if ! cmp . Equal (configuration , want ) {
8485 t .Errorf ("Organizations.GetCodeSecurityConfiguration returned %+v, want %+v" , configuration , want )
8586 }
8687
@@ -113,7 +114,7 @@ func TestOrganizationsService_CreateCodeSecurityConfiguration(t *testing.T) {
113114 v := new (CodeSecurityConfiguration )
114115 assertNilError (t , json .NewDecoder (r .Body ).Decode (v ))
115116
116- if ! reflect . DeepEqual (v , input ) {
117+ if ! cmp . Equal (v , input ) {
117118 t .Errorf ("Organizations.CreateCodeSecurityConfiguration request body = %+v, want %+v" , v , input )
118119 }
119120
@@ -130,7 +131,7 @@ func TestOrganizationsService_CreateCodeSecurityConfiguration(t *testing.T) {
130131 }
131132
132133 want := & CodeSecurityConfiguration {ID : Ptr (int64 (1 )), Name : Ptr ("config1" ), CodeScanningDefaultSetup : Ptr ("enabled" )}
133- if ! reflect . DeepEqual (configuration , want ) {
134+ if ! cmp . Equal (configuration , want ) {
134135 t .Errorf ("Organizations.CreateCodeSecurityConfiguration returned %+v, want %+v" , configuration , want )
135136 }
136137
@@ -178,7 +179,7 @@ func TestOrganizationsService_GetDefaultCodeSecurityConfigurations(t *testing.T)
178179 {ID : Ptr (int64 (1 )), Name : Ptr ("config1" ), CodeScanningDefaultSetup : Ptr ("enabled" )},
179180 {ID : Ptr (int64 (2 )), Name : Ptr ("config2" ), PrivateVulnerabilityReporting : Ptr ("enabled" )},
180181 }
181- if ! reflect . DeepEqual (configurations , want ) {
182+ if ! cmp . Equal (configurations , want ) {
182183 t .Errorf ("Organizations.GetDefaultCodeSecurityConfigurations returned %+v, want %+v" , configurations , want )
183184 }
184185
@@ -243,7 +244,7 @@ func TestOrganizationsService_UpdateCodeSecurityConfiguration(t *testing.T) {
243244 v := new (CodeSecurityConfiguration )
244245 assertNilError (t , json .NewDecoder (r .Body ).Decode (v ))
245246
246- if ! reflect . DeepEqual (v , input ) {
247+ if ! cmp . Equal (v , input ) {
247248 t .Errorf ("Organizations.UpdateCodeSecurityConfiguration request body = %+v, want %+v" , v , input )
248249 }
249250
@@ -260,7 +261,7 @@ func TestOrganizationsService_UpdateCodeSecurityConfiguration(t *testing.T) {
260261 }
261262
262263 want := & CodeSecurityConfiguration {ID : Ptr (int64 (1 )), Name : Ptr ("config1" ), CodeScanningDefaultSetup : Ptr ("enabled" )}
263- if ! reflect . DeepEqual (configuration , want ) {
264+ if ! cmp . Equal (configuration , want ) {
264265 t .Errorf ("Organizations.UpdateCodeSecurityConfiguration returned %+v, want %+v" , configuration , want )
265266 }
266267
@@ -327,7 +328,7 @@ func TestOrganizationsService_AttachCodeSecurityConfigurationsToRepositories(t *
327328 if v .Scope != "selected" {
328329 t .Errorf ("Organizations.AttachCodeSecurityConfigurationsToRepositories request body scope = %s, want selected" , v .Scope )
329330 }
330- if ! reflect . DeepEqual (v .SelectedRepositoryIDs , []int64 {5 , 20 }) {
331+ if ! cmp . Equal (v .SelectedRepositoryIDs , []int64 {5 , 20 }) {
331332 t .Errorf ("Organizations.AttachCodeSecurityConfigurationsToRepositories request body selected_repository_ids = %+v, want %+v" , v .SelectedRepositoryIDs , []int64 {5 , 20 })
332333 }
333334 w .WriteHeader (http .StatusAccepted )
@@ -387,7 +388,7 @@ func TestOrganizationsService_SetDefaultCodeSecurityConfiguration(t *testing.T)
387388 ID : Ptr (int64 (1 )), Name : Ptr ("config1" ), CodeScanningDefaultSetup : Ptr ("enabled" ),
388389 },
389390 }
390- if ! reflect . DeepEqual (got , want ) {
391+ if ! cmp . Equal (got , want ) {
391392 t .Errorf ("Organizations.SetDefaultCodeSecurityConfiguration returned %+v, want %+v" , got , want )
392393 }
393394
@@ -433,7 +434,7 @@ func TestOrganizationsService_GetRepositoriesForCodeSecurityConfiguration(t *tes
433434 {ID : Ptr (int64 (8 )), Name : Ptr ("repo8" )},
434435 {ID : Ptr (int64 (42 )), Name : Ptr ("repo42" )},
435436 }
436- if ! reflect . DeepEqual (repositories , want ) {
437+ if ! cmp . Equal (repositories , want ) {
437438 t .Errorf ("Organizations.GetRepositoriesForCodeSecurityConfiguration returned %+v, want %+v" , repositories , want )
438439 }
439440
@@ -478,7 +479,7 @@ func TestOrganizationsService_GetCodeSecurityConfigurationForRepository(t *testi
478479 State : Ptr ("attached" ),
479480 Configuration : c ,
480481 }
481- if ! reflect . DeepEqual (rc , want ) {
482+ if ! cmp . Equal (rc , want ) {
482483 t .Errorf ("Organizations.GetCodeSecurityConfigurationForRepository returned %+v, want %+v" , rc , want )
483484 }
484485
0 commit comments