Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 51e7595

Browse filesBrowse files
authored
fix: Updated comparisons in test files (#1875)
Replaced all reflect.DeepEqual comparisons in test files with cmp.Equal. Fixes: #1851
1 parent 0318e77 commit 51e7595
Copy full SHA for 51e7595

File tree

103 files changed

+848
-744
lines changed
Filter options

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Dismiss banner

103 files changed

+848
-744
lines changed

‎github/actions_artifacts_test.go

Copy file name to clipboardExpand all lines: github/actions_artifacts_test.go
+5-4Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@ import (
1010
"fmt"
1111
"net/http"
1212
"net/url"
13-
"reflect"
1413
"testing"
14+
15+
"github.com/google/go-cmp/cmp"
1516
)
1617

1718
func TestActionsService_ListArtifacts(t *testing.T) {
@@ -37,7 +38,7 @@ func TestActionsService_ListArtifacts(t *testing.T) {
3738
}
3839

3940
want := &ArtifactList{TotalCount: Int64(1), Artifacts: []*Artifact{{ID: Int64(1)}}}
40-
if !reflect.DeepEqual(artifacts, want) {
41+
if !cmp.Equal(artifacts, want) {
4142
t.Errorf("Actions.ListArtifacts returned %+v, want %+v", artifacts, want)
4243
}
4344

@@ -119,7 +120,7 @@ func TestActionsService_ListWorkflowRunArtifacts(t *testing.T) {
119120
}
120121

121122
want := &ArtifactList{TotalCount: Int64(1), Artifacts: []*Artifact{{ID: Int64(1)}}}
122-
if !reflect.DeepEqual(artifacts, want) {
123+
if !cmp.Equal(artifacts, want) {
123124
t.Errorf("Actions.ListWorkflowRunArtifacts returned %+v, want %+v", artifacts, want)
124125
}
125126

@@ -206,7 +207,7 @@ func TestActionsService_GetArtifact(t *testing.T) {
206207
SizeInBytes: Int64(5),
207208
ArchiveDownloadURL: String("u"),
208209
}
209-
if !reflect.DeepEqual(artifact, want) {
210+
if !cmp.Equal(artifact, want) {
210211
t.Errorf("Actions.GetArtifact returned %+v, want %+v", artifact, want)
211212
}
212213

‎github/actions_runner_groups_test.go

Copy file name to clipboardExpand all lines: github/actions_runner_groups_test.go
+8-7Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ import (
99
"context"
1010
"fmt"
1111
"net/http"
12-
"reflect"
1312
"testing"
13+
14+
"github.com/google/go-cmp/cmp"
1415
)
1516

1617
func TestActionsService_ListOrganizationRunnerGroups(t *testing.T) {
@@ -38,7 +39,7 @@ func TestActionsService_ListOrganizationRunnerGroups(t *testing.T) {
3839
{ID: Int64(3), Name: String("expensive-hardware"), Visibility: String("private"), Default: Bool(false), RunnersURL: String("https://api.github.com/orgs/octo-org/actions/runner_groups/3/runners"), Inherited: Bool(false), AllowsPublicRepositories: Bool(true)},
3940
},
4041
}
41-
if !reflect.DeepEqual(groups, want) {
42+
if !cmp.Equal(groups, want) {
4243
t.Errorf("Actions.ListOrganizationRunnerGroups returned %+v, want %+v", groups, want)
4344
}
4445

@@ -83,7 +84,7 @@ func TestActionsService_GetOrganizationRunnerGroup(t *testing.T) {
8384
AllowsPublicRepositories: Bool(true),
8485
}
8586

86-
if !reflect.DeepEqual(group, want) {
87+
if !cmp.Equal(group, want) {
8788
t.Errorf("Actions.GetOrganizationRunnerGroup returned %+v, want %+v", group, want)
8889
}
8990

@@ -157,7 +158,7 @@ func TestActionsService_CreateOrganizationRunnerGroup(t *testing.T) {
157158
AllowsPublicRepositories: Bool(true),
158159
}
159160

160-
if !reflect.DeepEqual(group, want) {
161+
if !cmp.Equal(group, want) {
161162
t.Errorf("Actions.CreateOrganizationRunnerGroup returned %+v, want %+v", group, want)
162163
}
163164

@@ -206,7 +207,7 @@ func TestActionsService_UpdateOrganizationRunnerGroup(t *testing.T) {
206207
AllowsPublicRepositories: Bool(true),
207208
}
208209

209-
if !reflect.DeepEqual(group, want) {
210+
if !cmp.Equal(group, want) {
210211
t.Errorf("Actions.UpdateOrganizationRunnerGroup returned %+v, want %+v", group, want)
211212
}
212213

@@ -246,7 +247,7 @@ func TestActionsService_ListRepositoryAccessRunnerGroup(t *testing.T) {
246247
{ID: Int64(43), NodeID: String("MDEwOlJlcG9zaXRvcnkxMjk2MjY5"), Name: String("Hello-World"), FullName: String("octocat/Hello-World")},
247248
},
248249
}
249-
if !reflect.DeepEqual(groups, want) {
250+
if !cmp.Equal(groups, want) {
250251
t.Errorf("Actions.ListRepositoryAccessRunnerGroup returned %+v, want %+v", groups, want)
251252
}
252253

@@ -371,7 +372,7 @@ func TestActionsService_ListRunerGroupRunners(t *testing.T) {
371372
{ID: Int64(24), Name: String("iMac"), OS: String("macos"), Status: String("offline")},
372373
},
373374
}
374-
if !reflect.DeepEqual(runners, want) {
375+
if !cmp.Equal(runners, want) {
375376
t.Errorf("Actions.ListRunerGroupRunners returned %+v, want %+v", runners, want)
376377
}
377378

‎github/actions_runners_test.go

Copy file name to clipboardExpand all lines: github/actions_runners_test.go
+13-12Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@ import (
99
"context"
1010
"fmt"
1111
"net/http"
12-
"reflect"
1312
"testing"
1413
"time"
14+
15+
"github.com/google/go-cmp/cmp"
1516
)
1617

1718
func TestActionsService_ListRunnerApplicationDownloads(t *testing.T) {
@@ -36,7 +37,7 @@ func TestActionsService_ListRunnerApplicationDownloads(t *testing.T) {
3637
{OS: String("win"), Architecture: String("x64"), DownloadURL: String("https://github.com/actions/runner/releases/download/v2.164.0/actions-runner-win-x64-2.164.0.zip"), Filename: String("actions-runner-win-x64-2.164.0.zip")},
3738
{OS: String("linux"), Architecture: String("arm64"), DownloadURL: String("https://github.com/actions/runner/releases/download/v2.164.0/actions-runner-linux-arm64-2.164.0.tar.gz"), Filename: String("actions-runner-linux-arm64-2.164.0.tar.gz")},
3839
}
39-
if !reflect.DeepEqual(downloads, want) {
40+
if !cmp.Equal(downloads, want) {
4041
t.Errorf("Actions.ListRunnerApplicationDownloads returned %+v, want %+v", downloads, want)
4142
}
4243

@@ -73,7 +74,7 @@ func TestActionsService_CreateRegistrationToken(t *testing.T) {
7374
want := &RegistrationToken{Token: String("LLBF3JGZDX3P5PMEXLND6TS6FCWO6"),
7475
ExpiresAt: &Timestamp{time.Date(2020, time.January, 22, 12, 13, 35,
7576
123000000, time.UTC)}}
76-
if !reflect.DeepEqual(token, want) {
77+
if !cmp.Equal(token, want) {
7778
t.Errorf("Actions.CreateRegistrationToken returned %+v, want %+v", token, want)
7879
}
7980

@@ -116,7 +117,7 @@ func TestActionsService_ListRunners(t *testing.T) {
116117
{ID: Int64(24), Name: String("iMac"), OS: String("macos"), Status: String("offline")},
117118
},
118119
}
119-
if !reflect.DeepEqual(runners, want) {
120+
if !cmp.Equal(runners, want) {
120121
t.Errorf("Actions.ListRunners returned %+v, want %+v", runners, want)
121122
}
122123

@@ -156,7 +157,7 @@ func TestActionsService_GetRunner(t *testing.T) {
156157
OS: String("macos"),
157158
Status: String("online"),
158159
}
159-
if !reflect.DeepEqual(runner, want) {
160+
if !cmp.Equal(runner, want) {
160161
t.Errorf("Actions.GetRunner returned %+v, want %+v", runner, want)
161162
}
162163

@@ -191,7 +192,7 @@ func TestActionsService_CreateRemoveToken(t *testing.T) {
191192
}
192193

193194
want := &RemoveToken{Token: String("AABF3JGZDX3P5PMEXLND6TS6FCWO6"), ExpiresAt: &Timestamp{time.Date(2020, time.January, 29, 12, 13, 35, 123000000, time.UTC)}}
194-
if !reflect.DeepEqual(token, want) {
195+
if !cmp.Equal(token, want) {
195196
t.Errorf("Actions.CreateRemoveToken returned %+v, want %+v", token, want)
196197
}
197198

@@ -257,7 +258,7 @@ func TestActionsService_ListOrganizationRunnerApplicationDownloads(t *testing.T)
257258
{OS: String("win"), Architecture: String("x64"), DownloadURL: String("https://github.com/actions/runner/releases/download/v2.164.0/actions-runner-win-x64-2.164.0.zip"), Filename: String("actions-runner-win-x64-2.164.0.zip")},
258259
{OS: String("linux"), Architecture: String("arm64"), DownloadURL: String("https://github.com/actions/runner/releases/download/v2.164.0/actions-runner-linux-arm64-2.164.0.tar.gz"), Filename: String("actions-runner-linux-arm64-2.164.0.tar.gz")},
259260
}
260-
if !reflect.DeepEqual(downloads, want) {
261+
if !cmp.Equal(downloads, want) {
261262
t.Errorf("Actions.ListOrganizationRunnerApplicationDownloads returned %+v, want %+v", downloads, want)
262263
}
263264

@@ -294,7 +295,7 @@ func TestActionsService_CreateOrganizationRegistrationToken(t *testing.T) {
294295
want := &RegistrationToken{Token: String("LLBF3JGZDX3P5PMEXLND6TS6FCWO6"),
295296
ExpiresAt: &Timestamp{time.Date(2020, time.January, 22, 12, 13, 35,
296297
123000000, time.UTC)}}
297-
if !reflect.DeepEqual(token, want) {
298+
if !cmp.Equal(token, want) {
298299
t.Errorf("Actions.CreateRegistrationToken returned %+v, want %+v", token, want)
299300
}
300301

@@ -337,7 +338,7 @@ func TestActionsService_ListOrganizationRunners(t *testing.T) {
337338
{ID: Int64(24), Name: String("iMac"), OS: String("macos"), Status: String("offline")},
338339
},
339340
}
340-
if !reflect.DeepEqual(runners, want) {
341+
if !cmp.Equal(runners, want) {
341342
t.Errorf("Actions.ListRunners returned %+v, want %+v", runners, want)
342343
}
343344

@@ -381,7 +382,7 @@ func TestActionsService_ListEnabledReposInOrg(t *testing.T) {
381382
{ID: Int64(2)},
382383
{ID: Int64(3)},
383384
}}
384-
if !reflect.DeepEqual(got, want) {
385+
if !cmp.Equal(got, want) {
385386
t.Errorf("Actions.ListEnabledReposInOrg returned %+v, want %+v", got, want)
386387
}
387388

@@ -421,7 +422,7 @@ func TestActionsService_GetOrganizationRunner(t *testing.T) {
421422
OS: String("macos"),
422423
Status: String("online"),
423424
}
424-
if !reflect.DeepEqual(runner, want) {
425+
if !cmp.Equal(runner, want) {
425426
t.Errorf("Actions.GetRunner returned %+v, want %+v", runner, want)
426427
}
427428

@@ -456,7 +457,7 @@ func TestActionsService_CreateOrganizationRemoveToken(t *testing.T) {
456457
}
457458

458459
want := &RemoveToken{Token: String("AABF3JGZDX3P5PMEXLND6TS6FCWO6"), ExpiresAt: &Timestamp{time.Date(2020, time.January, 29, 12, 13, 35, 123000000, time.UTC)}}
459-
if !reflect.DeepEqual(token, want) {
460+
if !cmp.Equal(token, want) {
460461
t.Errorf("Actions.CreateRemoveToken returned %+v, want %+v", token, want)
461462
}
462463

‎github/actions_secrets_test.go

Copy file name to clipboardExpand all lines: github/actions_secrets_test.go
+15-14Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@ import (
1010
"encoding/json"
1111
"fmt"
1212
"net/http"
13-
"reflect"
1413
"testing"
1514
"time"
15+
16+
"github.com/google/go-cmp/cmp"
1617
)
1718

1819
func TestPublicKey_UnmarshalJSON(t *testing.T) {
@@ -84,7 +85,7 @@ func TestPublicKey_UnmarshalJSON(t *testing.T) {
8485
if err != nil && !tt.wantErr {
8586
t.Errorf("PublicKey.UnmarshalJSON returned an unexpected error: %+v", err)
8687
}
87-
if !reflect.DeepEqual(tt.wantPublicKey, pk) {
88+
if !cmp.Equal(tt.wantPublicKey, pk) {
8889
t.Errorf("PublicKey.UnmarshalJSON expected public key %+v, got %+v", tt.wantPublicKey, pk)
8990
}
9091
})
@@ -107,7 +108,7 @@ func TestActionsService_GetRepoPublicKey(t *testing.T) {
107108
}
108109

109110
want := &PublicKey{KeyID: String("1234"), Key: String("2Sg8iYjAxxmI2LvUXpJjkYrMxURPc8r+dB7TJyvv1234")}
110-
if !reflect.DeepEqual(key, want) {
111+
if !cmp.Equal(key, want) {
111112
t.Errorf("Actions.GetRepoPublicKey returned %+v, want %+v", key, want)
112113
}
113114

@@ -142,7 +143,7 @@ func TestActionsService_GetRepoPublicKeyNumeric(t *testing.T) {
142143
}
143144

144145
want := &PublicKey{KeyID: String("1234"), Key: String("2Sg8iYjAxxmI2LvUXpJjkYrMxURPc8r+dB7TJyvv1234")}
145-
if !reflect.DeepEqual(key, want) {
146+
if !cmp.Equal(key, want) {
146147
t.Errorf("Actions.GetRepoPublicKey returned %+v, want %+v", key, want)
147148
}
148149

@@ -185,7 +186,7 @@ func TestActionsService_ListRepoSecrets(t *testing.T) {
185186
{Name: "B", CreatedAt: Timestamp{time.Date(2019, time.January, 02, 15, 04, 05, 0, time.UTC)}, UpdatedAt: Timestamp{time.Date(2020, time.January, 02, 15, 04, 05, 0, time.UTC)}},
186187
},
187188
}
188-
if !reflect.DeepEqual(secrets, want) {
189+
if !cmp.Equal(secrets, want) {
189190
t.Errorf("Actions.ListRepoSecrets returned %+v, want %+v", secrets, want)
190191
}
191192

@@ -224,7 +225,7 @@ func TestActionsService_GetRepoSecret(t *testing.T) {
224225
CreatedAt: Timestamp{time.Date(2019, time.January, 02, 15, 04, 05, 0, time.UTC)},
225226
UpdatedAt: Timestamp{time.Date(2020, time.January, 02, 15, 04, 05, 0, time.UTC)},
226227
}
227-
if !reflect.DeepEqual(secret, want) {
228+
if !cmp.Equal(secret, want) {
228229
t.Errorf("Actions.GetRepoSecret returned %+v, want %+v", secret, want)
229230
}
230231

@@ -317,7 +318,7 @@ func TestActionsService_GetOrgPublicKey(t *testing.T) {
317318
}
318319

319320
want := &PublicKey{KeyID: String("012345678"), Key: String("2Sg8iYjAxxmI2LvUXpJjkYrMxURPc8r+dB7TJyvv1234")}
320-
if !reflect.DeepEqual(key, want) {
321+
if !cmp.Equal(key, want) {
321322
t.Errorf("Actions.GetOrgPublicKey returned %+v, want %+v", key, want)
322323
}
323324

@@ -361,7 +362,7 @@ func TestActionsService_ListOrgSecrets(t *testing.T) {
361362
{Name: "GH_TOKEN", CreatedAt: Timestamp{time.Date(2019, time.August, 10, 14, 59, 22, 0, time.UTC)}, UpdatedAt: Timestamp{time.Date(2020, time.January, 10, 14, 59, 22, 0, time.UTC)}, Visibility: "selected", SelectedRepositoriesURL: "https://api.github.com/orgs/octo-org/actions/secrets/SUPER_SECRET/repositories"},
362363
},
363364
}
364-
if !reflect.DeepEqual(secrets, want) {
365+
if !cmp.Equal(secrets, want) {
365366
t.Errorf("Actions.ListOrgSecrets returned %+v, want %+v", secrets, want)
366367
}
367368

@@ -402,7 +403,7 @@ func TestActionsService_GetOrgSecret(t *testing.T) {
402403
Visibility: "selected",
403404
SelectedRepositoriesURL: "https://api.github.com/orgs/octo-org/actions/secrets/SUPER_SECRET/repositories",
404405
}
405-
if !reflect.DeepEqual(secret, want) {
406+
if !cmp.Equal(secret, want) {
406407
t.Errorf("Actions.GetOrgSecret returned %+v, want %+v", secret, want)
407408
}
408409

@@ -477,7 +478,7 @@ func TestActionsService_ListSelectedReposForOrgSecret(t *testing.T) {
477478
{ID: Int64(1)},
478479
},
479480
}
480-
if !reflect.DeepEqual(repos, want) {
481+
if !cmp.Equal(repos, want) {
481482
t.Errorf("Actions.ListSelectedReposForOrgSecret returned %+v, want %+v", repos, want)
482483
}
483484

@@ -615,7 +616,7 @@ func TestActionsService_GetEnvPublicKey(t *testing.T) {
615616
}
616617

617618
want := &PublicKey{KeyID: String("1234"), Key: String("2Sg8iYjAxxmI2LvUXpJjkYrMxURPc8r+dB7TJyvv1234")}
618-
if !reflect.DeepEqual(key, want) {
619+
if !cmp.Equal(key, want) {
619620
t.Errorf("Actions.GetEnvPublicKey returned %+v, want %+v", key, want)
620621
}
621622

@@ -650,7 +651,7 @@ func TestActionsService_GetEnvPublicKeyNumeric(t *testing.T) {
650651
}
651652

652653
want := &PublicKey{KeyID: String("1234"), Key: String("2Sg8iYjAxxmI2LvUXpJjkYrMxURPc8r+dB7TJyvv1234")}
653-
if !reflect.DeepEqual(key, want) {
654+
if !cmp.Equal(key, want) {
654655
t.Errorf("Actions.GetEnvPublicKey returned %+v, want %+v", key, want)
655656
}
656657

@@ -693,7 +694,7 @@ func TestActionsService_ListEnvSecrets(t *testing.T) {
693694
{Name: "B", CreatedAt: Timestamp{time.Date(2019, time.January, 02, 15, 04, 05, 0, time.UTC)}, UpdatedAt: Timestamp{time.Date(2020, time.January, 02, 15, 04, 05, 0, time.UTC)}},
694695
},
695696
}
696-
if !reflect.DeepEqual(secrets, want) {
697+
if !cmp.Equal(secrets, want) {
697698
t.Errorf("Actions.ListEnvSecrets returned %+v, want %+v", secrets, want)
698699
}
699700

@@ -732,7 +733,7 @@ func TestActionsService_GetEnvSecret(t *testing.T) {
732733
CreatedAt: Timestamp{time.Date(2019, time.January, 02, 15, 04, 05, 0, time.UTC)},
733734
UpdatedAt: Timestamp{time.Date(2020, time.January, 02, 15, 04, 05, 0, time.UTC)},
734735
}
735-
if !reflect.DeepEqual(secret, want) {
736+
if !cmp.Equal(secret, want) {
736737
t.Errorf("Actions.GetEnvSecret returned %+v, want %+v", secret, want)
737738
}
738739

‎github/actions_workflow_jobs_test.go

Copy file name to clipboardExpand all lines: github/actions_workflow_jobs_test.go
+5-4Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@ import (
1010
"fmt"
1111
"net/http"
1212
"net/url"
13-
"reflect"
1413
"testing"
1514
"time"
15+
16+
"github.com/google/go-cmp/cmp"
1617
)
1718

1819
func TestActionsService_ListWorkflowJobs(t *testing.T) {
@@ -39,7 +40,7 @@ func TestActionsService_ListWorkflowJobs(t *testing.T) {
3940
{ID: Int64(399444497), RunID: Int64(29679449), StartedAt: &Timestamp{time.Date(2019, time.January, 02, 15, 04, 05, 0, time.UTC)}, CompletedAt: &Timestamp{time.Date(2020, time.January, 02, 15, 04, 05, 0, time.UTC)}},
4041
},
4142
}
42-
if !reflect.DeepEqual(jobs, want) {
43+
if !cmp.Equal(jobs, want) {
4344
t.Errorf("Actions.ListWorkflowJobs returned %+v, want %+v", jobs, want)
4445
}
4546

@@ -82,7 +83,7 @@ func TestActionsService_ListWorkflowJobs_Filter(t *testing.T) {
8283
{ID: Int64(399444497), RunID: Int64(29679449), StartedAt: &Timestamp{time.Date(2019, time.January, 02, 15, 04, 05, 0, time.UTC)}, CompletedAt: &Timestamp{time.Date(2020, time.January, 02, 15, 04, 05, 0, time.UTC)}},
8384
},
8485
}
85-
if !reflect.DeepEqual(jobs, want) {
86+
if !cmp.Equal(jobs, want) {
8687
t.Errorf("Actions.ListWorkflowJobs returned %+v, want %+v", jobs, want)
8788
}
8889
}
@@ -107,7 +108,7 @@ func TestActionsService_GetWorkflowJobByID(t *testing.T) {
107108
StartedAt: &Timestamp{time.Date(2019, time.January, 02, 15, 04, 05, 0, time.UTC)},
108109
CompletedAt: &Timestamp{time.Date(2020, time.January, 02, 15, 04, 05, 0, time.UTC)},
109110
}
110-
if !reflect.DeepEqual(job, want) {
111+
if !cmp.Equal(job, want) {
111112
t.Errorf("Actions.GetWorkflowJobByID returned %+v, want %+v", job, want)
112113
}
113114

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.