From 467ab11aa50725056bb8c6e804ab94b64e9d3ea4 Mon Sep 17 00:00:00 2001 From: Oleksandr Redko Date: Mon, 18 Aug 2025 19:36:57 +0300 Subject: [PATCH] chore: Format code with gofumpt --- .golangci.yml | 1 + example/commitpr/main.go | 6 +- example/newfilewithappauth/main.go | 1 - example/verifyartifact/main.go | 1 - github/actions_cache_test.go | 1 + github/actions_runners_test.go | 12 ++-- github/actions_secrets_test.go | 29 ++++----- github/actions_variables_test.go | 24 ++++---- github/actions_workflow_jobs_test.go | 20 +++--- github/actions_workflow_runs_test.go | 16 ++--- github/actions_workflows_test.go | 12 ++-- github/activity_notifications_test.go | 14 ++--- github/apps_test.go | 3 +- github/code_scanning_test.go | 18 +++--- github/codesofconduct_test.go | 3 +- github/codespaces_secrets_test.go | 6 +- github/dependabot_secrets_test.go | 12 ++-- github/dependency_graph_snapshots_test.go | 4 +- github/enterprise_actions_runners_test.go | 6 +- .../enterprise_network_configurations_test.go | 4 +- github/gen-accessors.go | 8 +-- github/gen-stringify-test.go | 12 ++-- github/gists_comments_test.go | 1 + github/gists_test.go | 10 +-- github/github_test.go | 61 ++++++++++--------- github/issues_test.go | 14 +++-- github/messages_test.go | 2 +- github/orgs_attestations.go | 2 +- github/orgs_issue_types_test.go | 3 +- github/orgs_members_test.go | 3 +- github/pulls_reviews_test.go | 3 +- github/rate_limit_test.go | 4 +- github/repos_attestations.go | 2 +- github/repos_collaborators_test.go | 1 - github/repos_contents_test.go | 6 +- github/repos_environments_test.go | 2 +- github/repos_pages.go | 1 - github/repos_stats_test.go | 6 +- github/repos_test.go | 2 +- github/search_test.go | 18 +++--- github/secret_scanning_test.go | 12 ++-- github/security_advisories_test.go | 4 +- github/strings_test.go | 8 +-- github/teams_test.go | 1 + github/timestamp_test.go | 2 +- github/users_attestations.go | 2 +- test/integration/authorizations_test.go | 12 ++-- tools/metadata/metadata.go | 2 +- 48 files changed, 215 insertions(+), 182 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 80c21f9d99b..1db2c12a0c8 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -158,4 +158,5 @@ formatters: enable: - gci - gofmt + - gofumpt - goimports diff --git a/example/commitpr/main.go b/example/commitpr/main.go index c03b7fea30f..e443d4676f7 100644 --- a/example/commitpr/main.go +++ b/example/commitpr/main.go @@ -57,8 +57,10 @@ Example: README.md,main.go:github/examples/commitpr/main.go`) privateKey = flag.String("private-key", "", "Path to the private key to use to sign the commit.") ) -var client *github.Client -var ctx = context.Background() +var ( + client *github.Client + ctx = context.Background() +) // getRef returns the commit branch reference object if it exists or creates it // from the base branch before returning it. diff --git a/example/newfilewithappauth/main.go b/example/newfilewithappauth/main.go index 2a580a523e5..64a75659585 100644 --- a/example/newfilewithappauth/main.go +++ b/example/newfilewithappauth/main.go @@ -40,7 +40,6 @@ func main() { Timeout: time.Second * 30, }, ).WithEnterpriseURLs(gitHost, gitHost) - if err != nil { log.Fatalf("failed to create git client for app: %v\n", err) } diff --git a/example/verifyartifact/main.go b/example/verifyartifact/main.go index 91a8fe3a1c8..8fe6e9a28f9 100644 --- a/example/verifyartifact/main.go +++ b/example/verifyartifact/main.go @@ -109,7 +109,6 @@ func main() { } err := runVerification(sev, pb, b) - if err != nil { log.Fatal(err) } diff --git a/github/actions_cache_test.go b/github/actions_cache_test.go index 5ce1b4f9c21..0f8268e769b 100644 --- a/github/actions_cache_test.go +++ b/github/actions_cache_test.go @@ -139,6 +139,7 @@ func TestActionsService_DeleteCachesByKey_invalidRepo(t *testing.T) { _, err := client.Actions.DeleteCachesByKey(ctx, "o", "%", "1", Ptr("main")) testURLParseError(t, err) } + func TestActionsService_DeleteCachesByKey_notFound(t *testing.T) { t.Parallel() client, mux, _ := setup(t) diff --git a/github/actions_runners_test.go b/github/actions_runners_test.go index 48c3cdfff03..d15f302942e 100644 --- a/github/actions_runners_test.go +++ b/github/actions_runners_test.go @@ -160,9 +160,11 @@ func TestActionsService_CreateRegistrationToken(t *testing.T) { t.Errorf("Actions.CreateRegistrationToken returned error: %v", err) } - want := &RegistrationToken{Token: Ptr("LLBF3JGZDX3P5PMEXLND6TS6FCWO6"), + want := &RegistrationToken{ + Token: Ptr("LLBF3JGZDX3P5PMEXLND6TS6FCWO6"), ExpiresAt: &Timestamp{time.Date(2020, time.January, 22, 12, 13, 35, - 123000000, time.UTC)}} + 123000000, time.UTC)}, + } if !cmp.Equal(token, want) { t.Errorf("Actions.CreateRegistrationToken returned %+v, want %+v", token, want) } @@ -383,9 +385,11 @@ func TestActionsService_CreateOrganizationRegistrationToken(t *testing.T) { t.Errorf("Actions.CreateRegistrationToken returned error: %v", err) } - want := &RegistrationToken{Token: Ptr("LLBF3JGZDX3P5PMEXLND6TS6FCWO6"), + want := &RegistrationToken{ + Token: Ptr("LLBF3JGZDX3P5PMEXLND6TS6FCWO6"), ExpiresAt: &Timestamp{time.Date(2020, time.January, 22, 12, 13, 35, - 123000000, time.UTC)}} + 123000000, time.UTC)}, + } if !cmp.Equal(token, want) { t.Errorf("Actions.CreateRegistrationToken returned %+v, want %+v", token, want) } diff --git a/github/actions_secrets_test.go b/github/actions_secrets_test.go index fea453217ea..8405fa75c97 100644 --- a/github/actions_secrets_test.go +++ b/github/actions_secrets_test.go @@ -18,7 +18,7 @@ import ( func TestPublicKey_UnmarshalJSON(t *testing.T) { t.Parallel() - var testCases = map[string]struct { + testCases := map[string]struct { data []byte wantPublicKey PublicKey wantErr bool @@ -183,8 +183,8 @@ func TestActionsService_ListRepoSecrets(t *testing.T) { want := &Secrets{ TotalCount: 4, Secrets: []*Secret{ - {Name: "A", 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)}}, - {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)}}, + {Name: "A", CreatedAt: Timestamp{time.Date(2019, time.January, 2, 15, 4, 5, 0, time.UTC)}, UpdatedAt: Timestamp{time.Date(2020, time.January, 2, 15, 4, 5, 0, time.UTC)}}, + {Name: "B", CreatedAt: Timestamp{time.Date(2019, time.January, 2, 15, 4, 5, 0, time.UTC)}, UpdatedAt: Timestamp{time.Date(2020, time.January, 2, 15, 4, 5, 0, time.UTC)}}, }, } if !cmp.Equal(secrets, want) { @@ -226,8 +226,8 @@ func TestActionsService_ListRepoOrgSecrets(t *testing.T) { want := &Secrets{ TotalCount: 4, Secrets: []*Secret{ - {Name: "A", 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)}}, - {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)}}, + {Name: "A", CreatedAt: Timestamp{time.Date(2019, time.January, 2, 15, 4, 5, 0, time.UTC)}, UpdatedAt: Timestamp{time.Date(2020, time.January, 2, 15, 4, 5, 0, time.UTC)}}, + {Name: "B", CreatedAt: Timestamp{time.Date(2019, time.January, 2, 15, 4, 5, 0, time.UTC)}, UpdatedAt: Timestamp{time.Date(2020, time.January, 2, 15, 4, 5, 0, time.UTC)}}, }, } if !cmp.Equal(secrets, want) { @@ -266,8 +266,8 @@ func TestActionsService_GetRepoSecret(t *testing.T) { want := &Secret{ Name: "NAME", - 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)}, + CreatedAt: Timestamp{time.Date(2019, time.January, 2, 15, 4, 5, 0, time.UTC)}, + UpdatedAt: Timestamp{time.Date(2020, time.January, 2, 15, 4, 5, 0, time.UTC)}, } if !cmp.Equal(secret, want) { t.Errorf("Actions.GetRepoSecret returned %+v, want %+v", secret, want) @@ -446,8 +446,8 @@ func TestActionsService_GetOrgSecret(t *testing.T) { want := &Secret{ Name: "NAME", - 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)}, + CreatedAt: Timestamp{time.Date(2019, time.January, 2, 15, 4, 5, 0, time.UTC)}, + UpdatedAt: Timestamp{time.Date(2020, time.January, 2, 15, 4, 5, 0, time.UTC)}, Visibility: "selected", SelectedRepositoriesURL: "https://api.github.com/orgs/octo-org/actions/secrets/SUPER_SECRET/repositories", } @@ -752,8 +752,8 @@ func TestActionsService_ListEnvSecrets(t *testing.T) { want := &Secrets{ TotalCount: 4, Secrets: []*Secret{ - {Name: "A", 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)}}, - {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)}}, + {Name: "A", CreatedAt: Timestamp{time.Date(2019, time.January, 2, 15, 4, 5, 0, time.UTC)}, UpdatedAt: Timestamp{time.Date(2020, time.January, 2, 15, 4, 5, 0, time.UTC)}}, + {Name: "B", CreatedAt: Timestamp{time.Date(2019, time.January, 2, 15, 4, 5, 0, time.UTC)}, UpdatedAt: Timestamp{time.Date(2020, time.January, 2, 15, 4, 5, 0, time.UTC)}}, }, } if !cmp.Equal(secrets, want) { @@ -792,8 +792,8 @@ func TestActionsService_GetEnvSecret(t *testing.T) { want := &Secret{ Name: "secret", - 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)}, + CreatedAt: Timestamp{time.Date(2019, time.January, 2, 15, 4, 5, 0, time.UTC)}, + UpdatedAt: Timestamp{time.Date(2020, time.January, 2, 15, 4, 5, 0, time.UTC)}, } if !cmp.Equal(secret, want) { t.Errorf("Actions.GetEnvSecret returned %+v, want %+v", secret, want) @@ -928,7 +928,8 @@ func TestSecrets_Marshal(t *testing.T) { CreatedAt: Timestamp{referenceTime}, UpdatedAt: Timestamp{referenceTime}, Visibility: "v", - SelectedRepositoriesURL: "s"}, + SelectedRepositoriesURL: "s", + }, }, } diff --git a/github/actions_variables_test.go b/github/actions_variables_test.go index ab4fa370042..286a74f954a 100644 --- a/github/actions_variables_test.go +++ b/github/actions_variables_test.go @@ -35,8 +35,8 @@ func TestActionsService_ListRepoVariables(t *testing.T) { want := &ActionsVariables{ TotalCount: 4, Variables: []*ActionsVariable{ - {Name: "A", Value: "AA", 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)}}, - {Name: "B", Value: "BB", 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)}}, + {Name: "A", Value: "AA", CreatedAt: &Timestamp{time.Date(2019, time.January, 2, 15, 4, 5, 0, time.UTC)}, UpdatedAt: &Timestamp{time.Date(2020, time.January, 2, 15, 4, 5, 0, time.UTC)}}, + {Name: "B", Value: "BB", CreatedAt: &Timestamp{time.Date(2019, time.January, 2, 15, 4, 5, 0, time.UTC)}, UpdatedAt: &Timestamp{time.Date(2020, time.January, 2, 15, 4, 5, 0, time.UTC)}}, }, } if !cmp.Equal(variables, want) { @@ -78,8 +78,8 @@ func TestActionsService_ListRepoOrgVariables(t *testing.T) { want := &ActionsVariables{ TotalCount: 4, Variables: []*ActionsVariable{ - {Name: "A", Value: "AA", 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)}}, - {Name: "B", Value: "BB", 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)}}, + {Name: "A", Value: "AA", CreatedAt: &Timestamp{time.Date(2019, time.January, 2, 15, 4, 5, 0, time.UTC)}, UpdatedAt: &Timestamp{time.Date(2020, time.January, 2, 15, 4, 5, 0, time.UTC)}}, + {Name: "B", Value: "BB", CreatedAt: &Timestamp{time.Date(2019, time.January, 2, 15, 4, 5, 0, time.UTC)}, UpdatedAt: &Timestamp{time.Date(2020, time.January, 2, 15, 4, 5, 0, time.UTC)}}, }, } if !cmp.Equal(variables, want) { @@ -119,8 +119,8 @@ func TestActionsService_GetRepoVariable(t *testing.T) { want := &ActionsVariable{ Name: "NAME", Value: "VALUE", - 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)}, + CreatedAt: &Timestamp{time.Date(2019, time.January, 2, 15, 4, 5, 0, time.UTC)}, + UpdatedAt: &Timestamp{time.Date(2020, time.January, 2, 15, 4, 5, 0, time.UTC)}, } if !cmp.Equal(variable, want) { t.Errorf("Actions.GetRepoVariable returned %+v, want %+v", variable, want) @@ -296,8 +296,8 @@ func TestActionsService_GetOrgVariable(t *testing.T) { want := &ActionsVariable{ Name: "NAME", Value: "VALUE", - 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)}, + CreatedAt: &Timestamp{time.Date(2019, time.January, 2, 15, 4, 5, 0, time.UTC)}, + UpdatedAt: &Timestamp{time.Date(2020, time.January, 2, 15, 4, 5, 0, time.UTC)}, Visibility: Ptr("selected"), SelectedRepositoriesURL: Ptr("https://api.github.com/orgs/octo-org/actions/variables/VAR/repositories"), } @@ -573,8 +573,8 @@ func TestActionsService_ListEnvVariables(t *testing.T) { want := &ActionsVariables{ TotalCount: 4, Variables: []*ActionsVariable{ - {Name: "A", Value: "AA", 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)}}, - {Name: "B", Value: "BB", 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)}}, + {Name: "A", Value: "AA", CreatedAt: &Timestamp{time.Date(2019, time.January, 2, 15, 4, 5, 0, time.UTC)}, UpdatedAt: &Timestamp{time.Date(2020, time.January, 2, 15, 4, 5, 0, time.UTC)}}, + {Name: "B", Value: "BB", CreatedAt: &Timestamp{time.Date(2019, time.January, 2, 15, 4, 5, 0, time.UTC)}, UpdatedAt: &Timestamp{time.Date(2020, time.January, 2, 15, 4, 5, 0, time.UTC)}}, }, } if !cmp.Equal(variables, want) { @@ -614,8 +614,8 @@ func TestActionsService_GetEnvVariable(t *testing.T) { want := &ActionsVariable{ Name: "variable", Value: "VAR", - 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)}, + CreatedAt: &Timestamp{time.Date(2019, time.January, 2, 15, 4, 5, 0, time.UTC)}, + UpdatedAt: &Timestamp{time.Date(2020, time.January, 2, 15, 4, 5, 0, time.UTC)}, } if !cmp.Equal(variable, want) { t.Errorf("Actions.GetEnvVariable returned %+v, want %+v", variable, want) diff --git a/github/actions_workflow_jobs_test.go b/github/actions_workflow_jobs_test.go index fb106a0313d..fdb5e1991d2 100644 --- a/github/actions_workflow_jobs_test.go +++ b/github/actions_workflow_jobs_test.go @@ -38,8 +38,8 @@ func TestActionsService_ListWorkflowJobs(t *testing.T) { want := &Jobs{ TotalCount: Ptr(4), Jobs: []*WorkflowJob{ - {ID: Ptr(int64(399444496)), RunID: Ptr(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)}}, - {ID: Ptr(int64(399444497)), RunID: Ptr(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)}}, + {ID: Ptr(int64(399444496)), RunID: Ptr(int64(29679449)), StartedAt: &Timestamp{time.Date(2019, time.January, 2, 15, 4, 5, 0, time.UTC)}, CompletedAt: &Timestamp{time.Date(2020, time.January, 2, 15, 4, 5, 0, time.UTC)}}, + {ID: Ptr(int64(399444497)), RunID: Ptr(int64(29679449)), StartedAt: &Timestamp{time.Date(2019, time.January, 2, 15, 4, 5, 0, time.UTC)}, CompletedAt: &Timestamp{time.Date(2020, time.January, 2, 15, 4, 5, 0, time.UTC)}}, }, } if !cmp.Equal(jobs, want) { @@ -81,8 +81,8 @@ func TestActionsService_ListWorkflowJobs_Filter(t *testing.T) { want := &Jobs{ TotalCount: Ptr(4), Jobs: []*WorkflowJob{ - {ID: Ptr(int64(399444496)), RunID: Ptr(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)}}, - {ID: Ptr(int64(399444497)), RunID: Ptr(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)}}, + {ID: Ptr(int64(399444496)), RunID: Ptr(int64(29679449)), StartedAt: &Timestamp{time.Date(2019, time.January, 2, 15, 4, 5, 0, time.UTC)}, CompletedAt: &Timestamp{time.Date(2020, time.January, 2, 15, 4, 5, 0, time.UTC)}}, + {ID: Ptr(int64(399444497)), RunID: Ptr(int64(29679449)), StartedAt: &Timestamp{time.Date(2019, time.January, 2, 15, 4, 5, 0, time.UTC)}, CompletedAt: &Timestamp{time.Date(2020, time.January, 2, 15, 4, 5, 0, time.UTC)}}, }, } if !cmp.Equal(jobs, want) { @@ -112,15 +112,15 @@ func TestActionsService_ListWorkflowJobsAttempt(t *testing.T) { { ID: Ptr(int64(399444496)), RunID: Ptr(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)}, + StartedAt: &Timestamp{time.Date(2019, time.January, 2, 15, 4, 5, 0, time.UTC)}, + CompletedAt: &Timestamp{time.Date(2020, time.January, 2, 15, 4, 5, 0, time.UTC)}, RunAttempt: Ptr(int64(2)), }, { ID: Ptr(int64(399444497)), RunID: Ptr(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)}, + StartedAt: &Timestamp{time.Date(2019, time.January, 2, 15, 4, 5, 0, time.UTC)}, + CompletedAt: &Timestamp{time.Date(2020, time.January, 2, 15, 4, 5, 0, time.UTC)}, RunAttempt: Ptr(int64(2)), }, }, @@ -161,8 +161,8 @@ func TestActionsService_GetWorkflowJobByID(t *testing.T) { want := &WorkflowJob{ ID: Ptr(int64(399444496)), - 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)}, + StartedAt: &Timestamp{time.Date(2019, time.January, 2, 15, 4, 5, 0, time.UTC)}, + CompletedAt: &Timestamp{time.Date(2020, time.January, 2, 15, 4, 5, 0, time.UTC)}, } if !cmp.Equal(job, want) { t.Errorf("Actions.GetWorkflowJobByID returned %+v, want %+v", job, want) diff --git a/github/actions_workflow_runs_test.go b/github/actions_workflow_runs_test.go index 29dda8129d1..103d6f20421 100644 --- a/github/actions_workflow_runs_test.go +++ b/github/actions_workflow_runs_test.go @@ -38,8 +38,8 @@ func TestActionsService_ListWorkflowRunsByID(t *testing.T) { want := &WorkflowRuns{ TotalCount: Ptr(4), WorkflowRuns: []*WorkflowRun{ - {ID: Ptr(int64(399444496)), RunNumber: Ptr(296), 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)}}, - {ID: Ptr(int64(399444497)), RunNumber: Ptr(296), 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)}}, + {ID: Ptr(int64(399444496)), RunNumber: Ptr(296), CreatedAt: &Timestamp{time.Date(2019, time.January, 2, 15, 4, 5, 0, time.UTC)}, UpdatedAt: &Timestamp{time.Date(2020, time.January, 2, 15, 4, 5, 0, time.UTC)}}, + {ID: Ptr(int64(399444497)), RunNumber: Ptr(296), CreatedAt: &Timestamp{time.Date(2019, time.January, 2, 15, 4, 5, 0, time.UTC)}, UpdatedAt: &Timestamp{time.Date(2020, time.January, 2, 15, 4, 5, 0, time.UTC)}}, }, } if !cmp.Equal(runs, want) { @@ -81,8 +81,8 @@ func TestActionsService_ListWorkflowRunsFileName(t *testing.T) { want := &WorkflowRuns{ TotalCount: Ptr(4), WorkflowRuns: []*WorkflowRun{ - {ID: Ptr(int64(399444496)), RunNumber: Ptr(296), 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)}}, - {ID: Ptr(int64(399444497)), RunNumber: Ptr(296), 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)}}, + {ID: Ptr(int64(399444496)), RunNumber: Ptr(296), CreatedAt: &Timestamp{time.Date(2019, time.January, 2, 15, 4, 5, 0, time.UTC)}, UpdatedAt: &Timestamp{time.Date(2020, time.January, 2, 15, 4, 5, 0, time.UTC)}}, + {ID: Ptr(int64(399444497)), RunNumber: Ptr(296), CreatedAt: &Timestamp{time.Date(2019, time.January, 2, 15, 4, 5, 0, time.UTC)}, UpdatedAt: &Timestamp{time.Date(2020, time.January, 2, 15, 4, 5, 0, time.UTC)}}, }, } if !cmp.Equal(runs, want) { @@ -122,8 +122,8 @@ func TestActionsService_GetWorkflowRunByID(t *testing.T) { want := &WorkflowRun{ ID: Ptr(int64(399444496)), RunNumber: Ptr(296), - 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)}, + CreatedAt: &Timestamp{time.Date(2019, time.January, 2, 15, 4, 5, 0, time.UTC)}, + UpdatedAt: &Timestamp{time.Date(2020, time.January, 2, 15, 4, 5, 0, time.UTC)}, } if !cmp.Equal(runs, want) { @@ -166,8 +166,8 @@ func TestActionsService_GetWorkflowRunAttempt(t *testing.T) { ID: Ptr(int64(399444496)), RunNumber: Ptr(296), RunAttempt: Ptr(3), - 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)}, + CreatedAt: &Timestamp{time.Date(2019, time.January, 2, 15, 4, 5, 0, time.UTC)}, + UpdatedAt: &Timestamp{time.Date(2020, time.January, 2, 15, 4, 5, 0, time.UTC)}, } if !cmp.Equal(runs, want) { diff --git a/github/actions_workflows_test.go b/github/actions_workflows_test.go index fddf6b70c5f..97d7ce0d9db 100644 --- a/github/actions_workflows_test.go +++ b/github/actions_workflows_test.go @@ -36,8 +36,8 @@ func TestActionsService_ListWorkflows(t *testing.T) { want := &Workflows{ TotalCount: Ptr(4), Workflows: []*Workflow{ - {ID: Ptr(int64(72844)), 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)}}, - {ID: Ptr(int64(72845)), 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)}}, + {ID: Ptr(int64(72844)), CreatedAt: &Timestamp{time.Date(2019, time.January, 2, 15, 4, 5, 0, time.UTC)}, UpdatedAt: &Timestamp{time.Date(2020, time.January, 2, 15, 4, 5, 0, time.UTC)}}, + {ID: Ptr(int64(72845)), CreatedAt: &Timestamp{time.Date(2019, time.January, 2, 15, 4, 5, 0, time.UTC)}, UpdatedAt: &Timestamp{time.Date(2020, time.January, 2, 15, 4, 5, 0, time.UTC)}}, }, } if !cmp.Equal(workflows, want) { @@ -76,8 +76,8 @@ func TestActionsService_GetWorkflowByID(t *testing.T) { want := &Workflow{ ID: Ptr(int64(72844)), - 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)}, + CreatedAt: &Timestamp{time.Date(2019, time.January, 2, 15, 4, 5, 0, time.UTC)}, + UpdatedAt: &Timestamp{time.Date(2020, time.January, 2, 15, 4, 5, 0, time.UTC)}, } if !cmp.Equal(workflow, want) { t.Errorf("Actions.GetWorkflowByID returned %+v, want %+v", workflow, want) @@ -115,8 +115,8 @@ func TestActionsService_GetWorkflowByFileName(t *testing.T) { want := &Workflow{ ID: Ptr(int64(72844)), - 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)}, + CreatedAt: &Timestamp{time.Date(2019, time.January, 2, 15, 4, 5, 0, time.UTC)}, + UpdatedAt: &Timestamp{time.Date(2020, time.January, 2, 15, 4, 5, 0, time.UTC)}, } if !cmp.Equal(workflow, want) { t.Errorf("Actions.GetWorkflowByFileName returned %+v, want %+v", workflow, want) diff --git a/github/activity_notifications_test.go b/github/activity_notifications_test.go index 6f3ae5b970e..ad4f3685885 100644 --- a/github/activity_notifications_test.go +++ b/github/activity_notifications_test.go @@ -35,8 +35,8 @@ func TestActivityService_ListNotification(t *testing.T) { opt := &NotificationListOptions{ All: true, Participating: true, - Since: time.Date(2006, time.January, 02, 15, 04, 05, 0, time.UTC), - Before: time.Date(2007, time.March, 04, 15, 04, 05, 0, time.UTC), + Since: time.Date(2006, time.January, 2, 15, 4, 5, 0, time.UTC), + Before: time.Date(2007, time.March, 4, 15, 4, 5, 0, time.UTC), } ctx := context.Background() notifications, _, err := client.Activity.ListNotifications(ctx, opt) @@ -107,14 +107,14 @@ func TestActivityService_MarkNotificationsRead(t *testing.T) { }) ctx := context.Background() - _, err := client.Activity.MarkNotificationsRead(ctx, Timestamp{time.Date(2006, time.January, 02, 15, 04, 05, 0, time.UTC)}) + _, err := client.Activity.MarkNotificationsRead(ctx, Timestamp{time.Date(2006, time.January, 2, 15, 4, 5, 0, time.UTC)}) if err != nil { t.Errorf("Activity.MarkNotificationsRead returned error: %v", err) } const methodName = "MarkNotificationsRead" testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { - return client.Activity.MarkNotificationsRead(ctx, Timestamp{time.Date(2006, time.January, 02, 15, 04, 05, 0, time.UTC)}) + return client.Activity.MarkNotificationsRead(ctx, Timestamp{time.Date(2006, time.January, 2, 15, 4, 5, 0, time.UTC)}) }) } @@ -131,19 +131,19 @@ func TestActivityService_MarkRepositoryNotificationsRead(t *testing.T) { }) ctx := context.Background() - _, err := client.Activity.MarkRepositoryNotificationsRead(ctx, "o", "r", Timestamp{time.Date(2006, time.January, 02, 15, 04, 05, 0, time.UTC)}) + _, err := client.Activity.MarkRepositoryNotificationsRead(ctx, "o", "r", Timestamp{time.Date(2006, time.January, 2, 15, 4, 5, 0, time.UTC)}) if err != nil { t.Errorf("Activity.MarkRepositoryNotificationsRead returned error: %v", err) } const methodName = "MarkRepositoryNotificationsRead" testBadOptions(t, methodName, func() (err error) { - _, err = client.Activity.MarkRepositoryNotificationsRead(ctx, "\n", "\n", Timestamp{time.Date(2006, time.January, 02, 15, 04, 05, 0, time.UTC)}) + _, err = client.Activity.MarkRepositoryNotificationsRead(ctx, "\n", "\n", Timestamp{time.Date(2006, time.January, 2, 15, 4, 5, 0, time.UTC)}) return err }) testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { - return client.Activity.MarkRepositoryNotificationsRead(ctx, "o", "r", Timestamp{time.Date(2006, time.January, 02, 15, 04, 05, 0, time.UTC)}) + return client.Activity.MarkRepositoryNotificationsRead(ctx, "o", "r", Timestamp{time.Date(2006, time.January, 2, 15, 4, 5, 0, time.UTC)}) }) } diff --git a/github/apps_test.go b/github/apps_test.go index 060281a50b5..5858f21418e 100644 --- a/github/apps_test.go +++ b/github/apps_test.go @@ -234,7 +234,8 @@ func TestAppsService_ListInstallations(t *testing.T) { Statuses: Ptr("write"), TeamDiscussions: Ptr("read"), VulnerabilityAlerts: Ptr("read"), - Workflows: Ptr("write")}, + Workflows: Ptr("write"), + }, Events: []string{"push", "pull_request"}, CreatedAt: &date, UpdatedAt: &date, diff --git a/github/code_scanning_test.go b/github/code_scanning_test.go index 4cfa3d881bf..2837e6ddf99 100644 --- a/github/code_scanning_test.go +++ b/github/code_scanning_test.go @@ -68,7 +68,7 @@ func TestCodeScanningService_UploadSarif(t *testing.T) { v := new(SarifAnalysis) assertNilError(t, json.NewDecoder(r.Body).Decode(v)) testMethod(t, r, "POST") - want := &SarifAnalysis{CommitSHA: Ptr("abc"), Ref: Ptr("ref/head/main"), Sarif: Ptr("abc"), CheckoutURI: Ptr("uri"), StartedAt: &Timestamp{time.Date(2006, time.January, 02, 15, 04, 05, 0, time.UTC)}, ToolName: Ptr("codeql-cli")} + want := &SarifAnalysis{CommitSHA: Ptr("abc"), Ref: Ptr("ref/head/main"), Sarif: Ptr("abc"), CheckoutURI: Ptr("uri"), StartedAt: &Timestamp{time.Date(2006, time.January, 2, 15, 4, 5, 0, time.UTC)}, ToolName: Ptr("codeql-cli")} if !cmp.Equal(v, want) { t.Errorf("Request body = %+v, want %+v", v, want) } @@ -79,7 +79,7 @@ func TestCodeScanningService_UploadSarif(t *testing.T) { }) ctx := context.Background() - sarifAnalysis := &SarifAnalysis{CommitSHA: Ptr("abc"), Ref: Ptr("ref/head/main"), Sarif: Ptr("abc"), CheckoutURI: Ptr("uri"), StartedAt: &Timestamp{time.Date(2006, time.January, 02, 15, 04, 05, 0, time.UTC)}, ToolName: Ptr("codeql-cli")} + sarifAnalysis := &SarifAnalysis{CommitSHA: Ptr("abc"), Ref: Ptr("ref/head/main"), Sarif: Ptr("abc"), CheckoutURI: Ptr("uri"), StartedAt: &Timestamp{time.Date(2006, time.January, 2, 15, 4, 5, 0, time.UTC)}, ToolName: Ptr("codeql-cli")} respSarifID, _, err := client.CodeScanning.UploadSarif(ctx, "o", "r", sarifAnalysis) if err != nil { t.Errorf("CodeScanning.UploadSarif returned error: %v", err) @@ -246,7 +246,7 @@ func TestCodeScanningService_ListAlertsForOrg(t *testing.T) { t.Errorf("CodeScanning.ListAlertsForOrg returned error: %v", err) } - date := Timestamp{time.Date(2020, time.May, 06, 12, 00, 00, 0, time.UTC)} + date := Timestamp{time.Date(2020, time.May, 6, 12, 0, 0, 0, time.UTC)} want := []*Alert{ { Repository: &Repository{ @@ -408,7 +408,7 @@ func TestCodeScanningService_ListAlertsForOrgLisCursorOptions(t *testing.T) { t.Errorf("CodeScanning.ListAlertsForOrg returned error: %v", err) } - date := Timestamp{time.Date(2020, time.May, 06, 12, 00, 00, 0, time.UTC)} + date := Timestamp{time.Date(2020, time.May, 6, 12, 0, 0, 0, time.UTC)} want := []*Alert{ { Repository: &Repository{ @@ -571,7 +571,7 @@ func TestCodeScanningService_ListAlertsForRepo(t *testing.T) { t.Errorf("CodeScanning.ListAlertsForRepo returned error: %v", err) } - date := Timestamp{time.Date(2020, time.May, 06, 12, 00, 00, 0, time.UTC)} + date := Timestamp{time.Date(2020, time.May, 6, 12, 0, 0, 0, time.UTC)} want := []*Alert{ { RuleID: Ptr("js/trivial-conditional"), @@ -725,7 +725,7 @@ func TestCodeScanningService_UpdateAlert(t *testing.T) { t.Errorf("CodeScanning.UpdateAlert returned error: %v", err) } - date := Timestamp{time.Date(2019, time.January, 02, 15, 04, 05, 0, time.UTC)} + date := Timestamp{time.Date(2019, time.January, 2, 15, 4, 5, 0, time.UTC)} want := &Alert{ RuleID: Ptr("js/useless-expression"), RuleSeverity: Ptr("warning"), @@ -918,7 +918,7 @@ func TestCodeScanningService_GetAlert(t *testing.T) { t.Errorf("CodeScanning.GetAlert returned error: %v", err) } - date := Timestamp{time.Date(2019, time.January, 02, 15, 04, 05, 0, time.UTC)} + date := Timestamp{time.Date(2019, time.January, 2, 15, 4, 5, 0, time.UTC)} want := &Alert{ RuleID: Ptr("js/useless-expression"), RuleSeverity: Ptr("warning"), @@ -1177,7 +1177,7 @@ func TestCodeScanningService_ListAnalysesForRepo(t *testing.T) { t.Errorf("CodeScanning.ListAnalysesForRepo returned error: %v", err) } - date := &Timestamp{time.Date(2020, time.August, 27, 15, 05, 21, 0, time.UTC)} + date := &Timestamp{time.Date(2020, time.August, 27, 15, 5, 21, 0, time.UTC)} want := []*ScanningAnalysis{ { ID: Ptr(int64(201)), @@ -1579,7 +1579,7 @@ func TestCodeScanningService_GetDefaultSetupConfiguration(t *testing.T) { t.Errorf("CodeScanning.GetDefaultSetupConfiguration returned error: %v", err) } - date := &Timestamp{time.Date(2006, time.January, 02, 15, 04, 05, 0, time.UTC)} + date := &Timestamp{time.Date(2006, time.January, 2, 15, 4, 5, 0, time.UTC)} want := &DefaultSetupConfiguration{ State: Ptr("configured"), Languages: []string{"javascript", "javascript-typescript", "typescript"}, diff --git a/github/codesofconduct_test.go b/github/codesofconduct_test.go index a1f0aefe8ca..8ded65348ac 100644 --- a/github/codesofconduct_test.go +++ b/github/codesofconduct_test.go @@ -37,7 +37,8 @@ func TestCodesOfConductService_List(t *testing.T) { Key: Ptr("key"), Name: Ptr("name"), URL: Ptr("url"), - }} + }, + } if !cmp.Equal(want, cs) { t.Errorf("returned %+v, want %+v", cs, want) } diff --git a/github/codespaces_secrets_test.go b/github/codespaces_secrets_test.go index b569e7ea0ae..b785656cf07 100644 --- a/github/codespaces_secrets_test.go +++ b/github/codespaces_secrets_test.go @@ -92,8 +92,8 @@ func TestCodespacesService_ListSecrets(t *testing.T) { want := &Secrets{ TotalCount: 4, Secrets: []*Secret{ - {Name: "A", 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)}}, - {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)}}, + {Name: "A", CreatedAt: Timestamp{time.Date(2019, time.January, 2, 15, 4, 5, 0, time.UTC)}, UpdatedAt: Timestamp{time.Date(2020, time.January, 2, 15, 4, 5, 0, time.UTC)}}, + {Name: "B", CreatedAt: Timestamp{time.Date(2019, time.January, 2, 15, 4, 5, 0, time.UTC)}, UpdatedAt: Timestamp{time.Date(2020, time.January, 2, 15, 4, 5, 0, time.UTC)}}, }, } if !cmp.Equal(secrets, want) { @@ -188,7 +188,7 @@ func TestCodespacesService_GetSecret(t *testing.T) { t.Errorf("Codespaces.%v returned error: %v", tt.methodName, err) } - want := &Secret{Name: "A", 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)}} + want := &Secret{Name: "A", CreatedAt: Timestamp{time.Date(2019, time.January, 2, 15, 4, 5, 0, time.UTC)}, UpdatedAt: Timestamp{time.Date(2020, time.January, 2, 15, 4, 5, 0, time.UTC)}} if !cmp.Equal(secret, want) { t.Errorf("Codespaces.%v returned %+v, want %+v", tt.methodName, secret, want) } diff --git a/github/dependabot_secrets_test.go b/github/dependabot_secrets_test.go index e8c205c2c41..a9ff17e35f4 100644 --- a/github/dependabot_secrets_test.go +++ b/github/dependabot_secrets_test.go @@ -105,8 +105,8 @@ func TestDependabotService_ListRepoSecrets(t *testing.T) { want := &Secrets{ TotalCount: 4, Secrets: []*Secret{ - {Name: "A", 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)}}, - {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)}}, + {Name: "A", CreatedAt: Timestamp{time.Date(2019, time.January, 2, 15, 4, 5, 0, time.UTC)}, UpdatedAt: Timestamp{time.Date(2020, time.January, 2, 15, 4, 5, 0, time.UTC)}}, + {Name: "B", CreatedAt: Timestamp{time.Date(2019, time.January, 2, 15, 4, 5, 0, time.UTC)}, UpdatedAt: Timestamp{time.Date(2020, time.January, 2, 15, 4, 5, 0, time.UTC)}}, }, } if !cmp.Equal(secrets, want) { @@ -145,8 +145,8 @@ func TestDependabotService_GetRepoSecret(t *testing.T) { want := &Secret{ Name: "NAME", - 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)}, + CreatedAt: Timestamp{time.Date(2019, time.January, 2, 15, 4, 5, 0, time.UTC)}, + UpdatedAt: Timestamp{time.Date(2020, time.January, 2, 15, 4, 5, 0, time.UTC)}, } if !cmp.Equal(secret, want) { t.Errorf("Dependabot.GetRepoSecret returned %+v, want %+v", secret, want) @@ -325,8 +325,8 @@ func TestDependabotService_GetOrgSecret(t *testing.T) { want := &Secret{ Name: "NAME", - 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)}, + CreatedAt: Timestamp{time.Date(2019, time.January, 2, 15, 4, 5, 0, time.UTC)}, + UpdatedAt: Timestamp{time.Date(2020, time.January, 2, 15, 4, 5, 0, time.UTC)}, Visibility: "selected", SelectedRepositoriesURL: "https://api.github.com/orgs/octo-org/dependabot/secrets/SUPER_SECRET/repositories", } diff --git a/github/dependency_graph_snapshots_test.go b/github/dependency_graph_snapshots_test.go index 6b9ec81f095..4a9b6360121 100644 --- a/github/dependency_graph_snapshots_test.go +++ b/github/dependency_graph_snapshots_test.go @@ -40,7 +40,7 @@ func TestDependencyGraphService_CreateSnapshot(t *testing.T) { Version: Ptr("0.0.1"), URL: Ptr("https://github.com/octo-org/octo-repo"), }, - Scanned: &Timestamp{time.Date(2022, time.June, 14, 20, 25, 00, 0, time.UTC)}, + Scanned: &Timestamp{time.Date(2022, time.June, 14, 20, 25, 0, 0, time.UTC)}, Metadata: map[string]any{ "key1": "value1", "key2": "value2", @@ -86,7 +86,7 @@ func TestDependencyGraphService_CreateSnapshot(t *testing.T) { want := &DependencyGraphSnapshotCreationData{ ID: 12345, - CreatedAt: &Timestamp{time.Date(2022, time.June, 14, 20, 25, 01, 0, time.UTC)}, + CreatedAt: &Timestamp{time.Date(2022, time.June, 14, 20, 25, 1, 0, time.UTC)}, Message: Ptr("Dependency results for the repo have been successfully updated."), Result: Ptr("SUCCESS"), } diff --git a/github/enterprise_actions_runners_test.go b/github/enterprise_actions_runners_test.go index 8202c9072b6..2eacf23ed24 100644 --- a/github/enterprise_actions_runners_test.go +++ b/github/enterprise_actions_runners_test.go @@ -75,9 +75,11 @@ func TestEnterpriseService_CreateRegistrationToken(t *testing.T) { t.Errorf("Enterprise.CreateRegistrationToken returned error: %v", err) } - want := &RegistrationToken{Token: Ptr("LLBF3JGZDX3P5PMEXLND6TS6FCWO6"), + want := &RegistrationToken{ + Token: Ptr("LLBF3JGZDX3P5PMEXLND6TS6FCWO6"), ExpiresAt: &Timestamp{time.Date(2020, time.January, 22, 12, 13, 35, - 123000000, time.UTC)}} + 123000000, time.UTC)}, + } if !cmp.Equal(token, want) { t.Errorf("Enterprise.CreateRegistrationToken returned %+v, want %+v", token, want) } diff --git a/github/enterprise_network_configurations_test.go b/github/enterprise_network_configurations_test.go index b3efbd3f168..d738318d7dd 100644 --- a/github/enterprise_network_configurations_test.go +++ b/github/enterprise_network_configurations_test.go @@ -218,7 +218,7 @@ func TestEnterpriseService_GetEnterpriseNetworkConfiguration(t *testing.T) { Name: Ptr("configuration one"), ComputeService: Ptr(ComputeService("actions")), NetworkSettingsIDs: []string{"23456789ABDCEF1", "3456789ABDCEF12"}, - CreatedOn: &Timestamp{time.Date(2024, 12, 10, 19, 00, 15, 0, time.UTC)}, + CreatedOn: &Timestamp{time.Date(2024, 12, 10, 19, 0, 15, 0, time.UTC)}, } if !cmp.Equal(configuration, want) { t.Errorf("Enterprise.GetEnterpriseNetworkConfiguration mismatch (-want +got):\n%s", cmp.Diff(want, configuration)) @@ -274,7 +274,7 @@ func TestEnterpriseService_UpdateEnterpriseNetworkConfiguration(t *testing.T) { Name: Ptr("updated configuration one"), ComputeService: Ptr(ComputeService("none")), NetworkSettingsIDs: []string{"456789ABDCEF123"}, - CreatedOn: &Timestamp{time.Date(2024, 12, 10, 19, 00, 15, 0, time.UTC)}, + CreatedOn: &Timestamp{time.Date(2024, 12, 10, 19, 0, 15, 0, time.UTC)}, } if !cmp.Equal(configuration, want) { t.Errorf("Enterprise.UpdateEnterpriseNetworkConfiguration mismatch (-want +get)\n%s", cmp.Diff(want, configuration)) diff --git a/github/gen-accessors.go b/github/gen-accessors.go index 896734b4c51..6605c73bcca 100644 --- a/github/gen-accessors.go +++ b/github/gen-accessors.go @@ -199,15 +199,15 @@ func (t *templateData) dump() error { } logf("Writing %v...", filename) - if err := os.Chmod(filename, 0644); err != nil { + if err := os.Chmod(filename, 0o644); err != nil { return fmt.Errorf("os.Chmod(%q, 0644): %v", filename, err) } - if err := os.WriteFile(filename, clean, 0444); err != nil { + if err := os.WriteFile(filename, clean, 0o444); err != nil { return err } - if err := os.Chmod(filename, 0444); err != nil { + if err := os.Chmod(filename, 0o444); err != nil { return fmt.Errorf("os.Chmod(%q, 0444): %v", filename, err) } @@ -256,7 +256,7 @@ func (t *templateData) addArrayType(x *ast.ArrayType, receiverType, fieldName st func (t *templateData) addIdent(x *ast.Ident, receiverType, fieldName string) { var zeroValue string - var namedStruct = false + var namedStruct bool switch x.String() { case "int", "int64": zeroValue = "0" diff --git a/github/gen-stringify-test.go b/github/gen-stringify-test.go index 6b09e80c3f5..f4aee63eee2 100644 --- a/github/gen-stringify-test.go +++ b/github/gen-stringify-test.go @@ -251,7 +251,7 @@ func (t *templateData) addMapType(receiverType, fieldName string) { func (t *templateData) addIdent(x *ast.Ident, receiverType, fieldName string) { var zeroValue string - var namedStruct = false + var namedStruct bool switch x.String() { case "int": zeroValue = "0" @@ -275,7 +275,7 @@ func (t *templateData) addIdent(x *ast.Ident, receiverType, fieldName string) { func (t *templateData) addIdentPtr(x *ast.Ident, receiverType, fieldName string) { var zeroValue string - var namedStruct = false + var namedStruct bool switch x.String() { case "int": zeroValue = "Ptr(0)" @@ -299,7 +299,7 @@ func (t *templateData) addIdentPtr(x *ast.Ident, receiverType, fieldName string) func (t *templateData) addIdentSlice(x *ast.Ident, receiverType, fieldName string) { var zeroValue string - var namedStruct = false + var namedStruct bool switch x.String() { case "int": zeroValue = "[]int{0}" @@ -354,15 +354,15 @@ func (t *templateData) dump() error { } logf("Writing %v...", t.filename) - if err := os.Chmod(t.filename, 0644); err != nil { + if err := os.Chmod(t.filename, 0o644); err != nil { return fmt.Errorf("os.Chmod(%q, 0644): %v", t.filename, err) } - if err := os.WriteFile(t.filename, clean, 0444); err != nil { + if err := os.WriteFile(t.filename, clean, 0o444); err != nil { return err } - if err := os.Chmod(t.filename, 0444); err != nil { + if err := os.Chmod(t.filename, 0o444); err != nil { return fmt.Errorf("os.Chmod(%q, 0444): %v", t.filename, err) } diff --git a/github/gists_comments_test.go b/github/gists_comments_test.go index c3b89c863c6..61c6d8f172d 100644 --- a/github/gists_comments_test.go +++ b/github/gists_comments_test.go @@ -72,6 +72,7 @@ func TestGistComments_Marshal(t *testing.T) { testJSONMarshal(t, u, want) } + func TestGistsService_ListComments(t *testing.T) { t.Parallel() client, mux, _ := setup(t) diff --git a/github/gists_test.go b/github/gists_test.go index c7b1b88e98e..b6d2313e18a 100644 --- a/github/gists_test.go +++ b/github/gists_test.go @@ -652,12 +652,13 @@ func TestGistsService_ListCommits(t *testing.T) { URL: Ptr("https://api.github.com/gists/1/1"), Version: Ptr("1"), User: &User{ID: Ptr(int64(1))}, - CommittedAt: &Timestamp{time.Date(2010, time.January, 1, 00, 00, 00, 0, time.UTC)}, + CommittedAt: &Timestamp{time.Date(2010, time.January, 1, 0, 0, 0, 0, time.UTC)}, ChangeStatus: &CommitStats{ Additions: Ptr(180), Deletions: Ptr(0), Total: Ptr(180), - }}} + }, + }} if !cmp.Equal(gistCommits, want) { t.Errorf("Gists.ListCommits returned %+v, want %+v", gistCommits, want) @@ -961,8 +962,9 @@ func TestGistsService_ListForks(t *testing.T) { URL: Ptr("https://api.github.com/gists/1"), ID: Ptr("1"), User: &User{ID: Ptr(int64(1))}, - CreatedAt: &Timestamp{time.Date(2010, time.January, 1, 00, 00, 00, 0, time.UTC)}, - UpdatedAt: &Timestamp{time.Date(2013, time.January, 1, 00, 00, 00, 0, time.UTC)}}} + CreatedAt: &Timestamp{time.Date(2010, time.January, 1, 0, 0, 0, 0, time.UTC)}, + UpdatedAt: &Timestamp{time.Date(2013, time.January, 1, 0, 0, 0, 0, time.UTC)}, + }} if !cmp.Equal(gistForks, want) { t.Errorf("Gists.ListForks returned %+v, want %+v", gistForks, want) diff --git a/github/github_test.go b/github/github_test.go index ff0fa16a4a3..1b5ed56290e 100644 --- a/github/github_test.go +++ b/github/github_test.go @@ -96,7 +96,7 @@ func setup(t *testing.T) (client *Client, mux *http.ServeMux, serverURL string) func openTestFile(t *testing.T, name, content string) *os.File { t.Helper() fname := filepath.Join(t.TempDir(), name) - err := os.WriteFile(fname, []byte(content), 0600) + err := os.WriteFile(fname, []byte(content), 0o600) if err != nil { t.Fatal(err) } @@ -806,10 +806,11 @@ func TestResponse_populatePageValues(t *testing.T) { t.Parallel() r := http.Response{ Header: http.Header{ - "Link": {`; rel="first",` + - ` ; rel="prev",` + - ` ; rel="next",` + - ` ; rel="last"`, + "Link": { + `; rel="first",` + + ` ; rel="prev",` + + ` ; rel="next",` + + ` ; rel="last"`, }, }, } @@ -836,10 +837,11 @@ func TestResponse_populateSinceValues(t *testing.T) { t.Parallel() r := http.Response{ Header: http.Header{ - "Link": {`; rel="first",` + - ` ; rel="prev",` + - ` ; rel="next",` + - ` ; rel="last"`, + "Link": { + `; rel="first",` + + ` ; rel="prev",` + + ` ; rel="next",` + + ` ; rel="last"`, }, }, } @@ -866,10 +868,11 @@ func TestResponse_SinceWithPage(t *testing.T) { t.Parallel() r := http.Response{ Header: http.Header{ - "Link": {`; rel="first",` + - ` ; rel="prev",` + - ` ; rel="next",` + - ` ; rel="last"`, + "Link": { + `; rel="first",` + + ` ; rel="prev",` + + ` ; rel="next",` + + ` ; rel="last"`, }, }, } @@ -937,9 +940,10 @@ func TestResponse_beforeAfterPagination(t *testing.T) { t.Parallel() r := http.Response{ Header: http.Header{ - "Link": {`; rel="next",` + - ` ; rel="first",` + - ` ; rel="prev",`, + "Link": { + `; rel="next",` + + ` ; rel="first",` + + ` ; rel="prev",`, }, }, } @@ -972,11 +976,12 @@ func TestResponse_populatePageValues_invalid(t *testing.T) { t.Parallel() r := http.Response{ Header: http.Header{ - "Link": {`,` + - `; rel="first",` + - `https://api.github.com/?page=2; rel="prev",` + - `; rel="next",` + - `; rel="last"`, + "Link": { + `,` + + `; rel="first",` + + `https://api.github.com/?page=2; rel="prev",` + + `; rel="next",` + + `; rel="last"`, }, }, } @@ -1012,11 +1017,12 @@ func TestResponse_populateSinceValues_invalid(t *testing.T) { t.Parallel() r := http.Response{ Header: http.Header{ - "Link": {`,` + - `; rel="first",` + - `https://api.github.com/?since=2; rel="prev",` + - `; rel="next",` + - `; rel="last"`, + "Link": { + `,` + + `; rel="first",` + + `https://api.github.com/?since=2; rel="prev",` + + `; rel="next",` + + `; rel="last"`, }, }, } @@ -1504,7 +1510,6 @@ func TestDo_rateLimit_ignoredFromCache(t *testing.T) { // Second request should not by hindered by rate limits. req, _ = client.NewRequest("GET", "second", nil) _, err = client.Do(ctx, req, nil) - if err != nil { t.Fatalf("Second request failed, even though the rate limits from the cache should've been ignored: %v", err) } @@ -1520,7 +1525,7 @@ func TestDo_rateLimit_sleepUntilResponseResetLimit(t *testing.T) { reset := time.Now().UTC().Add(time.Second) - var firstRequest = true + firstRequest := true mux.HandleFunc("/", func(w http.ResponseWriter, _ *http.Request) { if firstRequest { firstRequest = false diff --git a/github/issues_test.go b/github/issues_test.go index 66e4526d77a..450b38a2c2c 100644 --- a/github/issues_test.go +++ b/github/issues_test.go @@ -39,9 +39,12 @@ func TestIssuesService_List_all(t *testing.T) { }) opt := &IssueListOptions{ - "all", "closed", []string{"a", "b"}, "updated", "asc", + "all", "closed", + []string{"a", "b"}, + "updated", "asc", time.Date(2002, time.February, 10, 15, 30, 0, 0, time.UTC), - ListCursorOptions{Before: "foo", After: "bar"}, ListOptions{Page: 1, PerPage: 2}, + ListCursorOptions{Before: "foo", After: "bar"}, + ListOptions{Page: 1, PerPage: 2}, } ctx := context.Background() issues, _, err := client.Issues.List(ctx, true, opt) @@ -165,9 +168,12 @@ func TestIssuesService_ListByRepo(t *testing.T) { }) opt := &IssueListByRepoOptions{ - "*", "closed", "a", "c", "m", []string{"a", "b"}, "updated", "asc", + "*", "closed", "a", "c", "m", + []string{"a", "b"}, + "updated", "asc", time.Date(2002, time.February, 10, 15, 30, 0, 0, time.UTC), - ListCursorOptions{PerPage: 1, Before: "foo", After: "bar"}, ListOptions{0, 0}, + ListCursorOptions{PerPage: 1, Before: "foo", After: "bar"}, + ListOptions{0, 0}, } ctx := context.Background() issues, _, err := client.Issues.ListByRepo(ctx, "o", "r", opt) diff --git a/github/messages_test.go b/github/messages_test.go index 8ba48808848..1d2d6ec5edb 100644 --- a/github/messages_test.go +++ b/github/messages_test.go @@ -242,7 +242,7 @@ func TestValidatePayload_InvalidContentTypeParams(t *testing.T) { func TestValidatePayload_ValidContentTypeParams(t *testing.T) { t.Parallel() - var requestBody = `{"yo":true}` + requestBody := `{"yo":true}` buf := bytes.NewBufferString(requestBody) req, err := http.NewRequest("POST", "http://localhost/event", buf) diff --git a/github/orgs_attestations.go b/github/orgs_attestations.go index 3d5793c18f0..d0ac123e2cf 100644 --- a/github/orgs_attestations.go +++ b/github/orgs_attestations.go @@ -18,7 +18,7 @@ import ( // //meta:operation GET /orgs/{org}/attestations/{subject_digest} func (s *OrganizationsService) ListAttestations(ctx context.Context, org, subjectDigest string, opts *ListOptions) (*AttestationsResponse, *Response, error) { - var u = fmt.Sprintf("orgs/%v/attestations/%v", org, subjectDigest) + u := fmt.Sprintf("orgs/%v/attestations/%v", org, subjectDigest) u, err := addOptions(u, opts) if err != nil { diff --git a/github/orgs_issue_types_test.go b/github/orgs_issue_types_test.go index 57c731a35d2..20a0389edd9 100644 --- a/github/orgs_issue_types_test.go +++ b/github/orgs_issue_types_test.go @@ -63,7 +63,8 @@ func TestOrganizationsService_ListIssueTypes(t *testing.T) { Name: Ptr("Bug"), Description: Ptr("An unexpected problem or behavior"), CreatedAt: Ptr(Timestamp{time.Date(2024, 12, 11, 14, 39, 9, 0, time.UTC)}), - UpdatedAt: Ptr(Timestamp{time.Date(2024, 12, 11, 14, 39, 9, 0, time.UTC)})}, + UpdatedAt: Ptr(Timestamp{time.Date(2024, 12, 11, 14, 39, 9, 0, time.UTC)}), + }, } if !cmp.Equal(issueTypes, want) { t.Errorf("Organizations.ListIssueTypes returned %+v, want %+v", issueTypes, want) diff --git a/github/orgs_members_test.go b/github/orgs_members_test.go index 28040fc9c19..313b951cb8d 100644 --- a/github/orgs_members_test.go +++ b/github/orgs_members_test.go @@ -638,7 +638,8 @@ func TestOrganizationsService_ListPendingOrgInvitations(t *testing.T) { }, TeamCount: Ptr(2), InvitationTeamURL: Ptr("https://api.github.com/organizations/2/invitations/1/teams"), - }} + }, + } if !cmp.Equal(invitations, want) { t.Errorf("Organizations.ListPendingOrgInvitations returned %+v, want %+v", invitations, want) diff --git a/github/pulls_reviews_test.go b/github/pulls_reviews_test.go index 44df29f506d..f460389ee39 100644 --- a/github/pulls_reviews_test.go +++ b/github/pulls_reviews_test.go @@ -433,7 +433,8 @@ func TestPullRequestsService_CreateReview_badReview(t *testing.T) { Path: &path, Body: &body, Position: &pos1, - }}} + }}, + } _, _, err := client.PullRequests.CreateReview(ctx, "o", "r", 1, badReview) if err == nil { diff --git a/github/rate_limit_test.go b/github/rate_limit_test.go index bd2414d57f6..7898596108b 100644 --- a/github/rate_limit_test.go +++ b/github/rate_limit_test.go @@ -110,7 +110,7 @@ func TestRateLimits(t *testing.T) { Limit: 9, Remaining: 8, Used: 1, - Reset: Timestamp{time.Date(2013, time.July, 1, 17, 48, 00, 0, time.UTC).Local()}, + Reset: Timestamp{time.Date(2013, time.July, 1, 17, 48, 0, 0, time.UTC).Local()}, }, DependencySnapshots: &Rate{ Limit: 10, @@ -283,7 +283,7 @@ func TestRateLimits_overQuota(t *testing.T) { Limit: 9, Remaining: 8, Used: 1, - Reset: Timestamp{time.Date(2013, time.July, 1, 17, 48, 00, 0, time.UTC).Local()}, + Reset: Timestamp{time.Date(2013, time.July, 1, 17, 48, 0, 0, time.UTC).Local()}, }, DependencySnapshots: &Rate{ Limit: 10, diff --git a/github/repos_attestations.go b/github/repos_attestations.go index 2e5425502c9..c5f34cd4dc3 100644 --- a/github/repos_attestations.go +++ b/github/repos_attestations.go @@ -17,7 +17,7 @@ import ( // //meta:operation GET /repos/{owner}/{repo}/attestations/{subject_digest} func (s *RepositoriesService) ListAttestations(ctx context.Context, owner, repo, subjectDigest string, opts *ListOptions) (*AttestationsResponse, *Response, error) { - var u = fmt.Sprintf("repos/%v/%v/attestations/%v", owner, repo, subjectDigest) + u := fmt.Sprintf("repos/%v/%v/attestations/%v", owner, repo, subjectDigest) u, err := addOptions(u, opts) if err != nil { diff --git a/github/repos_collaborators_test.go b/github/repos_collaborators_test.go index b91b0932978..e8a2157b9f0 100644 --- a/github/repos_collaborators_test.go +++ b/github/repos_collaborators_test.go @@ -439,7 +439,6 @@ func TestCollaboratorInvitation_Marshal(t *testing.T) { r := &CollaboratorInvitation{ ID: Ptr(int64(1)), Repo: &Repository{ - ID: Ptr(int64(1)), URL: Ptr("url"), Name: Ptr("n"), diff --git a/github/repos_contents_test.go b/github/repos_contents_test.go index c7007c8b751..e3cb67e3fa3 100644 --- a/github/repos_contents_test.go +++ b/github/repos_contents_test.go @@ -694,8 +694,10 @@ func TestRepositoriesService_GetContents_Directory(t *testing.T) { if err != nil { t.Errorf("Repositories.GetContents returned error: %v", err) } - want := []*RepositoryContent{{Type: Ptr("dir"), Name: Ptr("lib"), Path: Ptr("lib")}, - {Type: Ptr("file"), Name: Ptr("LICENSE"), Size: Ptr(20678), Path: Ptr("LICENSE")}} + want := []*RepositoryContent{ + {Type: Ptr("dir"), Name: Ptr("lib"), Path: Ptr("lib")}, + {Type: Ptr("file"), Name: Ptr("LICENSE"), Size: Ptr(20678), Path: Ptr("LICENSE")}, + } if !cmp.Equal(directoryContents, want) { t.Errorf("Repositories.GetContents_Directory returned %+v, want %+v", directoryContents, want) } diff --git a/github/repos_environments_test.go b/github/repos_environments_test.go index 463742fc97f..ebb1b1ee7c9 100644 --- a/github/repos_environments_test.go +++ b/github/repos_environments_test.go @@ -17,7 +17,7 @@ import ( func TestRequiredReviewer_UnmarshalJSON(t *testing.T) { t.Parallel() - var testCases = map[string]struct { + testCases := map[string]struct { data []byte wantRule []*RequiredReviewer wantError bool diff --git a/github/repos_pages.go b/github/repos_pages.go index 38913fc95af..5986fc01ba9 100644 --- a/github/repos_pages.go +++ b/github/repos_pages.go @@ -196,7 +196,6 @@ func (s *RepositoriesService) UpdatePagesGHES(ctx context.Context, owner, repo s u := fmt.Sprintf("repos/%v/%v/pages", owner, repo) req, err := s.client.NewRequest("PUT", u, opts) - if err != nil { return nil, err } diff --git a/github/repos_stats_test.go b/github/repos_stats_test.go index 467ef1693c5..d1cec541a72 100644 --- a/github/repos_stats_test.go +++ b/github/repos_stats_test.go @@ -58,7 +58,7 @@ func TestRepositoriesService_ListContributorsStats(t *testing.T) { Total: Ptr(135), Weeks: []*WeeklyStats{ { - Week: &Timestamp{time.Date(2013, time.May, 05, 00, 00, 00, 0, time.UTC).Local()}, + Week: &Timestamp{time.Date(2013, time.May, 5, 0, 0, 0, 0, time.UTC).Local()}, Additions: Ptr(6898), Deletions: Ptr(77), Commits: Ptr(10), @@ -114,7 +114,7 @@ func TestRepositoriesService_ListCommitActivity(t *testing.T) { { Days: []int{0, 3, 26, 20, 39, 1, 0}, Total: Ptr(89), - Week: &Timestamp{time.Date(2012, time.May, 06, 05, 00, 00, 0, time.UTC).Local()}, + Week: &Timestamp{time.Date(2012, time.May, 6, 5, 0, 0, 0, time.UTC).Local()}, }, } @@ -154,7 +154,7 @@ func TestRepositoriesService_ListCodeFrequency(t *testing.T) { } want := []*WeeklyStats{{ - Week: &Timestamp{time.Date(2011, time.April, 17, 00, 00, 00, 0, time.UTC).Local()}, + Week: &Timestamp{time.Date(2011, time.April, 17, 0, 0, 0, 0, time.UTC).Local()}, Additions: Ptr(1124), Deletions: Ptr(-435), }} diff --git a/github/repos_test.go b/github/repos_test.go index 91b20dcb5f2..e2e9d78031a 100644 --- a/github/repos_test.go +++ b/github/repos_test.go @@ -4523,7 +4523,7 @@ func TestRepositoriesService_IsPrivateReportingEnabled(t *testing.T) { func TestRepository_UnmarshalJSON(t *testing.T) { t.Parallel() - var testCases = map[string]struct { + testCases := map[string]struct { data []byte wantRepository Repository wantErr bool diff --git a/github/search_test.go b/github/search_test.go index d9fcb66c5bf..dbd1df8434c 100644 --- a/github/search_test.go +++ b/github/search_test.go @@ -124,10 +124,11 @@ func TestSearchService_RepositoriesTextMatch(t *testing.T) { wantedRepoResult := &Repository{ Name: Ptr("gopher1"), - TextMatches: []*TextMatch{{ - Fragment: Ptr("I'm afraid my friend what you have found\nIs a gopher who lives to feed"), - Matches: []*Match{{Text: Ptr("gopher"), Indices: []int{14, 21}}}, - }, + TextMatches: []*TextMatch{ + { + Fragment: Ptr("I'm afraid my friend what you have found\nIs a gopher who lives to feed"), + Matches: []*Match{{Text: Ptr("gopher"), Indices: []int{14, 21}}}, + }, }, } @@ -494,10 +495,11 @@ func TestSearchService_CodeTextMatch(t *testing.T) { wantedCodeResult := &CodeResult{ Name: Ptr("gopher1"), - TextMatches: []*TextMatch{{ - Fragment: Ptr("I'm afraid my friend what you have found\nIs a gopher who lives to feed"), - Matches: []*Match{{Text: Ptr("gopher"), Indices: []int{14, 21}}}, - }, + TextMatches: []*TextMatch{ + { + Fragment: Ptr("I'm afraid my friend what you have found\nIs a gopher who lives to feed"), + Matches: []*Match{{Text: Ptr("gopher"), Indices: []int{14, 21}}}, + }, }, } diff --git a/github/secret_scanning_test.go b/github/secret_scanning_test.go index 779785396f1..6f29a588dc6 100644 --- a/github/secret_scanning_test.go +++ b/github/secret_scanning_test.go @@ -52,7 +52,7 @@ func TestSecretScanningService_ListAlertsForEnterprise(t *testing.T) { t.Errorf("SecretScanning.ListAlertsForEnterprise returned error: %v", err) } - date := Timestamp{time.Date(1996, time.June, 20, 00, 00, 00, 0, time.UTC)} + date := Timestamp{time.Date(1996, time.June, 20, 0, 0, 0, 0, time.UTC)} want := []*SecretScanningAlert{ { Number: Ptr(1), @@ -122,7 +122,7 @@ func TestSecretScanningService_ListAlertsForOrg(t *testing.T) { t.Errorf("SecretScanning.ListAlertsForOrg returned error: %v", err) } - date := Timestamp{time.Date(1996, time.June, 20, 00, 00, 00, 0, time.UTC)} + date := Timestamp{time.Date(1996, time.June, 20, 0, 0, 0, 0, time.UTC)} want := []*SecretScanningAlert{ { Number: Ptr(1), @@ -189,7 +189,7 @@ func TestSecretScanningService_ListAlertsForOrgListOptions(t *testing.T) { t.Errorf("SecretScanning.ListAlertsForOrg returned error: %v", err) } - date := Timestamp{time.Date(1996, time.June, 20, 00, 00, 00, 0, time.UTC)} + date := Timestamp{time.Date(1996, time.June, 20, 0, 0, 0, 0, time.UTC)} want := []*SecretScanningAlert{ { Number: Ptr(1), @@ -254,7 +254,7 @@ func TestSecretScanningService_ListAlertsForRepo(t *testing.T) { t.Errorf("SecretScanning.ListAlertsForRepo returned error: %v", err) } - date := Timestamp{time.Date(1996, time.June, 20, 00, 00, 00, 0, time.UTC)} + date := Timestamp{time.Date(1996, time.June, 20, 0, 0, 0, 0, time.UTC)} want := []*SecretScanningAlert{ { Number: Ptr(1), @@ -317,7 +317,7 @@ func TestSecretScanningService_GetAlert(t *testing.T) { t.Errorf("SecretScanning.GetAlert returned error: %v", err) } - date := Timestamp{time.Date(1996, time.June, 20, 00, 00, 00, 0, time.UTC)} + date := Timestamp{time.Date(1996, time.June, 20, 0, 0, 0, 0, time.UTC)} want := &SecretScanningAlert{ Number: Ptr(1), CreatedAt: &date, @@ -389,7 +389,7 @@ func TestSecretScanningService_UpdateAlert(t *testing.T) { t.Errorf("SecretScanning.UpdateAlert returned error: %v", err) } - date := Timestamp{time.Date(1996, time.June, 20, 00, 00, 00, 0, time.UTC)} + date := Timestamp{time.Date(1996, time.June, 20, 0, 0, 0, 0, time.UTC)} want := &SecretScanningAlert{ Number: Ptr(1), CreatedAt: &date, diff --git a/github/security_advisories_test.go b/github/security_advisories_test.go index a10460c626a..15befb62b64 100644 --- a/github/security_advisories_test.go +++ b/github/security_advisories_test.go @@ -878,7 +878,7 @@ func TestListGlobalSecurityAdvisories(t *testing.T) { t.Errorf("SecurityAdvisories.ListGlobalSecurityAdvisories returned error: %v", err) } - date := Timestamp{time.Date(1996, time.June, 20, 00, 00, 00, 0, time.UTC)} + date := Timestamp{time.Date(1996, time.June, 20, 0, 0, 0, 0, time.UTC)} want := []*GlobalSecurityAdvisory{ { ID: Ptr(int64(1)), @@ -1060,7 +1060,7 @@ func TestGetGlobalSecurityAdvisories(t *testing.T) { t.Errorf("SecurityAdvisories.GetGlobalSecurityAdvisories returned error: %v", err) } - date := Timestamp{time.Date(1996, time.June, 20, 00, 00, 00, 0, time.UTC)} + date := Timestamp{time.Date(1996, time.June, 20, 0, 0, 0, 0, time.UTC)} want := &GlobalSecurityAdvisory{ ID: Ptr(int64(1)), SecurityAdvisory: SecurityAdvisory{ diff --git a/github/strings_test.go b/github/strings_test.go index 0e6203c096c..b61d68908d5 100644 --- a/github/strings_test.go +++ b/github/strings_test.go @@ -15,7 +15,7 @@ func TestStringify(t *testing.T) { t.Parallel() var nilPointer *string - var tests = []struct { + tests := []struct { in any out string }{ @@ -56,11 +56,11 @@ func TestStringify(t *testing.T) { // actual GitHub structs { - Timestamp{time.Date(2006, time.January, 02, 15, 04, 05, 0, time.UTC)}, + Timestamp{time.Date(2006, time.January, 2, 15, 4, 5, 0, time.UTC)}, `github.Timestamp{2006-01-02 15:04:05 +0000 UTC}`, }, { - &Timestamp{time.Date(2006, time.January, 02, 15, 04, 05, 0, time.UTC)}, + &Timestamp{time.Date(2006, time.January, 2, 15, 4, 5, 0, time.UTC)}, `github.Timestamp{2006-01-02 15:04:05 +0000 UTC}`, }, { @@ -88,7 +88,7 @@ func TestStringify(t *testing.T) { // stringified as their underlying value. func TestString(t *testing.T) { t.Parallel() - var tests = []struct { + tests := []struct { in any out string }{ diff --git a/github/teams_test.go b/github/teams_test.go index 30c2796855f..afb6623541c 100644 --- a/github/teams_test.go +++ b/github/teams_test.go @@ -1523,6 +1523,7 @@ func TestTeamsService_CreateOrUpdateIDPGroupConnectionsBySlug(t *testing.T) { return resp, err }) } + func TestTeamsService_CreateOrUpdateIDPGroupConnectionsByID_empty(t *testing.T) { t.Parallel() client, mux, _ := setup(t) diff --git a/github/timestamp_test.go b/github/timestamp_test.go index 4107a4fa6e4..487a634ac1e 100644 --- a/github/timestamp_test.go +++ b/github/timestamp_test.go @@ -21,7 +21,7 @@ const ( ) var ( - referenceTime = time.Date(2006, time.January, 02, 15, 04, 05, 0, time.UTC) + referenceTime = time.Date(2006, time.January, 2, 15, 4, 5, 0, time.UTC) unixOrigin = time.Unix(0, 0).In(time.UTC) ) diff --git a/github/users_attestations.go b/github/users_attestations.go index 18f60298d87..d63634500b5 100644 --- a/github/users_attestations.go +++ b/github/users_attestations.go @@ -18,7 +18,7 @@ import ( // //meta:operation GET /users/{username}/attestations/{subject_digest} func (s *UsersService) ListAttestations(ctx context.Context, user, subjectDigest string, opts *ListOptions) (*AttestationsResponse, *Response, error) { - var u = fmt.Sprintf("users/%v/attestations/%v", user, subjectDigest) + u := fmt.Sprintf("users/%v/attestations/%v", user, subjectDigest) u, err := addOptions(u, opts) if err != nil { diff --git a/test/integration/authorizations_test.go b/test/integration/authorizations_test.go index 9a1f397bffe..55b5b1beda5 100644 --- a/test/integration/authorizations_test.go +++ b/test/integration/authorizations_test.go @@ -17,11 +17,13 @@ import ( "github.com/google/go-github/v74/github" ) -const msgEnvMissing = "Skipping test because the required environment variable (%v) is not present." -const envKeyClientID = "GITHUB_CLIENT_ID" -const envKeyClientSecret = "GITHUB_CLIENT_SECRET" -const envKeyAccessToken = "GITHUB_ACCESS_TOKEN" -const InvalidTokenValue = "iamnotacroken" +const ( + msgEnvMissing = "Skipping test because the required environment variable (%v) is not present." + envKeyClientID = "GITHUB_CLIENT_ID" + envKeyClientSecret = "GITHUB_CLIENT_SECRET" + envKeyAccessToken = "GITHUB_ACCESS_TOKEN" + InvalidTokenValue = "iamnotacroken" +) // TestAuthorizationsAppOperations tests the application/token related operations, such // as creating, testing, resetting and revoking application OAuth tokens. diff --git a/tools/metadata/metadata.go b/tools/metadata/metadata.go index 35d90142931..378037cd8d2 100644 --- a/tools/metadata/metadata.go +++ b/tools/metadata/metadata.go @@ -431,7 +431,7 @@ func visitFileMethods(updateFile bool, filename string, visit nodeVisitor) error if bytes.Equal(content, updatedContent) { return nil } - return os.WriteFile(filename, updatedContent, 0600) + return os.WriteFile(filename, updatedContent, 0o600) } var (