From cd953b0515b5949ae462908707da2acb50f87bff Mon Sep 17 00:00:00 2001 From: ajayk Date: Sat, 22 Aug 2026 19:50:47 -0700 Subject: [PATCH 1/2] feat: Require Go 1.26 and use new(expr) for pointer literals Bump go.mod to 1.26 per the N-1 support policy (Go 1.27 is current) and replace Ptr() with the new(v) builtin across tests. --- github/actions_artifacts_test.go | 16 +- github/actions_cache_test.go | 14 +- github/actions_hosted_runners_test.go | 132 ++-- github/actions_oidc_test.go | 10 +- github/actions_permissions_enterprise_test.go | 44 +- github/actions_permissions_orgs_test.go | 64 +- github/actions_runner_groups_test.go | 142 ++--- github/actions_runners_test.go | 56 +- github/actions_secrets.go | 2 +- github/actions_secrets_test.go | 24 +- github/actions_variables_test.go | 26 +- github/actions_workflow_jobs_test.go | 28 +- github/actions_workflow_runs_test.go | 96 +-- github/actions_workflows_test.go | 38 +- github/activity_events_test.go | 24 +- github/activity_notifications_test.go | 12 +- github/activity_star_test.go | 6 +- github/activity_test.go | 40 +- github/activity_watching_test.go | 12 +- github/admin_orgs_test.go | 14 +- github/admin_stats_test.go | 68 +-- github/admin_test.go | 62 +- github/admin_users_test.go | 20 +- github/agent_tasks_test.go | 60 +- github/apps_hooks_deliveries_test.go | 6 +- github/apps_hooks_test.go | 24 +- github/apps_installation_test.go | 6 +- github/apps_manifest_test.go | 10 +- github/apps_marketplace_test.go | 16 +- github/apps_test.go | 126 ++-- github/authorizations_test.go | 6 +- github/billing_test.go | 92 +-- github/checks_test.go | 160 ++--- github/classroom_test.go | 348 +++++------ github/code_quality_test.go | 38 +- github/code_scanning_test.go | 564 +++++++++--------- github/codesofconduct_test.go | 14 +- github/codespaces_machines_test.go | 34 +- github/codespaces_orgs_test.go | 8 +- github/codespaces_secrets_test.go | 10 +- github/codespaces_test.go | 150 ++--- github/copilot_test.go | 482 +++++++-------- github/dependabot_alerts_test.go | 30 +- github/dependabot_secrets_test.go | 10 +- github/dependency_graph_snapshots_test.go | 42 +- github/dependency_graph_test.go | 6 +- .../enterprise_actions_hosted_runners_test.go | 132 ++-- .../enterprise_actions_runner_groups_test.go | 94 +-- github/enterprise_actions_runners_test.go | 26 +- github/enterprise_app_installation_test.go | 8 +- github/enterprise_audit_log_test.go | 14 +- .../enterprise_billing_cost_centers_test.go | 38 +- github/enterprise_billing_test.go | 22 +- github/enterprise_budgets_test.go | 48 +- ...erprise_code_security_and_analysis_test.go | 20 +- ...rprise_codesecurity_configurations_test.go | 26 +- github/enterprise_licenses_test.go | 14 +- github/enterprise_manage_ghes_config_test.go | 218 +++---- ...enterprise_manage_ghes_maintenance_test.go | 24 +- github/enterprise_manage_ghes_ssh_test.go | 8 +- github/enterprise_manage_ghes_test.go | 36 +- .../enterprise_network_configurations_test.go | 66 +- ...enterprise_organization_properties_test.go | 18 +- github/enterprise_properties_test.go | 48 +- github/enterprise_rules_test.go | 268 ++++----- github/enterprise_scim_test.go | 144 ++--- github/enterprise_team_test.go | 62 +- github/event_test.go | 4 +- github/examples_test.go | 12 +- github/gists_comments_test.go | 8 +- github/gists_test.go | 58 +- github/git_blobs_test.go | 12 +- github/git_commits_test.go | 70 +-- github/git_refs_test.go | 94 +-- github/git_tags_test.go | 4 +- github/git_trees_test.go | 100 ++-- github/github.go | 16 +- github/github_test.go | 44 +- github/gitignore_test.go | 2 +- github/interactions_orgs_test.go | 6 +- github/interactions_repos_test.go | 6 +- github/issue_import_test.go | 22 +- github/issues_assignees_test.go | 6 +- github/issues_comments_test.go | 14 +- github/issues_dependencies_test.go | 8 +- github/issues_events_test.go | 6 +- github/issues_labels_test.go | 4 +- github/issues_milestones_test.go | 10 +- github/issues_test.go | 26 +- github/issues_timeline_test.go | 34 +- github/licenses_test.go | 14 +- github/markdown_test.go | 6 +- github/meta_test.go | 2 +- github/migrations_source_import_test.go | 38 +- github/migrations_test.go | 24 +- github/migrations_user_test.go | 24 +- github/orgs_actions_allowed_test.go | 6 +- github/orgs_actions_permissions_test.go | 6 +- github/orgs_artifacts_test.go | 36 +- github/orgs_audit_log.go | 2 +- github/orgs_audit_log_test.go | 66 +- .../orgs_codesecurity_configurations_test.go | 52 +- github/orgs_credential_authorizations_test.go | 8 +- github/orgs_custom_repository_roles_test.go | 64 +- github/orgs_hooks_configuration_test.go | 16 +- github/orgs_hooks_deliveries_test.go | 6 +- github/orgs_hooks_test.go | 8 +- github/orgs_immutable_releases_test.go | 12 +- github/orgs_issue_types_test.go | 44 +- github/orgs_members_test.go | 140 ++--- github/orgs_network_configurations_test.go | 84 +-- github/orgs_organization_properties_test.go | 4 +- github/orgs_organization_roles_test.go | 62 +- github/orgs_outside_collaborators_test.go | 2 +- github/orgs_packages_test.go | 86 +-- github/orgs_personal_access_tokens_test.go | 82 +-- github/orgs_properties_test.go | 62 +- github/orgs_rules_test.go | 256 ++++---- github/orgs_security_managers_test.go | 2 +- github/orgs_test.go | 18 +- github/orgs_users_blocking_test.go | 2 +- github/packages_test.go | 6 +- github/private_registries_test.go | 88 +-- github/projects_test.go | 178 +++--- github/pulls_comments_test.go | 18 +- github/pulls_reviewers_test.go | 10 +- github/pulls_reviews_test.go | 36 +- github/pulls_test.go | 132 ++-- github/reactions_test.go | 28 +- github/repos_actions_access_test.go | 4 +- github/repos_actions_allowed_test.go | 6 +- github/repos_actions_permissions_test.go | 30 +- github/repos_autolinks_test.go | 14 +- github/repos_codeowners_test.go | 4 +- github/repos_collaborators_test.go | 28 +- github/repos_comments_test.go | 14 +- github/repos_commits_test.go | 90 +-- github/repos_community_health_test.go | 44 +- github/repos_contents_test.go | 56 +- .../repos_deployment_branch_policies_test.go | 14 +- .../repos_deployment_protection_rules_test.go | 42 +- github/repos_deployments_test.go | 16 +- github/repos_environments.go | 4 +- github/repos_environments_test.go | 40 +- github/repos_forks_test.go | 6 +- github/repos_hooks_configuration_test.go | 16 +- github/repos_hooks_deliveries_test.go | 10 +- github/repos_hooks_test.go | 8 +- github/repos_immutable_releases_test.go | 2 +- github/repos_invitations_test.go | 4 +- github/repos_keys_test.go | 8 +- github/repos_merging_test.go | 6 +- github/repos_pages_test.go | 60 +- github/repos_prereceive_hooks_test.go | 8 +- github/repos_releases_test.go | 30 +- github/repos_rules.go | 2 +- github/repos_rules_test.go | 30 +- github/repos_stats.go | 10 +- github/repos_stats_test.go | 24 +- github/repos_statuses_test.go | 8 +- github/repos_tags_test.go | 4 +- github/repos_test.go | 400 ++++++------- github/repos_traffic_test.go | 30 +- github/rules.go | 2 +- github/rules_test.go | 112 ++-- github/scim_test.go | 52 +- github/search_test.go | 92 +-- .../secret_scanning_custom_patterns_test.go | 36 +- .../secret_scanning_pattern_configs_test.go | 104 ++-- github/secret_scanning_test.go | 120 ++-- github/security_advisories_test.go | 562 ++++++++--------- github/strings_benchmark_test.go | 2 +- github/strings_test.go | 90 +-- github/sub_issue_test.go | 12 +- github/teams_discussion_comments_test.go | 60 +- github/teams_discussions_test.go | 140 ++--- github/teams_members_test.go | 16 +- github/teams_test.go | 160 ++--- github/users_administration_test.go | 2 +- github/users_blocking_test.go | 2 +- github/users_emails_test.go | 10 +- github/users_followers_test.go | 8 +- github/users_gpg_keys_test.go | 8 +- github/users_keys_test.go | 10 +- github/users_packages_test.go | 100 ++-- github/users_social_accounts_test.go | 6 +- github/users_ssh_signing_keys_test.go | 10 +- github/users_test.go | 16 +- go.mod | 2 +- 189 files changed, 4815 insertions(+), 4813 deletions(-) diff --git a/github/actions_artifacts_test.go b/github/actions_artifacts_test.go index 4ae31c47ff6..1be74b6222e 100644 --- a/github/actions_artifacts_test.go +++ b/github/actions_artifacts_test.go @@ -32,7 +32,7 @@ func TestActionsService_ListArtifacts(t *testing.T) { }) opts := &ListArtifactsOptions{ - Name: Ptr("TheArtifact"), + Name: new("TheArtifact"), ListOptions: ListOptions{Page: 2}, } ctx := t.Context() @@ -41,7 +41,7 @@ func TestActionsService_ListArtifacts(t *testing.T) { t.Errorf("Actions.ListArtifacts returned error: %v", err) } - want := &ArtifactList{TotalCount: Ptr(int64(1)), Artifacts: []*Artifact{{ID: Ptr(int64(1))}}} + want := &ArtifactList{TotalCount: new(int64(1)), Artifacts: []*Artifact{{ID: new(int64(1))}}} if !cmp.Equal(artifacts, want) { t.Errorf("Actions.ListArtifacts returned %+v, want %+v", artifacts, want) } @@ -123,7 +123,7 @@ func TestActionsService_ListWorkflowRunArtifacts(t *testing.T) { t.Errorf("Actions.ListWorkflowRunArtifacts returned error: %v", err) } - want := &ArtifactList{TotalCount: Ptr(int64(1)), Artifacts: []*Artifact{{ID: Ptr(int64(1))}}} + want := &ArtifactList{TotalCount: new(int64(1)), Artifacts: []*Artifact{{ID: new(int64(1))}}} if !cmp.Equal(artifacts, want) { t.Errorf("Actions.ListWorkflowRunArtifacts returned %+v, want %+v", artifacts, want) } @@ -205,11 +205,11 @@ func TestActionsService_GetArtifact(t *testing.T) { } want := &Artifact{ - ID: Ptr(int64(1)), - NodeID: Ptr("xyz"), - Name: Ptr("a"), - SizeInBytes: Ptr(int64(5)), - ArchiveDownloadURL: Ptr("u"), + ID: new(int64(1)), + NodeID: new("xyz"), + Name: new("a"), + SizeInBytes: new(int64(5)), + ArchiveDownloadURL: new("u"), } if !cmp.Equal(artifact, want) { t.Errorf("Actions.GetArtifact returned %+v, want %+v", artifact, want) diff --git a/github/actions_cache_test.go b/github/actions_cache_test.go index 14a8ad194d6..f94c71c2f4c 100644 --- a/github/actions_cache_test.go +++ b/github/actions_cache_test.go @@ -35,7 +35,7 @@ func TestActionsService_ListCaches(t *testing.T) { t.Errorf("Actions.ListCaches returned error: %v", err) } - want := &ActionsCacheList{TotalCount: 1, ActionsCaches: []*ActionsCache{{ID: Ptr(int64(1))}}} + want := &ActionsCacheList{TotalCount: 1, ActionsCaches: []*ActionsCache{{ID: new(int64(1))}}} if !cmp.Equal(cacheList, want) { t.Errorf("Actions.ListCaches returned %+v, want %+v", cacheList, want) } @@ -105,19 +105,19 @@ func TestActionsService_DeleteCachesByKey(t *testing.T) { }) ctx := t.Context() - _, err := client.Actions.DeleteCachesByKey(ctx, "o", "r", "1", Ptr("main")) + _, err := client.Actions.DeleteCachesByKey(ctx, "o", "r", "1", new("main")) if err != nil { t.Errorf("Actions.DeleteCachesByKey return error: %v", err) } const methodName = "DeleteCachesByKey" testBadOptions(t, methodName, func() (err error) { - _, err = client.Actions.DeleteCachesByKey(ctx, "\n", "\n", "\n", Ptr("\n")) + _, err = client.Actions.DeleteCachesByKey(ctx, "\n", "\n", "\n", new("\n")) return err }) testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { - return client.Actions.DeleteCachesByKey(ctx, "o", "r", "1", Ptr("main")) + return client.Actions.DeleteCachesByKey(ctx, "o", "r", "1", new("main")) }) } @@ -126,7 +126,7 @@ func TestActionsService_DeleteCachesByKey_invalidOwner(t *testing.T) { client, _, _ := setup(t) ctx := t.Context() - _, err := client.Actions.DeleteCachesByKey(ctx, "%", "r", "1", Ptr("main")) + _, err := client.Actions.DeleteCachesByKey(ctx, "%", "r", "1", new("main")) testURLParseError(t, err) } @@ -135,7 +135,7 @@ func TestActionsService_DeleteCachesByKey_invalidRepo(t *testing.T) { client, _, _ := setup(t) ctx := t.Context() - _, err := client.Actions.DeleteCachesByKey(ctx, "o", "%", "1", Ptr("main")) + _, err := client.Actions.DeleteCachesByKey(ctx, "o", "%", "1", new("main")) testURLParseError(t, err) } @@ -149,7 +149,7 @@ func TestActionsService_DeleteCachesByKey_notFound(t *testing.T) { }) ctx := t.Context() - resp, err := client.Actions.DeleteCachesByKey(ctx, "o", "r", "1", Ptr("main")) + resp, err := client.Actions.DeleteCachesByKey(ctx, "o", "r", "1", new("main")) if err == nil { t.Error("Expected HTTP 404 response") } diff --git a/github/actions_hosted_runners_test.go b/github/actions_hosted_runners_test.go index b4cc96a61ba..6f0fd9380cf 100644 --- a/github/actions_hosted_runners_test.go +++ b/github/actions_hosted_runners_test.go @@ -84,13 +84,13 @@ func TestActionsService_ListHostedRunners(t *testing.T) { TotalCount: 2, Runners: []*HostedRunner{ { - ID: Ptr(int64(5)), - Name: Ptr("My hosted ubuntu runner"), - RunnerGroupID: Ptr(int64(2)), - Platform: Ptr("linux-x64"), + ID: new(int64(5)), + Name: new("My hosted ubuntu runner"), + RunnerGroupID: new(int64(2)), + Platform: new("linux-x64"), ImageDetails: &HostedRunnerImageDetail{ - ID: Ptr("ubuntu-20.04"), - SizeGB: Ptr(int64(86)), + ID: new("ubuntu-20.04"), + SizeGB: new(int64(86)), }, MachineSizeDetails: &HostedRunnerMachineSpec{ ID: "4-core", @@ -98,9 +98,9 @@ func TestActionsService_ListHostedRunners(t *testing.T) { MemoryGB: 16, StorageGB: 150, }, - Status: Ptr("Ready"), - MaximumRunners: Ptr(int64(10)), - PublicIPEnabled: Ptr(true), + Status: new("Ready"), + MaximumRunners: new(int64(10)), + PublicIPEnabled: new(true), PublicIPs: []*HostedRunnerPublicIP{ { Enabled: true, @@ -111,13 +111,13 @@ func TestActionsService_ListHostedRunners(t *testing.T) { LastActiveOn: &referenceTimestamp, }, { - ID: Ptr(int64(7)), - Name: Ptr("My hosted Windows runner"), - RunnerGroupID: Ptr(int64(2)), - Platform: Ptr("win-x64"), + ID: new(int64(7)), + Name: new("My hosted Windows runner"), + RunnerGroupID: new(int64(2)), + Platform: new("win-x64"), ImageDetails: &HostedRunnerImageDetail{ - ID: Ptr("windows-latest"), - SizeGB: Ptr(int64(256)), + ID: new("windows-latest"), + SizeGB: new(int64(256)), }, MachineSizeDetails: &HostedRunnerMachineSpec{ ID: "8-core", @@ -125,9 +125,9 @@ func TestActionsService_ListHostedRunners(t *testing.T) { MemoryGB: 32, StorageGB: 300, }, - Status: Ptr("Ready"), - MaximumRunners: Ptr(int64(20)), - PublicIPEnabled: Ptr(false), + Status: new("Ready"), + MaximumRunners: new(int64(20)), + PublicIPEnabled: new(false), PublicIPs: []*HostedRunnerPublicIP{}, LastActiveOn: &referenceTimestamp, }, @@ -194,13 +194,13 @@ func TestActionsService_CreateHostedRunner(t *testing.T) { Image: HostedRunnerImage{ ID: "ubuntu-latest", Source: "github", - Version: Ptr("latest"), + Version: new("latest"), }, RunnerGroupID: 1, Size: "4-core", - MaximumRunners: Ptr(int64(50)), - EnableStaticIP: Ptr(false), - ImageGen: Ptr(true), + MaximumRunners: new(int64(50)), + EnableStaticIP: new(false), + ImageGen: new(true), } hostedRunner, _, err := client.Actions.CreateHostedRunner(ctx, "o", validReq) if err != nil { @@ -208,13 +208,13 @@ func TestActionsService_CreateHostedRunner(t *testing.T) { } want := &HostedRunner{ - ID: Ptr(int64(5)), - Name: Ptr("My hosted ubuntu runner"), - RunnerGroupID: Ptr(int64(2)), - Platform: Ptr("linux-x64"), + ID: new(int64(5)), + Name: new("My hosted ubuntu runner"), + RunnerGroupID: new(int64(2)), + Platform: new("linux-x64"), ImageDetails: &HostedRunnerImageDetail{ - ID: Ptr("ubuntu-20.04"), - SizeGB: Ptr(int64(86)), + ID: new("ubuntu-20.04"), + SizeGB: new(int64(86)), }, MachineSizeDetails: &HostedRunnerMachineSpec{ ID: "4-core", @@ -222,9 +222,9 @@ func TestActionsService_CreateHostedRunner(t *testing.T) { MemoryGB: 16, StorageGB: 150, }, - Status: Ptr("Ready"), - MaximumRunners: Ptr(int64(10)), - PublicIPEnabled: Ptr(true), + Status: new("Ready"), + MaximumRunners: new(int64(10)), + PublicIPEnabled: new(true), PublicIPs: []*HostedRunnerPublicIP{ { Enabled: true, @@ -252,7 +252,7 @@ func TestActionsService_CreateHostedRunner(t *testing.T) { Image: HostedRunnerImage{ ID: "ubuntu-latest", Source: "github", - Version: Ptr("latest"), + Version: new("latest"), }, RunnerGroupID: 1, }, @@ -273,7 +273,7 @@ func TestActionsService_CreateHostedRunner(t *testing.T) { Image: HostedRunnerImage{ ID: "ubuntu-latest", Source: "github", - Version: Ptr("latest"), + Version: new("latest"), }, RunnerGroupID: 1, Size: "4-core", @@ -287,7 +287,7 @@ func TestActionsService_CreateHostedRunner(t *testing.T) { Image: HostedRunnerImage{ ID: "ubuntu-latest", Source: "github", - Version: Ptr("latest"), + Version: new("latest"), }, Size: "4-core", }, @@ -623,13 +623,13 @@ func TestActionsService_GetHostedRunner(t *testing.T) { } want := &HostedRunner{ - ID: Ptr(int64(5)), - Name: Ptr("My hosted ubuntu runner"), - RunnerGroupID: Ptr(int64(2)), - Platform: Ptr("linux-x64"), + ID: new(int64(5)), + Name: new("My hosted ubuntu runner"), + RunnerGroupID: new(int64(2)), + Platform: new("linux-x64"), ImageDetails: &HostedRunnerImageDetail{ - ID: Ptr("ubuntu-20.04"), - SizeGB: Ptr(int64(86)), + ID: new("ubuntu-20.04"), + SizeGB: new(int64(86)), }, MachineSizeDetails: &HostedRunnerMachineSpec{ ID: "4-core", @@ -637,9 +637,9 @@ func TestActionsService_GetHostedRunner(t *testing.T) { MemoryGB: 16, StorageGB: 150, }, - Status: Ptr("Ready"), - MaximumRunners: Ptr(int64(10)), - PublicIPEnabled: Ptr(true), + Status: new("Ready"), + MaximumRunners: new(int64(10)), + PublicIPEnabled: new(true), PublicIPs: []*HostedRunnerPublicIP{ { Enabled: true, @@ -706,11 +706,11 @@ func TestActionsService_UpdateHostedRunner(t *testing.T) { ctx := t.Context() validReq := UpdateHostedRunnerRequest{ - Name: Ptr("My larger runner"), - RunnerGroupID: Ptr(int64(1)), - MaximumRunners: Ptr(int64(50)), - EnableStaticIP: Ptr(false), - ImageVersion: Ptr("1.0.0"), + Name: new("My larger runner"), + RunnerGroupID: new(int64(1)), + MaximumRunners: new(int64(50)), + EnableStaticIP: new(false), + ImageVersion: new("1.0.0"), } hostedRunner, _, err := client.Actions.UpdateHostedRunner(ctx, "o", 23, validReq) if err != nil { @@ -718,13 +718,13 @@ func TestActionsService_UpdateHostedRunner(t *testing.T) { } want := &HostedRunner{ - ID: Ptr(int64(5)), - Name: Ptr("My hosted ubuntu runner"), - RunnerGroupID: Ptr(int64(2)), - Platform: Ptr("linux-x64"), + ID: new(int64(5)), + Name: new("My hosted ubuntu runner"), + RunnerGroupID: new(int64(2)), + Platform: new("linux-x64"), ImageDetails: &HostedRunnerImageDetail{ - ID: Ptr("ubuntu-20.04"), - SizeGB: Ptr(int64(86)), + ID: new("ubuntu-20.04"), + SizeGB: new(int64(86)), }, MachineSizeDetails: &HostedRunnerMachineSpec{ ID: "4-core", @@ -732,9 +732,9 @@ func TestActionsService_UpdateHostedRunner(t *testing.T) { MemoryGB: 16, StorageGB: 150, }, - Status: Ptr("Ready"), - MaximumRunners: Ptr(int64(10)), - PublicIPEnabled: Ptr(true), + Status: new("Ready"), + MaximumRunners: new(int64(10)), + PublicIPEnabled: new(true), PublicIPs: []*HostedRunnerPublicIP{ { Enabled: true, @@ -806,13 +806,13 @@ func TestActionsService_DeleteHostedRunner(t *testing.T) { } want := &HostedRunner{ - ID: Ptr(int64(5)), - Name: Ptr("My hosted ubuntu runner"), - RunnerGroupID: Ptr(int64(2)), - Platform: Ptr("linux-x64"), + ID: new(int64(5)), + Name: new("My hosted ubuntu runner"), + RunnerGroupID: new(int64(2)), + Platform: new("linux-x64"), ImageDetails: &HostedRunnerImageDetail{ - ID: Ptr("ubuntu-20.04"), - SizeGB: Ptr(int64(86)), + ID: new("ubuntu-20.04"), + SizeGB: new(int64(86)), }, MachineSizeDetails: &HostedRunnerMachineSpec{ ID: "4-core", @@ -820,9 +820,9 @@ func TestActionsService_DeleteHostedRunner(t *testing.T) { MemoryGB: 16, StorageGB: 150, }, - Status: Ptr("Ready"), - MaximumRunners: Ptr(int64(10)), - PublicIPEnabled: Ptr(true), + Status: new("Ready"), + MaximumRunners: new(int64(10)), + PublicIPEnabled: new(true), PublicIPs: []*HostedRunnerPublicIP{ { Enabled: true, diff --git a/github/actions_oidc_test.go b/github/actions_oidc_test.go index 710012bf469..9f6c23afd43 100644 --- a/github/actions_oidc_test.go +++ b/github/actions_oidc_test.go @@ -28,7 +28,7 @@ func TestActionsService_GetOrgOIDCSubjectClaimCustomTemplate(t *testing.T) { t.Errorf("Actions.GetOrgOIDCSubjectClaimCustomTemplate returned error: %v", err) } - want := &OIDCSubjectClaimCustomTemplate{IncludeClaimKeys: []string{"repo", "context"}, UseImmutableSubject: Ptr(true)} + want := &OIDCSubjectClaimCustomTemplate{IncludeClaimKeys: []string{"repo", "context"}, UseImmutableSubject: new(true)} if !cmp.Equal(template, want) { t.Errorf("Actions.GetOrgOIDCSubjectClaimCustomTemplate returned %+v, want %+v", template, want) } @@ -63,7 +63,7 @@ func TestActionsService_GetRepoOIDCSubjectClaimCustomTemplate(t *testing.T) { t.Errorf("Actions.GetRepoOIDCSubjectClaimCustomTemplate returned error: %v", err) } - want := &OIDCSubjectClaimCustomTemplate{UseDefault: Ptr(false), IncludeClaimKeys: []string{"repo", "context"}, UseImmutableSubject: Ptr(true), SubClaimPrefix: Ptr("repo:o/r")} + want := &OIDCSubjectClaimCustomTemplate{UseDefault: new(false), IncludeClaimKeys: []string{"repo", "context"}, UseImmutableSubject: new(true), SubClaimPrefix: new("repo:o/r")} if !cmp.Equal(template, want) { t.Errorf("Actions.GetRepoOIDCSubjectClaimCustomTemplate returned %+v, want %+v", template, want) } @@ -89,7 +89,7 @@ func TestActionsService_SetOrgOIDCSubjectClaimCustomTemplate(t *testing.T) { input := OIDCSubjectClaimCustomTemplate{ IncludeClaimKeys: []string{"repo", "context"}, - UseImmutableSubject: Ptr(true), + UseImmutableSubject: new(true), } mux.HandleFunc("/orgs/o/actions/oidc/customization/sub", func(w http.ResponseWriter, r *http.Request) { @@ -122,7 +122,7 @@ func TestActionsService_SetRepoOIDCSubjectClaimCustomTemplate(t *testing.T) { client, mux, _ := setup(t) input := OIDCSubjectClaimCustomTemplate{ - UseDefault: Ptr(false), + UseDefault: new(false), IncludeClaimKeys: []string{"repo", "context"}, } @@ -156,7 +156,7 @@ func TestActionsService_SetRepoOIDCSubjectClaimCustomTemplateToDefault(t *testin client, mux, _ := setup(t) input := OIDCSubjectClaimCustomTemplate{ - UseDefault: Ptr(true), + UseDefault: new(true), } mux.HandleFunc("/repos/o/r/actions/oidc/customization/sub", func(w http.ResponseWriter, r *http.Request) { diff --git a/github/actions_permissions_enterprise_test.go b/github/actions_permissions_enterprise_test.go index e56d6b11960..c1a98baf3c7 100644 --- a/github/actions_permissions_enterprise_test.go +++ b/github/actions_permissions_enterprise_test.go @@ -27,7 +27,7 @@ func TestActionsService_GetActionsPermissionsInEnterprise(t *testing.T) { if err != nil { t.Errorf("Actions.GetActionsPermissionsInEnterprise returned error: %v", err) } - want := &ActionsPermissionsEnterprise{EnabledOrganizations: Ptr("all"), AllowedActions: Ptr("all")} + want := &ActionsPermissionsEnterprise{EnabledOrganizations: new("all"), AllowedActions: new("all")} if !cmp.Equal(ent, want) { t.Errorf("Actions.GetActionsPermissionsInEnterprise returned %+v, want %+v", ent, want) } @@ -51,7 +51,7 @@ func TestActionsService_UpdateActionsPermissionsInEnterprise(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - input := &ActionsPermissionsEnterprise{EnabledOrganizations: Ptr("all"), AllowedActions: Ptr("selected")} + input := &ActionsPermissionsEnterprise{EnabledOrganizations: new("all"), AllowedActions: new("selected")} mux.HandleFunc("/enterprises/e/actions/permissions", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "PUT") @@ -65,7 +65,7 @@ func TestActionsService_UpdateActionsPermissionsInEnterprise(t *testing.T) { t.Errorf("Actions.UpdateActionsPermissionsInEnterprise returned error: %v", err) } - want := &ActionsPermissionsEnterprise{EnabledOrganizations: Ptr("all"), AllowedActions: Ptr("selected")} + want := &ActionsPermissionsEnterprise{EnabledOrganizations: new("all"), AllowedActions: new("selected")} if !cmp.Equal(ent, want) { t.Errorf("Actions.UpdateActionsPermissionsInEnterprise returned %+v, want %+v", ent, want) } @@ -107,8 +107,8 @@ func TestActionsService_ListEnabledOrgsInEnterprise(t *testing.T) { } want := &ActionsEnabledOnEnterpriseRepos{TotalCount: int(2), Organizations: []*Organization{ - {ID: Ptr(int64(2))}, - {ID: Ptr(int64(3))}, + {ID: new(int64(2))}, + {ID: new(int64(3))}, }} if !cmp.Equal(got, want) { t.Errorf("Actions.ListEnabledOrgsInEnterprise returned %+v, want %+v", got, want) @@ -232,7 +232,7 @@ func TestActionsService_GetActionsAllowedInEnterprise(t *testing.T) { if err != nil { t.Errorf("Actions.GetActionsAllowedInEnterprise returned error: %v", err) } - want := &ActionsAllowed{GithubOwnedAllowed: Ptr(true), VerifiedAllowed: Ptr(false), PatternsAllowed: []string{"a/b"}} + want := &ActionsAllowed{GithubOwnedAllowed: new(true), VerifiedAllowed: new(false), PatternsAllowed: []string{"a/b"}} if !cmp.Equal(ent, want) { t.Errorf("Actions.GetActionsAllowedInEnterprise returned %+v, want %+v", ent, want) } @@ -256,7 +256,7 @@ func TestActionsService_UpdateActionsAllowedInEnterprise(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - input := &ActionsAllowed{GithubOwnedAllowed: Ptr(true), VerifiedAllowed: Ptr(false), PatternsAllowed: []string{"a/b"}} + input := &ActionsAllowed{GithubOwnedAllowed: new(true), VerifiedAllowed: new(false), PatternsAllowed: []string{"a/b"}} mux.HandleFunc("/enterprises/e/actions/permissions/selected-actions", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "PUT") @@ -270,7 +270,7 @@ func TestActionsService_UpdateActionsAllowedInEnterprise(t *testing.T) { t.Errorf("Actions.UpdateActionsAllowedInEnterprise returned error: %v", err) } - want := &ActionsAllowed{GithubOwnedAllowed: Ptr(true), VerifiedAllowed: Ptr(false), PatternsAllowed: []string{"a/b"}} + want := &ActionsAllowed{GithubOwnedAllowed: new(true), VerifiedAllowed: new(false), PatternsAllowed: []string{"a/b"}} if !cmp.Equal(ent, want) { t.Errorf("Actions.UpdateActionsAllowedInEnterprise returned %+v, want %+v", ent, want) } @@ -304,7 +304,7 @@ func TestActionsService_GetDefaultWorkflowPermissionsInEnterprise(t *testing.T) if err != nil { t.Errorf("Actions.GetDefaultWorkflowPermissionsInEnterprise returned error: %v", err) } - want := &DefaultWorkflowPermissionEnterprise{DefaultWorkflowPermissions: Ptr("read"), CanApprovePullRequestReviews: Ptr(true)} + want := &DefaultWorkflowPermissionEnterprise{DefaultWorkflowPermissions: new("read"), CanApprovePullRequestReviews: new(true)} if !cmp.Equal(ent, want) { t.Errorf("Actions.GetDefaultWorkflowPermissionsInEnterprise returned %+v, want %+v", ent, want) } @@ -328,7 +328,7 @@ func TestActionsService_UpdateDefaultWorkflowPermissionsInEnterprise(t *testing. t.Parallel() client, mux, _ := setup(t) - input := &DefaultWorkflowPermissionEnterprise{DefaultWorkflowPermissions: Ptr("read"), CanApprovePullRequestReviews: Ptr(true)} + input := &DefaultWorkflowPermissionEnterprise{DefaultWorkflowPermissions: new("read"), CanApprovePullRequestReviews: new(true)} mux.HandleFunc("/enterprises/e/actions/permissions/workflow", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "PUT") @@ -342,7 +342,7 @@ func TestActionsService_UpdateDefaultWorkflowPermissionsInEnterprise(t *testing. t.Errorf("Actions.UpdateDefaultWorkflowPermissionsInEnterprise returned error: %v", err) } - want := &DefaultWorkflowPermissionEnterprise{DefaultWorkflowPermissions: Ptr("read"), CanApprovePullRequestReviews: Ptr(true)} + want := &DefaultWorkflowPermissionEnterprise{DefaultWorkflowPermissions: new("read"), CanApprovePullRequestReviews: new(true)} if !cmp.Equal(ent, want) { t.Errorf("Actions.UpdateDefaultWorkflowPermissionsInEnterprise returned %+v, want %+v", ent, want) } @@ -378,8 +378,8 @@ func TestActionsService_GetArtifactAndLogRetentionPeriodInEnterprise(t *testing. } want := &ArtifactPeriod{ - Days: Ptr(90), - MaximumAllowedDays: Ptr(365), + Days: new(90), + MaximumAllowedDays: new(365), } if !cmp.Equal(period, want) { t.Errorf("Actions.GetArtifactAndLogRetentionPeriodInEnterprise = %+v, want %+v", period, want) @@ -404,7 +404,7 @@ func TestActionsService_UpdateArtifactAndLogRetentionPeriodInEnterprise(t *testi t.Parallel() client, mux, _ := setup(t) - input := &ArtifactPeriodOpt{Days: Ptr(90)} + input := &ArtifactPeriodOpt{Days: new(90)} mux.HandleFunc("/enterprises/e/actions/permissions/artifact-and-log-retention", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "PUT") @@ -447,7 +447,7 @@ func TestActionsService_GetSelfHostedRunnerPermissionsInEnterprise(t *testing.T) if err != nil { t.Errorf("Actions.GetSelfHostedRunnerPermissionsInEnterprise returned error: %v", err) } - want := &SelfHostRunnerPermissionsEnterprise{DisableSelfHostedRunnersForAllOrgs: Ptr(true)} + want := &SelfHostRunnerPermissionsEnterprise{DisableSelfHostedRunnersForAllOrgs: new(true)} if !cmp.Equal(permissions, want) { t.Errorf("Actions.GetSelfHostedRunnerPermissionsInEnterprise returned %+v, want %+v", permissions, want) } @@ -471,7 +471,7 @@ func TestActionsService_UpdateSelfHostedRunnerPermissionsInEnterprise(t *testing t.Parallel() client, mux, _ := setup(t) - input := &SelfHostRunnerPermissionsEnterprise{DisableSelfHostedRunnersForAllOrgs: Ptr(false)} + input := &SelfHostRunnerPermissionsEnterprise{DisableSelfHostedRunnersForAllOrgs: new(false)} mux.HandleFunc("/enterprises/e/actions/permissions/self-hosted-runners", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "PUT") @@ -515,10 +515,10 @@ func TestActionsService_GetPrivateRepoForkPRWorkflowSettingsInEnterprise(t *test t.Errorf("Actions.GetPrivateRepoForkPRWorkflowSettingsInEnterprise returned error: %v", err) } want := &WorkflowsPermissions{ - RunWorkflowsFromForkPullRequests: Ptr(true), - SendWriteTokensToWorkflows: Ptr(false), - SendSecretsAndVariables: Ptr(true), - RequireApprovalForForkPRWorkflows: Ptr(false), + RunWorkflowsFromForkPullRequests: new(true), + SendWriteTokensToWorkflows: new(false), + SendSecretsAndVariables: new(true), + RequireApprovalForForkPRWorkflows: new(false), } if !cmp.Equal(permissions, want) { t.Errorf("Actions.GetPrivateRepoForkPRWorkflowSettingsInEnterprise returned %+v, want %+v", permissions, want) @@ -545,8 +545,8 @@ func TestActionsService_UpdatePrivateRepoForkPRWorkflowSettingsInEnterprise(t *t input := &WorkflowsPermissionsOpt{ RunWorkflowsFromForkPullRequests: true, - SendWriteTokensToWorkflows: Ptr(false), - SendSecretsAndVariables: Ptr(true), + SendWriteTokensToWorkflows: new(false), + SendSecretsAndVariables: new(true), } mux.HandleFunc("/enterprises/e/actions/permissions/fork-pr-workflows-private-repos", func(w http.ResponseWriter, r *http.Request) { diff --git a/github/actions_permissions_orgs_test.go b/github/actions_permissions_orgs_test.go index b8dddddba72..121c774ecac 100644 --- a/github/actions_permissions_orgs_test.go +++ b/github/actions_permissions_orgs_test.go @@ -27,7 +27,7 @@ func TestActionsService_GetActionsPermissions(t *testing.T) { if err != nil { t.Errorf("Actions.GetActionsPermissions returned error: %v", err) } - want := &ActionsPermissions{EnabledRepositories: Ptr("all"), AllowedActions: Ptr("all"), SHAPinningRequired: Ptr(true)} + want := &ActionsPermissions{EnabledRepositories: new("all"), AllowedActions: new("all"), SHAPinningRequired: new(true)} if !cmp.Equal(org, want) { t.Errorf("Actions.GetActionsPermissions returned %+v, want %+v", org, want) } @@ -51,7 +51,7 @@ func TestActionsService_UpdateActionsPermissions(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - input := &ActionsPermissions{EnabledRepositories: Ptr("all"), AllowedActions: Ptr("selected"), SHAPinningRequired: Ptr(true)} + input := &ActionsPermissions{EnabledRepositories: new("all"), AllowedActions: new("selected"), SHAPinningRequired: new(true)} mux.HandleFunc("/orgs/o/actions/permissions", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "PUT") @@ -65,7 +65,7 @@ func TestActionsService_UpdateActionsPermissions(t *testing.T) { t.Errorf("Actions.UpdateActionsPermissions returned error: %v", err) } - want := &ActionsPermissions{EnabledRepositories: Ptr("all"), AllowedActions: Ptr("selected"), SHAPinningRequired: Ptr(true)} + want := &ActionsPermissions{EnabledRepositories: new("all"), AllowedActions: new("selected"), SHAPinningRequired: new(true)} if !cmp.Equal(org, want) { t.Errorf("Actions.UpdateActionsPermissions returned %+v, want %+v", org, want) } @@ -107,8 +107,8 @@ func TestActionsService_ListEnabledReposInOrg(t *testing.T) { } want := &ActionsEnabledOnOrgRepos{TotalCount: int(2), Repositories: []*Repository{ - {ID: Ptr(int64(2))}, - {ID: Ptr(int64(3))}, + {ID: new(int64(2))}, + {ID: new(int64(3))}, }} if !cmp.Equal(got, want) { t.Errorf("Actions.ListEnabledReposInOrg returned %+v, want %+v", got, want) @@ -232,7 +232,7 @@ func TestActionsService_GetActionsAllowed(t *testing.T) { if err != nil { t.Errorf("Actions.GetActionsAllowed returned error: %v", err) } - want := &ActionsAllowed{GithubOwnedAllowed: Ptr(true), VerifiedAllowed: Ptr(false), PatternsAllowed: []string{"a/b"}} + want := &ActionsAllowed{GithubOwnedAllowed: new(true), VerifiedAllowed: new(false), PatternsAllowed: []string{"a/b"}} if !cmp.Equal(org, want) { t.Errorf("Actions.GetActionsAllowed returned %+v, want %+v", org, want) } @@ -266,7 +266,7 @@ func TestActionsService_GetActionsAllowed_emptyPatterns(t *testing.T) { if err != nil { t.Errorf("Actions.GetActionsAllowed returned error: %v", err) } - want := &ActionsAllowed{GithubOwnedAllowed: Ptr(true), VerifiedAllowed: Ptr(false), PatternsAllowed: []string{}} + want := &ActionsAllowed{GithubOwnedAllowed: new(true), VerifiedAllowed: new(false), PatternsAllowed: []string{}} if !cmp.Equal(org, want) { t.Errorf("Actions.GetActionsAllowed returned %+v, want %+v", org, want) } @@ -290,7 +290,7 @@ func TestActionsService_UpdateActionsAllowed(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - input := &ActionsAllowed{GithubOwnedAllowed: Ptr(true), VerifiedAllowed: Ptr(false), PatternsAllowed: []string{"a/b"}} + input := &ActionsAllowed{GithubOwnedAllowed: new(true), VerifiedAllowed: new(false), PatternsAllowed: []string{"a/b"}} mux.HandleFunc("/orgs/o/actions/permissions/selected-actions", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "PUT") @@ -304,7 +304,7 @@ func TestActionsService_UpdateActionsAllowed(t *testing.T) { t.Errorf("Actions.UpdateActionsAllowed returned error: %v", err) } - want := &ActionsAllowed{GithubOwnedAllowed: Ptr(true), VerifiedAllowed: Ptr(false), PatternsAllowed: []string{"a/b"}} + want := &ActionsAllowed{GithubOwnedAllowed: new(true), VerifiedAllowed: new(false), PatternsAllowed: []string{"a/b"}} if !cmp.Equal(org, want) { t.Errorf("Actions.UpdateActionsAllowed returned %+v, want %+v", org, want) } @@ -328,7 +328,7 @@ func TestActionsService_UpdateActionsAllowed_emptyPatterns(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - input := &ActionsAllowed{GithubOwnedAllowed: Ptr(true), VerifiedAllowed: Ptr(false), PatternsAllowed: []string{}} + input := &ActionsAllowed{GithubOwnedAllowed: new(true), VerifiedAllowed: new(false), PatternsAllowed: []string{}} mux.HandleFunc("/orgs/o/actions/permissions/selected-actions", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "PUT") @@ -342,7 +342,7 @@ func TestActionsService_UpdateActionsAllowed_emptyPatterns(t *testing.T) { t.Errorf("Actions.UpdateActionsAllowed returned error: %v", err) } - want := &ActionsAllowed{GithubOwnedAllowed: Ptr(true), VerifiedAllowed: Ptr(false), PatternsAllowed: []string{}} + want := &ActionsAllowed{GithubOwnedAllowed: new(true), VerifiedAllowed: new(false), PatternsAllowed: []string{}} if !cmp.Equal(org, want) { t.Errorf("Actions.UpdateActionsAllowed returned %+v, want %+v", org, want) } @@ -352,7 +352,7 @@ func TestActionsService_UpdateActionsAllowed_nilPatterns(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - input := &ActionsAllowed{GithubOwnedAllowed: Ptr(true), VerifiedAllowed: Ptr(false), PatternsAllowed: nil} + input := &ActionsAllowed{GithubOwnedAllowed: new(true), VerifiedAllowed: new(false), PatternsAllowed: nil} mux.HandleFunc("/orgs/o/actions/permissions/selected-actions", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "PUT") @@ -366,7 +366,7 @@ func TestActionsService_UpdateActionsAllowed_nilPatterns(t *testing.T) { t.Errorf("Actions.UpdateActionsAllowed returned error: %v", err) } - want := &ActionsAllowed{GithubOwnedAllowed: Ptr(true), VerifiedAllowed: Ptr(false), PatternsAllowed: []string{"a/b"}} + want := &ActionsAllowed{GithubOwnedAllowed: new(true), VerifiedAllowed: new(false), PatternsAllowed: []string{"a/b"}} if !cmp.Equal(org, want) { t.Errorf("Actions.UpdateActionsAllowed returned %+v, want %+v", org, want) } @@ -376,7 +376,7 @@ func TestActionsService_UpdateActionsAllowed_omittedPatterns(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - input := &ActionsAllowed{GithubOwnedAllowed: Ptr(true), VerifiedAllowed: Ptr(false)} + input := &ActionsAllowed{GithubOwnedAllowed: new(true), VerifiedAllowed: new(false)} mux.HandleFunc("/orgs/o/actions/permissions/selected-actions", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "PUT") @@ -390,7 +390,7 @@ func TestActionsService_UpdateActionsAllowed_omittedPatterns(t *testing.T) { t.Errorf("Actions.UpdateActionsAllowed returned error: %v", err) } - want := &ActionsAllowed{GithubOwnedAllowed: Ptr(true), VerifiedAllowed: Ptr(false), PatternsAllowed: []string{"a/b"}} + want := &ActionsAllowed{GithubOwnedAllowed: new(true), VerifiedAllowed: new(false), PatternsAllowed: []string{"a/b"}} if !cmp.Equal(org, want) { t.Errorf("Actions.UpdateActionsAllowed returned %+v, want %+v", org, want) } @@ -410,7 +410,7 @@ func TestActionsService_GetDefaultWorkflowPermissionsInOrganization(t *testing.T if err != nil { t.Errorf("Actions.GetDefaultWorkflowPermissionsInOrganization returned error: %v", err) } - want := &DefaultWorkflowPermissionOrganization{DefaultWorkflowPermissions: Ptr("read"), CanApprovePullRequestReviews: Ptr(true)} + want := &DefaultWorkflowPermissionOrganization{DefaultWorkflowPermissions: new("read"), CanApprovePullRequestReviews: new(true)} if !cmp.Equal(org, want) { t.Errorf("Actions.GetDefaultWorkflowPermissionsInOrganization returned %+v, want %+v", org, want) } @@ -434,7 +434,7 @@ func TestActionsService_UpdateDefaultWorkflowPermissionsInOrganization(t *testin t.Parallel() client, mux, _ := setup(t) - input := &DefaultWorkflowPermissionOrganization{DefaultWorkflowPermissions: Ptr("read"), CanApprovePullRequestReviews: Ptr(true)} + input := &DefaultWorkflowPermissionOrganization{DefaultWorkflowPermissions: new("read"), CanApprovePullRequestReviews: new(true)} mux.HandleFunc("/orgs/o/actions/permissions/workflow", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "PUT") @@ -448,7 +448,7 @@ func TestActionsService_UpdateDefaultWorkflowPermissionsInOrganization(t *testin t.Errorf("Actions.UpdateDefaultWorkflowPermissionsInOrganization returned error: %v", err) } - want := &DefaultWorkflowPermissionOrganization{DefaultWorkflowPermissions: Ptr("read"), CanApprovePullRequestReviews: Ptr(true)} + want := &DefaultWorkflowPermissionOrganization{DefaultWorkflowPermissions: new("read"), CanApprovePullRequestReviews: new(true)} if !cmp.Equal(org, want) { t.Errorf("Actions.UpdateDefaultWorkflowPermissionsInOrganization returned %+v, want %+v", org, want) } @@ -484,8 +484,8 @@ func TestActionsService_GetArtifactAndLogRetentionPeriodInOrganization(t *testin } want := &ArtifactPeriod{ - Days: Ptr(90), - MaximumAllowedDays: Ptr(365), + Days: new(90), + MaximumAllowedDays: new(365), } if !cmp.Equal(period, want) { t.Errorf("Actions.GetArtifactAndLogRetentionPeriodInOrganization = %+v, want %+v", period, want) @@ -510,7 +510,7 @@ func TestActionsService_UpdateArtifactAndLogRetentionPeriodInOrganization(t *tes t.Parallel() client, mux, _ := setup(t) - input := &ArtifactPeriodOpt{Days: Ptr(90)} + input := &ArtifactPeriodOpt{Days: new(90)} mux.HandleFunc("/orgs/o/actions/permissions/artifact-and-log-retention", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "PUT") @@ -554,8 +554,8 @@ func TestActionsService_GetSelfHostedRunnersSettingsInOrganization(t *testing.T) t.Errorf("Actions.GetSelfHostedRunnersSettingsInOrganization returned error: %v", err) } want := &SelfHostedRunnersSettingsOrganization{ - EnabledRepositories: Ptr("all"), - SelectedRepositoriesURL: Ptr("https://api.github.com/orgs/octo-org/actions/permissions/self-hosted-runners/repositories"), + EnabledRepositories: new("all"), + SelectedRepositoriesURL: new("https://api.github.com/orgs/octo-org/actions/permissions/self-hosted-runners/repositories"), } if !cmp.Equal(settings, want) { t.Errorf("Actions.GetSelfHostedRunnersSettingsInOrganization returned %+v, want %+v", settings, want) @@ -580,7 +580,7 @@ func TestActionsService_UpdateSelfHostedRunnersSettingsInOrganization(t *testing t.Parallel() client, mux, _ := setup(t) - input := &SelfHostedRunnersSettingsOrganizationOpt{EnabledRepositories: Ptr("selected")} + input := &SelfHostedRunnersSettingsOrganizationOpt{EnabledRepositories: new("selected")} mux.HandleFunc("/orgs/o/actions/permissions/self-hosted-runners", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "PUT") @@ -631,8 +631,8 @@ func TestActionsService_ListRepositoriesSelfHostedRunnersAllowedInOrganization(t } want := &SelfHostedRunnersAllowedRepos{TotalCount: int(2), Repositories: []*Repository{ - {ID: Ptr(int64(2))}, - {ID: Ptr(int64(3))}, + {ID: new(int64(2))}, + {ID: new(int64(3))}, }} if !cmp.Equal(got, want) { t.Errorf("Actions.ListRepositoriesSelfHostedRunnersAllowedInOrganization returned %+v, want %+v", got, want) @@ -757,10 +757,10 @@ func TestActionsService_GetPrivateRepoForkPRWorkflowSettingsInOrganization(t *te t.Errorf("Actions.GetPrivateRepoForkPRWorkflowSettingsInOrganization returned error: %v", err) } want := &WorkflowsPermissions{ - RunWorkflowsFromForkPullRequests: Ptr(true), - SendWriteTokensToWorkflows: Ptr(false), - SendSecretsAndVariables: Ptr(true), - RequireApprovalForForkPRWorkflows: Ptr(false), + RunWorkflowsFromForkPullRequests: new(true), + SendWriteTokensToWorkflows: new(false), + SendSecretsAndVariables: new(true), + RequireApprovalForForkPRWorkflows: new(false), } if !cmp.Equal(permissions, want) { t.Errorf("Actions.GetPrivateRepoForkPRWorkflowSettingsInOrganization returned %+v, want %+v", permissions, want) @@ -787,8 +787,8 @@ func TestActionsService_UpdatePrivateRepoForkPRWorkflowSettingsInOrganization(t input := &WorkflowsPermissionsOpt{ RunWorkflowsFromForkPullRequests: true, - SendWriteTokensToWorkflows: Ptr(false), - SendSecretsAndVariables: Ptr(true), + SendWriteTokensToWorkflows: new(false), + SendSecretsAndVariables: new(true), } mux.HandleFunc("/orgs/o/actions/permissions/fork-pr-workflows-private-repos", func(w http.ResponseWriter, r *http.Request) { diff --git a/github/actions_runner_groups_test.go b/github/actions_runner_groups_test.go index 51578b1ee20..820021d0bbf 100644 --- a/github/actions_runner_groups_test.go +++ b/github/actions_runner_groups_test.go @@ -33,9 +33,9 @@ func TestActionsService_ListOrganizationRunnerGroups(t *testing.T) { want := &RunnerGroups{ TotalCount: 3, RunnerGroups: []*RunnerGroup{ - {ID: Ptr(int64(1)), Name: Ptr("Default"), Visibility: Ptr("all"), Default: Ptr(true), RunnersURL: Ptr("https://api.github.com/orgs/octo-org/actions/runner_groups/1/runners"), Inherited: Ptr(false), AllowsPublicRepositories: Ptr(true), RestrictedToWorkflows: Ptr(true), SelectedWorkflows: []string{"a", "b"}}, - {ID: Ptr(int64(2)), Name: Ptr("octo-runner-group"), Visibility: Ptr("selected"), Default: Ptr(false), SelectedRepositoriesURL: Ptr("https://api.github.com/orgs/octo-org/actions/runner_groups/2/repositories"), RunnersURL: Ptr("https://api.github.com/orgs/octo-org/actions/runner_groups/2/runners"), Inherited: Ptr(true), AllowsPublicRepositories: Ptr(true), RestrictedToWorkflows: Ptr(false), SelectedWorkflows: []string{}}, - {ID: Ptr(int64(3)), Name: Ptr("expensive-hardware"), Visibility: Ptr("private"), Default: Ptr(false), RunnersURL: Ptr("https://api.github.com/orgs/octo-org/actions/runner_groups/3/runners"), Inherited: Ptr(false), AllowsPublicRepositories: Ptr(true), RestrictedToWorkflows: Ptr(false), SelectedWorkflows: []string{}}, + {ID: new(int64(1)), Name: new("Default"), Visibility: new("all"), Default: new(true), RunnersURL: new("https://api.github.com/orgs/octo-org/actions/runner_groups/1/runners"), Inherited: new(false), AllowsPublicRepositories: new(true), RestrictedToWorkflows: new(true), SelectedWorkflows: []string{"a", "b"}}, + {ID: new(int64(2)), Name: new("octo-runner-group"), Visibility: new("selected"), Default: new(false), SelectedRepositoriesURL: new("https://api.github.com/orgs/octo-org/actions/runner_groups/2/repositories"), RunnersURL: new("https://api.github.com/orgs/octo-org/actions/runner_groups/2/runners"), Inherited: new(true), AllowsPublicRepositories: new(true), RestrictedToWorkflows: new(false), SelectedWorkflows: []string{}}, + {ID: new(int64(3)), Name: new("expensive-hardware"), Visibility: new("private"), Default: new(false), RunnersURL: new("https://api.github.com/orgs/octo-org/actions/runner_groups/3/runners"), Inherited: new(false), AllowsPublicRepositories: new(true), RestrictedToWorkflows: new(false), SelectedWorkflows: []string{}}, }, } if !cmp.Equal(groups, want) { @@ -77,9 +77,9 @@ func TestActionsService_ListOrganizationRunnerGroupsVisibleToRepo(t *testing.T) want := &RunnerGroups{ TotalCount: 3, RunnerGroups: []*RunnerGroup{ - {ID: Ptr(int64(1)), Name: Ptr("Default"), Visibility: Ptr("all"), Default: Ptr(true), RunnersURL: Ptr("https://api.github.com/orgs/octo-org/actions/runner_groups/1/runners"), Inherited: Ptr(false), AllowsPublicRepositories: Ptr(true), RestrictedToWorkflows: Ptr(false), SelectedWorkflows: []string{}}, - {ID: Ptr(int64(2)), Name: Ptr("octo-runner-group"), Visibility: Ptr("selected"), Default: Ptr(false), SelectedRepositoriesURL: Ptr("https://api.github.com/orgs/octo-org/actions/runner_groups/2/repositories"), RunnersURL: Ptr("https://api.github.com/orgs/octo-org/actions/runner_groups/2/runners"), Inherited: Ptr(true), AllowsPublicRepositories: Ptr(true), RestrictedToWorkflows: Ptr(false), SelectedWorkflows: []string{}}, - {ID: Ptr(int64(3)), Name: Ptr("expensive-hardware"), Visibility: Ptr("private"), Default: Ptr(false), RunnersURL: Ptr("https://api.github.com/orgs/octo-org/actions/runner_groups/3/runners"), Inherited: Ptr(false), AllowsPublicRepositories: Ptr(true), RestrictedToWorkflows: Ptr(false), SelectedWorkflows: []string{}}, + {ID: new(int64(1)), Name: new("Default"), Visibility: new("all"), Default: new(true), RunnersURL: new("https://api.github.com/orgs/octo-org/actions/runner_groups/1/runners"), Inherited: new(false), AllowsPublicRepositories: new(true), RestrictedToWorkflows: new(false), SelectedWorkflows: []string{}}, + {ID: new(int64(2)), Name: new("octo-runner-group"), Visibility: new("selected"), Default: new(false), SelectedRepositoriesURL: new("https://api.github.com/orgs/octo-org/actions/runner_groups/2/repositories"), RunnersURL: new("https://api.github.com/orgs/octo-org/actions/runner_groups/2/runners"), Inherited: new(true), AllowsPublicRepositories: new(true), RestrictedToWorkflows: new(false), SelectedWorkflows: []string{}}, + {ID: new(int64(3)), Name: new("expensive-hardware"), Visibility: new("private"), Default: new(false), RunnersURL: new("https://api.github.com/orgs/octo-org/actions/runner_groups/3/runners"), Inherited: new(false), AllowsPublicRepositories: new(true), RestrictedToWorkflows: new(false), SelectedWorkflows: []string{}}, }, } if !cmp.Equal(groups, want) { @@ -117,17 +117,17 @@ func TestActionsService_GetOrganizationRunnerGroup(t *testing.T) { } want := &RunnerGroup{ - ID: Ptr(int64(2)), - Name: Ptr("octo-runner-group"), - Visibility: Ptr("selected"), - Default: Ptr(false), - SelectedRepositoriesURL: Ptr("https://api.github.com/orgs/octo-org/actions/runner_groups/2/repositories"), - RunnersURL: Ptr("https://api.github.com/orgs/octo-org/actions/runner_groups/2/runners"), - HostedRunnersURL: Ptr("https://api.github.com/orgs/octo-org/actions/runner_groups/2/hosted-runners"), - NetworkConfigurationID: Ptr("EC486D5D793175D7E3B29C27318D5C1AAE49A7833FC85F2E82C3D2C54AC7D3BA"), - Inherited: Ptr(false), - AllowsPublicRepositories: Ptr(true), - RestrictedToWorkflows: Ptr(false), + ID: new(int64(2)), + Name: new("octo-runner-group"), + Visibility: new("selected"), + Default: new(false), + SelectedRepositoriesURL: new("https://api.github.com/orgs/octo-org/actions/runner_groups/2/repositories"), + RunnersURL: new("https://api.github.com/orgs/octo-org/actions/runner_groups/2/runners"), + HostedRunnersURL: new("https://api.github.com/orgs/octo-org/actions/runner_groups/2/hosted-runners"), + NetworkConfigurationID: new("EC486D5D793175D7E3B29C27318D5C1AAE49A7833FC85F2E82C3D2C54AC7D3BA"), + Inherited: new(false), + AllowsPublicRepositories: new(true), + RestrictedToWorkflows: new(false), SelectedWorkflows: []string{}, } @@ -186,12 +186,12 @@ func TestActionsService_CreateOrganizationRunnerGroup(t *testing.T) { ctx := t.Context() req := CreateRunnerGroupRequest{ - Name: Ptr("octo-runner-group"), - Visibility: Ptr("selected"), - AllowsPublicRepositories: Ptr(true), - RestrictedToWorkflows: Ptr(false), + Name: new("octo-runner-group"), + Visibility: new("selected"), + AllowsPublicRepositories: new(true), + RestrictedToWorkflows: new(false), SelectedWorkflows: []string{}, - NetworkConfigurationID: Ptr("EC486D5D793175D7E3B29C27318D5C1AAE49A7833FC85F2E82C3D2C54AC7D3BA"), + NetworkConfigurationID: new("EC486D5D793175D7E3B29C27318D5C1AAE49A7833FC85F2E82C3D2C54AC7D3BA"), } group, _, err := client.Actions.CreateOrganizationRunnerGroup(ctx, "o", req) if err != nil { @@ -199,17 +199,17 @@ func TestActionsService_CreateOrganizationRunnerGroup(t *testing.T) { } want := &RunnerGroup{ - ID: Ptr(int64(2)), - Name: Ptr("octo-runner-group"), - Visibility: Ptr("selected"), - Default: Ptr(false), - SelectedRepositoriesURL: Ptr("https://api.github.com/orgs/octo-org/actions/runner_groups/2/repositories"), - RunnersURL: Ptr("https://api.github.com/orgs/octo-org/actions/runner_groups/2/runners"), - HostedRunnersURL: Ptr("https://api.github.com/orgs/octo-org/actions/runner_groups/2/hosted-runners"), - NetworkConfigurationID: Ptr("EC486D5D793175D7E3B29C27318D5C1AAE49A7833FC85F2E82C3D2C54AC7D3BA"), - Inherited: Ptr(false), - AllowsPublicRepositories: Ptr(true), - RestrictedToWorkflows: Ptr(false), + ID: new(int64(2)), + Name: new("octo-runner-group"), + Visibility: new("selected"), + Default: new(false), + SelectedRepositoriesURL: new("https://api.github.com/orgs/octo-org/actions/runner_groups/2/repositories"), + RunnersURL: new("https://api.github.com/orgs/octo-org/actions/runner_groups/2/runners"), + HostedRunnersURL: new("https://api.github.com/orgs/octo-org/actions/runner_groups/2/hosted-runners"), + NetworkConfigurationID: new("EC486D5D793175D7E3B29C27318D5C1AAE49A7833FC85F2E82C3D2C54AC7D3BA"), + Inherited: new(false), + AllowsPublicRepositories: new(true), + RestrictedToWorkflows: new(false), SelectedWorkflows: []string{}, } @@ -243,12 +243,12 @@ func TestActionsService_UpdateOrganizationRunnerGroup(t *testing.T) { ctx := t.Context() req := UpdateRunnerGroupRequest{ - Name: Ptr("octo-runner-group"), - Visibility: Ptr("selected"), - AllowsPublicRepositories: Ptr(true), - RestrictedToWorkflows: Ptr(false), + Name: new("octo-runner-group"), + Visibility: new("selected"), + AllowsPublicRepositories: new(true), + RestrictedToWorkflows: new(false), SelectedWorkflows: []string{}, - NetworkConfigurationID: Ptr("EC486D5D793175D7E3B29C27318D5C1AAE49A7833FC85F2E82C3D2C54AC7D3BA"), + NetworkConfigurationID: new("EC486D5D793175D7E3B29C27318D5C1AAE49A7833FC85F2E82C3D2C54AC7D3BA"), } group, _, err := client.Actions.UpdateOrganizationRunnerGroup(ctx, "o", 2, req) if err != nil { @@ -256,17 +256,17 @@ func TestActionsService_UpdateOrganizationRunnerGroup(t *testing.T) { } want := &RunnerGroup{ - ID: Ptr(int64(2)), - Name: Ptr("octo-runner-group"), - Visibility: Ptr("selected"), - Default: Ptr(false), - SelectedRepositoriesURL: Ptr("https://api.github.com/orgs/octo-org/actions/runner_groups/2/repositories"), - RunnersURL: Ptr("https://api.github.com/orgs/octo-org/actions/runner_groups/2/runners"), - HostedRunnersURL: Ptr("https://api.github.com/orgs/octo-org/actions/runner_groups/2/hosted-runners"), - NetworkConfigurationID: Ptr("EC486D5D793175D7E3B29C27318D5C1AAE49A7833FC85F2E82C3D2C54AC7D3BA"), - Inherited: Ptr(false), - AllowsPublicRepositories: Ptr(true), - RestrictedToWorkflows: Ptr(false), + ID: new(int64(2)), + Name: new("octo-runner-group"), + Visibility: new("selected"), + Default: new(false), + SelectedRepositoriesURL: new("https://api.github.com/orgs/octo-org/actions/runner_groups/2/repositories"), + RunnersURL: new("https://api.github.com/orgs/octo-org/actions/runner_groups/2/runners"), + HostedRunnersURL: new("https://api.github.com/orgs/octo-org/actions/runner_groups/2/hosted-runners"), + NetworkConfigurationID: new("EC486D5D793175D7E3B29C27318D5C1AAE49A7833FC85F2E82C3D2C54AC7D3BA"), + Inherited: new(false), + AllowsPublicRepositories: new(true), + RestrictedToWorkflows: new(false), SelectedWorkflows: []string{}, } @@ -307,9 +307,9 @@ func TestActionsService_ListRepositoryAccessRunnerGroup(t *testing.T) { } want := &ListRepositories{ - TotalCount: Ptr(1), + TotalCount: new(1), Repositories: []*Repository{ - {ID: Ptr(int64(43)), NodeID: Ptr("MDEwOlJlcG9zaXRvcnkxMjk2MjY5"), Name: Ptr("Hello-World"), FullName: Ptr("octocat/Hello-World")}, + {ID: new(int64(43)), NodeID: new("MDEwOlJlcG9zaXRvcnkxMjk2MjY5"), Name: new("Hello-World"), FullName: new("octocat/Hello-World")}, }, } if !cmp.Equal(groups, want) { @@ -486,13 +486,13 @@ func TestActionsService_ListRunnerGroupHostedRunners(t *testing.T) { TotalCount: 2, Runners: []*HostedRunner{ { - ID: Ptr(int64(5)), - Name: Ptr("My hosted ubuntu runner"), - RunnerGroupID: Ptr(int64(2)), - Platform: Ptr("linux-x64"), + ID: new(int64(5)), + Name: new("My hosted ubuntu runner"), + RunnerGroupID: new(int64(2)), + Platform: new("linux-x64"), ImageDetails: &HostedRunnerImageDetail{ - ID: Ptr("ubuntu-20.04"), - SizeGB: Ptr(int64(86)), + ID: new("ubuntu-20.04"), + SizeGB: new(int64(86)), }, MachineSizeDetails: &HostedRunnerMachineSpec{ ID: "4-core", @@ -500,9 +500,9 @@ func TestActionsService_ListRunnerGroupHostedRunners(t *testing.T) { MemoryGB: 16, StorageGB: 150, }, - Status: Ptr("Ready"), - MaximumRunners: Ptr(int64(10)), - PublicIPEnabled: Ptr(true), + Status: new("Ready"), + MaximumRunners: new(int64(10)), + PublicIPEnabled: new(true), PublicIPs: []*HostedRunnerPublicIP{ { Enabled: true, @@ -513,13 +513,13 @@ func TestActionsService_ListRunnerGroupHostedRunners(t *testing.T) { LastActiveOn: &referenceTimestamp, }, { - ID: Ptr(int64(7)), - Name: Ptr("My hosted Windows runner"), - RunnerGroupID: Ptr(int64(2)), - Platform: Ptr("win-x64"), + ID: new(int64(7)), + Name: new("My hosted Windows runner"), + RunnerGroupID: new(int64(2)), + Platform: new("win-x64"), ImageDetails: &HostedRunnerImageDetail{ - ID: Ptr("windows-latest"), - SizeGB: Ptr(int64(256)), + ID: new("windows-latest"), + SizeGB: new(int64(256)), }, MachineSizeDetails: &HostedRunnerMachineSpec{ ID: "8-core", @@ -527,9 +527,9 @@ func TestActionsService_ListRunnerGroupHostedRunners(t *testing.T) { MemoryGB: 32, StorageGB: 300, }, - Status: Ptr("Ready"), - MaximumRunners: Ptr(int64(20)), - PublicIPEnabled: Ptr(false), + Status: new("Ready"), + MaximumRunners: new(int64(20)), + PublicIPEnabled: new(false), PublicIPs: []*HostedRunnerPublicIP{}, LastActiveOn: &referenceTimestamp, }, @@ -574,8 +574,8 @@ func TestActionsService_ListRunnerGroupRunners(t *testing.T) { want := &Runners{ TotalCount: 2, Runners: []*Runner{ - {ID: Ptr(int64(23)), Name: Ptr("MBP"), OS: Ptr("macos"), Status: Ptr("online")}, - {ID: Ptr(int64(24)), Name: Ptr("iMac"), OS: Ptr("macos"), Status: Ptr("offline")}, + {ID: new(int64(23)), Name: new("MBP"), OS: new("macos"), Status: new("online")}, + {ID: new(int64(24)), Name: new("iMac"), OS: new("macos"), Status: new("offline")}, }, } if !cmp.Equal(runners, want) { diff --git a/github/actions_runners_test.go b/github/actions_runners_test.go index c29bab5c096..861ac612c3c 100644 --- a/github/actions_runners_test.go +++ b/github/actions_runners_test.go @@ -29,11 +29,11 @@ func TestActionsService_ListRunnerApplicationDownloads(t *testing.T) { } want := []*RunnerApplicationDownload{ - {OS: Ptr("osx"), Architecture: Ptr("x64"), DownloadURL: Ptr("https://github.com/actions/runner/releases/download/v2.164.0/actions-runner-osx-x64-2.164.0.tar.gz"), Filename: Ptr("actions-runner-osx-x64-2.164.0.tar.gz")}, - {OS: Ptr("linux"), Architecture: Ptr("x64"), DownloadURL: Ptr("https://github.com/actions/runner/releases/download/v2.164.0/actions-runner-linux-x64-2.164.0.tar.gz"), Filename: Ptr("actions-runner-linux-x64-2.164.0.tar.gz")}, - {OS: Ptr("linux"), Architecture: Ptr("arm"), DownloadURL: Ptr("https://github.com/actions/runner/releases/download/v2.164.0/actions-runner-linux-arm-2.164.0.tar.gz"), Filename: Ptr("actions-runner-linux-arm-2.164.0.tar.gz")}, - {OS: Ptr("win"), Architecture: Ptr("x64"), DownloadURL: Ptr("https://github.com/actions/runner/releases/download/v2.164.0/actions-runner-win-x64-2.164.0.zip"), Filename: Ptr("actions-runner-win-x64-2.164.0.zip")}, - {OS: Ptr("linux"), Architecture: Ptr("arm64"), DownloadURL: Ptr("https://github.com/actions/runner/releases/download/v2.164.0/actions-runner-linux-arm64-2.164.0.tar.gz"), Filename: Ptr("actions-runner-linux-arm64-2.164.0.tar.gz")}, + {OS: new("osx"), Architecture: new("x64"), DownloadURL: new("https://github.com/actions/runner/releases/download/v2.164.0/actions-runner-osx-x64-2.164.0.tar.gz"), Filename: new("actions-runner-osx-x64-2.164.0.tar.gz")}, + {OS: new("linux"), Architecture: new("x64"), DownloadURL: new("https://github.com/actions/runner/releases/download/v2.164.0/actions-runner-linux-x64-2.164.0.tar.gz"), Filename: new("actions-runner-linux-x64-2.164.0.tar.gz")}, + {OS: new("linux"), Architecture: new("arm"), DownloadURL: new("https://github.com/actions/runner/releases/download/v2.164.0/actions-runner-linux-arm-2.164.0.tar.gz"), Filename: new("actions-runner-linux-arm-2.164.0.tar.gz")}, + {OS: new("win"), Architecture: new("x64"), DownloadURL: new("https://github.com/actions/runner/releases/download/v2.164.0/actions-runner-win-x64-2.164.0.zip"), Filename: new("actions-runner-win-x64-2.164.0.zip")}, + {OS: new("linux"), Architecture: new("arm64"), DownloadURL: new("https://github.com/actions/runner/releases/download/v2.164.0/actions-runner-linux-arm64-2.164.0.tar.gz"), Filename: new("actions-runner-linux-arm64-2.164.0.tar.gz")}, } if !cmp.Equal(downloads, want) { t.Errorf("Actions.ListRunnerApplicationDownloads returned %+v, want %+v", downloads, want) @@ -72,7 +72,7 @@ func TestActionsService_CreateOrgJITConfig(t *testing.T) { t.Errorf("Actions.CreateOrgJITConfig returned error: %v", err) } - want := &JITRunnerConfig{EncodedJITConfig: Ptr("foo")} + want := &JITRunnerConfig{EncodedJITConfig: new("foo")} if !cmp.Equal(jitConfig, want) { t.Errorf("Actions.CreateOrgJITConfig returned %+v, want %+v", jitConfig, want) } @@ -110,7 +110,7 @@ func TestActionsService_CreateRepoJITConfig(t *testing.T) { t.Errorf("Actions.CreateRepoJITConfig returned error: %v", err) } - want := &JITRunnerConfig{EncodedJITConfig: Ptr("foo")} + want := &JITRunnerConfig{EncodedJITConfig: new("foo")} if !cmp.Equal(jitConfig, want) { t.Errorf("Actions.CreateRepoJITConfig returned %+v, want %+v", jitConfig, want) } @@ -146,7 +146,7 @@ func TestActionsService_CreateRegistrationToken(t *testing.T) { } want := &RegistrationToken{ - Token: Ptr("LLBF3JGZDX3P5PMEXLND6TS6FCWO6"), + Token: new("LLBF3JGZDX3P5PMEXLND6TS6FCWO6"), ExpiresAt: &referenceTimestamp, } if !cmp.Equal(token, want) { @@ -179,7 +179,7 @@ func TestActionsService_ListRunners(t *testing.T) { }) opts := &ListRunnersOptions{ - Name: Ptr("MBP"), + Name: new("MBP"), ListOptions: ListOptions{Page: 2, PerPage: 2}, } ctx := t.Context() @@ -191,7 +191,7 @@ func TestActionsService_ListRunners(t *testing.T) { want := &Runners{ TotalCount: 1, Runners: []*Runner{ - {ID: Ptr(int64(23)), Name: Ptr("MBP"), OS: Ptr("macos"), Status: Ptr("online")}, + {ID: new(int64(23)), Name: new("MBP"), OS: new("macos"), Status: new("online")}, }, } if !cmp.Equal(runners, want) { @@ -229,10 +229,10 @@ func TestActionsService_GetRunner(t *testing.T) { } want := &Runner{ - ID: Ptr(int64(23)), - Name: Ptr("MBP"), - OS: Ptr("macos"), - Status: Ptr("online"), + ID: new(int64(23)), + Name: new("MBP"), + OS: new("macos"), + Status: new("online"), } if !cmp.Equal(runner, want) { t.Errorf("Actions.GetRunner returned %+v, want %+v", runner, want) @@ -268,7 +268,7 @@ func TestActionsService_CreateRemoveToken(t *testing.T) { t.Errorf("Actions.CreateRemoveToken returned error: %v", err) } - want := &RemoveToken{Token: Ptr("AABF3JGZDX3P5PMEXLND6TS6FCWO6"), ExpiresAt: &referenceTimestamp} + want := &RemoveToken{Token: new("AABF3JGZDX3P5PMEXLND6TS6FCWO6"), ExpiresAt: &referenceTimestamp} if !cmp.Equal(token, want) { t.Errorf("Actions.CreateRemoveToken returned %+v, want %+v", token, want) } @@ -329,11 +329,11 @@ func TestActionsService_ListOrganizationRunnerApplicationDownloads(t *testing.T) } want := []*RunnerApplicationDownload{ - {OS: Ptr("osx"), Architecture: Ptr("x64"), DownloadURL: Ptr("https://github.com/actions/runner/releases/download/v2.164.0/actions-runner-osx-x64-2.164.0.tar.gz"), Filename: Ptr("actions-runner-osx-x64-2.164.0.tar.gz")}, - {OS: Ptr("linux"), Architecture: Ptr("x64"), DownloadURL: Ptr("https://github.com/actions/runner/releases/download/v2.164.0/actions-runner-linux-x64-2.164.0.tar.gz"), Filename: Ptr("actions-runner-linux-x64-2.164.0.tar.gz")}, - {OS: Ptr("linux"), Architecture: Ptr("arm"), DownloadURL: Ptr("https://github.com/actions/runner/releases/download/v2.164.0/actions-runner-linux-arm-2.164.0.tar.gz"), Filename: Ptr("actions-runner-linux-arm-2.164.0.tar.gz")}, - {OS: Ptr("win"), Architecture: Ptr("x64"), DownloadURL: Ptr("https://github.com/actions/runner/releases/download/v2.164.0/actions-runner-win-x64-2.164.0.zip"), Filename: Ptr("actions-runner-win-x64-2.164.0.zip")}, - {OS: Ptr("linux"), Architecture: Ptr("arm64"), DownloadURL: Ptr("https://github.com/actions/runner/releases/download/v2.164.0/actions-runner-linux-arm64-2.164.0.tar.gz"), Filename: Ptr("actions-runner-linux-arm64-2.164.0.tar.gz")}, + {OS: new("osx"), Architecture: new("x64"), DownloadURL: new("https://github.com/actions/runner/releases/download/v2.164.0/actions-runner-osx-x64-2.164.0.tar.gz"), Filename: new("actions-runner-osx-x64-2.164.0.tar.gz")}, + {OS: new("linux"), Architecture: new("x64"), DownloadURL: new("https://github.com/actions/runner/releases/download/v2.164.0/actions-runner-linux-x64-2.164.0.tar.gz"), Filename: new("actions-runner-linux-x64-2.164.0.tar.gz")}, + {OS: new("linux"), Architecture: new("arm"), DownloadURL: new("https://github.com/actions/runner/releases/download/v2.164.0/actions-runner-linux-arm-2.164.0.tar.gz"), Filename: new("actions-runner-linux-arm-2.164.0.tar.gz")}, + {OS: new("win"), Architecture: new("x64"), DownloadURL: new("https://github.com/actions/runner/releases/download/v2.164.0/actions-runner-win-x64-2.164.0.zip"), Filename: new("actions-runner-win-x64-2.164.0.zip")}, + {OS: new("linux"), Architecture: new("arm64"), DownloadURL: new("https://github.com/actions/runner/releases/download/v2.164.0/actions-runner-linux-arm64-2.164.0.tar.gz"), Filename: new("actions-runner-linux-arm64-2.164.0.tar.gz")}, } if !cmp.Equal(downloads, want) { t.Errorf("Actions.ListOrganizationRunnerApplicationDownloads returned %+v, want %+v", downloads, want) @@ -370,7 +370,7 @@ func TestActionsService_CreateOrganizationRegistrationToken(t *testing.T) { } want := &RegistrationToken{ - Token: Ptr("LLBF3JGZDX3P5PMEXLND6TS6FCWO6"), + Token: new("LLBF3JGZDX3P5PMEXLND6TS6FCWO6"), ExpiresAt: &referenceTimestamp, } if !cmp.Equal(token, want) { @@ -414,8 +414,8 @@ func TestActionsService_ListOrganizationRunners(t *testing.T) { want := &Runners{ TotalCount: 2, Runners: []*Runner{ - {ID: Ptr(int64(23)), Name: Ptr("MBP"), OS: Ptr("macos"), Status: Ptr("online")}, - {ID: Ptr(int64(24)), Name: Ptr("iMac"), OS: Ptr("macos"), Status: Ptr("offline")}, + {ID: new(int64(23)), Name: new("MBP"), OS: new("macos"), Status: new("online")}, + {ID: new(int64(24)), Name: new("iMac"), OS: new("macos"), Status: new("offline")}, }, } if !cmp.Equal(runners, want) { @@ -453,10 +453,10 @@ func TestActionsService_GetOrganizationRunner(t *testing.T) { } want := &Runner{ - ID: Ptr(int64(23)), - Name: Ptr("MBP"), - OS: Ptr("macos"), - Status: Ptr("online"), + ID: new(int64(23)), + Name: new("MBP"), + OS: new("macos"), + Status: new("online"), } if !cmp.Equal(runner, want) { t.Errorf("Actions.GetOrganizationRunner returned %+v, want %+v", runner, want) @@ -492,7 +492,7 @@ func TestActionsService_CreateOrganizationRemoveToken(t *testing.T) { t.Errorf("Actions.CreateOrganizationRemoveToken returned error: %v", err) } - want := &RemoveToken{Token: Ptr("AABF3JGZDX3P5PMEXLND6TS6FCWO6"), ExpiresAt: &referenceTimestamp} + want := &RemoveToken{Token: new("AABF3JGZDX3P5PMEXLND6TS6FCWO6"), ExpiresAt: &referenceTimestamp} if !cmp.Equal(token, want) { t.Errorf("Actions.CreateOrganizationRemoveToken returned %+v, want %+v", token, want) } diff --git a/github/actions_secrets.go b/github/actions_secrets.go index 2426a10d98c..e3d4de0b221 100644 --- a/github/actions_secrets.go +++ b/github/actions_secrets.go @@ -39,7 +39,7 @@ func (p *PublicKey) UnmarshalJSON(data []byte) error { case string: p.KeyID = &v case float64: - p.KeyID = Ptr(strconv.FormatFloat(v, 'f', -1, 64)) + p.KeyID = new(strconv.FormatFloat(v, 'f', -1, 64)) default: return fmt.Errorf("unable to unmarshal %T as a string", v) } diff --git a/github/actions_secrets_test.go b/github/actions_secrets_test.go index e1e00c721b7..1b36d82c6a1 100644 --- a/github/actions_secrets_test.go +++ b/github/actions_secrets_test.go @@ -33,17 +33,17 @@ func TestPublicKey_UnmarshalJSON(t *testing.T) { }, "Numeric KeyID": { data: []byte(`{"key_id":1234,"key":"2Sg8iYjAxxmI2LvUXpJjkYrMxURPc8r+dB7TJyvv1234"}`), - wantPublicKey: PublicKey{KeyID: Ptr("1234"), Key: Ptr("2Sg8iYjAxxmI2LvUXpJjkYrMxURPc8r+dB7TJyvv1234")}, + wantPublicKey: PublicKey{KeyID: new("1234"), Key: new("2Sg8iYjAxxmI2LvUXpJjkYrMxURPc8r+dB7TJyvv1234")}, wantErr: false, }, "String KeyID": { data: []byte(`{"key_id":"1234","key":"2Sg8iYjAxxmI2LvUXpJjkYrMxURPc8r+dB7TJyvv1234"}`), - wantPublicKey: PublicKey{KeyID: Ptr("1234"), Key: Ptr("2Sg8iYjAxxmI2LvUXpJjkYrMxURPc8r+dB7TJyvv1234")}, + wantPublicKey: PublicKey{KeyID: new("1234"), Key: new("2Sg8iYjAxxmI2LvUXpJjkYrMxURPc8r+dB7TJyvv1234")}, wantErr: false, }, "Invalid KeyID": { data: []byte(`{"key_id":["1234"],"key":"2Sg8iYjAxxmI2LvUXpJjkYrMxURPc8r+dB7TJyvv1234"}`), - wantPublicKey: PublicKey{KeyID: nil, Key: Ptr("2Sg8iYjAxxmI2LvUXpJjkYrMxURPc8r+dB7TJyvv1234")}, + wantPublicKey: PublicKey{KeyID: nil, Key: new("2Sg8iYjAxxmI2LvUXpJjkYrMxURPc8r+dB7TJyvv1234")}, wantErr: true, }, "Invalid Key": { @@ -63,12 +63,12 @@ func TestPublicKey_UnmarshalJSON(t *testing.T) { }, "Missing Key": { data: []byte(`{"key_id":"1234"}`), - wantPublicKey: PublicKey{KeyID: Ptr("1234")}, + wantPublicKey: PublicKey{KeyID: new("1234")}, wantErr: false, }, "Missing KeyID": { data: []byte(`{"key":"2Sg8iYjAxxmI2LvUXpJjkYrMxURPc8r+dB7TJyvv1234"}`), - wantPublicKey: PublicKey{Key: Ptr("2Sg8iYjAxxmI2LvUXpJjkYrMxURPc8r+dB7TJyvv1234")}, + wantPublicKey: PublicKey{Key: new("2Sg8iYjAxxmI2LvUXpJjkYrMxURPc8r+dB7TJyvv1234")}, wantErr: false, }, } @@ -106,7 +106,7 @@ func TestActionsService_GetRepoPublicKey(t *testing.T) { t.Errorf("Actions.GetRepoPublicKey returned error: %v", err) } - want := &PublicKey{KeyID: Ptr("1234"), Key: Ptr("2Sg8iYjAxxmI2LvUXpJjkYrMxURPc8r+dB7TJyvv1234")} + want := &PublicKey{KeyID: new("1234"), Key: new("2Sg8iYjAxxmI2LvUXpJjkYrMxURPc8r+dB7TJyvv1234")} if !cmp.Equal(key, want) { t.Errorf("Actions.GetRepoPublicKey returned %+v, want %+v", key, want) } @@ -141,7 +141,7 @@ func TestActionsService_GetRepoPublicKeyNumeric(t *testing.T) { t.Errorf("Actions.GetRepoPublicKey returned error: %v", err) } - want := &PublicKey{KeyID: Ptr("1234"), Key: Ptr("2Sg8iYjAxxmI2LvUXpJjkYrMxURPc8r+dB7TJyvv1234")} + want := &PublicKey{KeyID: new("1234"), Key: new("2Sg8iYjAxxmI2LvUXpJjkYrMxURPc8r+dB7TJyvv1234")} if !cmp.Equal(key, want) { t.Errorf("Actions.GetRepoPublicKey returned %+v, want %+v", key, want) } @@ -363,7 +363,7 @@ func TestActionsService_GetOrgPublicKey(t *testing.T) { t.Errorf("Actions.GetOrgPublicKey returned error: %v", err) } - want := &PublicKey{KeyID: Ptr("012345678"), Key: Ptr("2Sg8iYjAxxmI2LvUXpJjkYrMxURPc8r+dB7TJyvv1234")} + want := &PublicKey{KeyID: new("012345678"), Key: new("2Sg8iYjAxxmI2LvUXpJjkYrMxURPc8r+dB7TJyvv1234")} if !cmp.Equal(key, want) { t.Errorf("Actions.GetOrgPublicKey returned %+v, want %+v", key, want) } @@ -526,9 +526,9 @@ func TestActionsService_ListSelectedReposForOrgSecret(t *testing.T) { } want := &SelectedReposList{ - TotalCount: Ptr(1), + TotalCount: new(1), Repositories: []*Repository{ - {ID: Ptr(int64(1))}, + {ID: new(int64(1))}, }, } if !cmp.Equal(repos, want) { @@ -683,7 +683,7 @@ func TestActionsService_GetEnvPublicKey(t *testing.T) { t.Errorf("Actions.GetEnvPublicKey returned error: %v", err) } - want := &PublicKey{KeyID: Ptr("1234"), Key: Ptr("2Sg8iYjAxxmI2LvUXpJjkYrMxURPc8r+dB7TJyvv1234")} + want := &PublicKey{KeyID: new("1234"), Key: new("2Sg8iYjAxxmI2LvUXpJjkYrMxURPc8r+dB7TJyvv1234")} if !cmp.Equal(key, want) { t.Errorf("Actions.GetEnvPublicKey returned %+v, want %+v", key, want) } @@ -718,7 +718,7 @@ func TestActionsService_GetEnvPublicKeyNumeric(t *testing.T) { t.Errorf("Actions.GetEnvPublicKey returned error: %v", err) } - want := &PublicKey{KeyID: Ptr("1234"), Key: Ptr("2Sg8iYjAxxmI2LvUXpJjkYrMxURPc8r+dB7TJyvv1234")} + want := &PublicKey{KeyID: new("1234"), Key: new("2Sg8iYjAxxmI2LvUXpJjkYrMxURPc8r+dB7TJyvv1234")} if !cmp.Equal(key, want) { t.Errorf("Actions.GetEnvPublicKey returned %+v, want %+v", key, want) } diff --git a/github/actions_variables_test.go b/github/actions_variables_test.go index d251677e4e1..40f7b1b18d3 100644 --- a/github/actions_variables_test.go +++ b/github/actions_variables_test.go @@ -179,7 +179,7 @@ func TestActionsService_UpdateRepoVariable(t *testing.T) { name := "NAME" input := ActionsUpdateVariableRequest{ Name: &name, - Value: Ptr("VALUE"), + Value: new("VALUE"), } mux.HandleFunc("/repos/o/r/actions/variables/NAME", func(w http.ResponseWriter, r *http.Request) { @@ -251,9 +251,9 @@ func TestActionsService_ListOrgVariables(t *testing.T) { want := &ActionsVariables{ TotalCount: 3, Variables: []*ActionsVariable{ - {Name: "A", Value: "AA", CreatedAt: refTimestamp(1136178000), UpdatedAt: refTimestamp(1136178001), Visibility: Ptr("private")}, - {Name: "B", Value: "BB", CreatedAt: refTimestamp(1136178002), UpdatedAt: refTimestamp(1136178003), Visibility: Ptr("all")}, - {Name: "C", Value: "CC", CreatedAt: refTimestamp(1136178004), UpdatedAt: refTimestamp(1136178005), Visibility: Ptr("selected"), SelectedRepositoriesURL: Ptr("https://api.github.com/orgs/octo-org/actions/variables/VAR/repositories")}, + {Name: "A", Value: "AA", CreatedAt: refTimestamp(1136178000), UpdatedAt: refTimestamp(1136178001), Visibility: new("private")}, + {Name: "B", Value: "BB", CreatedAt: refTimestamp(1136178002), UpdatedAt: refTimestamp(1136178003), Visibility: new("all")}, + {Name: "C", Value: "CC", CreatedAt: refTimestamp(1136178004), UpdatedAt: refTimestamp(1136178005), Visibility: new("selected"), SelectedRepositoriesURL: new("https://api.github.com/orgs/octo-org/actions/variables/VAR/repositories")}, }, } if !cmp.Equal(variables, want) { @@ -295,8 +295,8 @@ func TestActionsService_GetOrgVariable(t *testing.T) { Value: "VALUE", CreatedAt: refTimestamp(1136178000), UpdatedAt: refTimestamp(1136178001), - Visibility: Ptr("selected"), - SelectedRepositoriesURL: Ptr("https://api.github.com/orgs/octo-org/actions/variables/VAR/repositories"), + Visibility: new("selected"), + SelectedRepositoriesURL: new("https://api.github.com/orgs/octo-org/actions/variables/VAR/repositories"), } if !cmp.Equal(variable, want) { t.Errorf("Actions.GetOrgVariable returned %+v, want %+v", variable, want) @@ -359,8 +359,8 @@ func TestActionsService_UpdateOrgVariable(t *testing.T) { name := "NAME" input := ActionsUpdateOrgVariableRequest{ Name: &name, - Value: Ptr("VALUE"), - Visibility: Ptr("selected"), + Value: new("VALUE"), + Visibility: new("selected"), SelectedRepositoryIDs: []int64{1296269, 1269280}, } @@ -405,9 +405,9 @@ func TestActionsService_ListSelectedReposForOrgVariable(t *testing.T) { } want := &SelectedReposList{ - TotalCount: Ptr(1), + TotalCount: new(1), Repositories: []*Repository{ - {ID: Ptr(int64(1))}, + {ID: new(int64(1))}, }, } if !cmp.Equal(repos, want) { @@ -470,7 +470,7 @@ func TestActionsService_AddSelectedRepoToOrgVariable(t *testing.T) { testMethod(t, r, "PUT") }) - repo := &Repository{ID: Ptr(int64(1234))} + repo := &Repository{ID: new(int64(1234))} ctx := t.Context() _, err := client.Actions.AddSelectedRepoToOrgVariable(ctx, "o", "NAME", repo) if err != nil { @@ -504,7 +504,7 @@ func TestActionsService_RemoveSelectedRepoFromOrgVariable(t *testing.T) { testMethod(t, r, "DELETE") }) - repo := &Repository{ID: Ptr(int64(1234))} + repo := &Repository{ID: new(int64(1234))} ctx := t.Context() _, err := client.Actions.RemoveSelectedRepoFromOrgVariable(ctx, "o", "NAME", repo) if err != nil { @@ -678,7 +678,7 @@ func TestActionsService_UpdateEnvVariable(t *testing.T) { name := "NAME" input := ActionsUpdateVariableRequest{ Name: &name, - Value: Ptr("VAR"), + Value: new("VAR"), } mux.HandleFunc("/repos/o/r/environments/e/variables/NAME", func(w http.ResponseWriter, r *http.Request) { diff --git a/github/actions_workflow_jobs_test.go b/github/actions_workflow_jobs_test.go index 519fbd4ff55..b74515fed54 100644 --- a/github/actions_workflow_jobs_test.go +++ b/github/actions_workflow_jobs_test.go @@ -34,10 +34,10 @@ func TestActionsService_ListWorkflowJobs(t *testing.T) { } want := &Jobs{ - TotalCount: Ptr(4), + TotalCount: new(4), Jobs: []*WorkflowJob{ - {ID: Ptr(int64(399444496)), RunID: Ptr(int64(29679449)), StartedAt: refTimestamp(1136178000), CompletedAt: refTimestamp(1136178001)}, - {ID: Ptr(int64(399444497)), RunID: Ptr(int64(29679449)), StartedAt: refTimestamp(1136178002), CompletedAt: refTimestamp(1136178003)}, + {ID: new(int64(399444496)), RunID: new(int64(29679449)), StartedAt: refTimestamp(1136178000), CompletedAt: refTimestamp(1136178001)}, + {ID: new(int64(399444497)), RunID: new(int64(29679449)), StartedAt: refTimestamp(1136178002), CompletedAt: refTimestamp(1136178003)}, }, } if !cmp.Equal(jobs, want) { @@ -77,10 +77,10 @@ func TestActionsService_ListWorkflowJobs_Filter(t *testing.T) { } want := &Jobs{ - TotalCount: Ptr(4), + TotalCount: new(4), Jobs: []*WorkflowJob{ - {ID: Ptr(int64(399444496)), RunID: Ptr(int64(29679449)), StartedAt: refTimestamp(1136178000), CompletedAt: refTimestamp(1136178001)}, - {ID: Ptr(int64(399444497)), RunID: Ptr(int64(29679449)), StartedAt: refTimestamp(1136178002), CompletedAt: refTimestamp(1136178003)}, + {ID: new(int64(399444496)), RunID: new(int64(29679449)), StartedAt: refTimestamp(1136178000), CompletedAt: refTimestamp(1136178001)}, + {ID: new(int64(399444497)), RunID: new(int64(29679449)), StartedAt: refTimestamp(1136178002), CompletedAt: refTimestamp(1136178003)}, }, } if !cmp.Equal(jobs, want) { @@ -105,21 +105,21 @@ func TestActionsService_ListWorkflowJobsAttempt(t *testing.T) { } want := &Jobs{ - TotalCount: Ptr(4), + TotalCount: new(4), Jobs: []*WorkflowJob{ { - ID: Ptr(int64(399444496)), - RunID: Ptr(int64(29679449)), + ID: new(int64(399444496)), + RunID: new(int64(29679449)), StartedAt: refTimestamp(1136178000), CompletedAt: refTimestamp(1136178001), - RunAttempt: Ptr(int64(2)), + RunAttempt: new(int64(2)), }, { - ID: Ptr(int64(399444497)), - RunID: Ptr(int64(29679449)), + ID: new(int64(399444497)), + RunID: new(int64(29679449)), StartedAt: refTimestamp(1136178002), CompletedAt: refTimestamp(1136178003), - RunAttempt: Ptr(int64(2)), + RunAttempt: new(int64(2)), }, }, } @@ -158,7 +158,7 @@ func TestActionsService_GetWorkflowJobByID(t *testing.T) { } want := &WorkflowJob{ - ID: Ptr(int64(399444496)), + ID: new(int64(399444496)), StartedAt: refTimestamp(1136178000), CompletedAt: refTimestamp(1136178001), } diff --git a/github/actions_workflow_runs_test.go b/github/actions_workflow_runs_test.go index bd53983e422..6a513e5da79 100644 --- a/github/actions_workflow_runs_test.go +++ b/github/actions_workflow_runs_test.go @@ -34,10 +34,10 @@ func TestActionsService_ListWorkflowRunsByID(t *testing.T) { } want := &WorkflowRuns{ - TotalCount: Ptr(4), + TotalCount: new(4), WorkflowRuns: []*WorkflowRun{ - {ID: Ptr(int64(399444496)), RunNumber: Ptr(296), CreatedAt: refTimestamp(1136178000), UpdatedAt: refTimestamp(1136178001)}, - {ID: Ptr(int64(399444497)), RunNumber: Ptr(296), CreatedAt: refTimestamp(1136178002), UpdatedAt: refTimestamp(1136178003)}, + {ID: new(int64(399444496)), RunNumber: new(296), CreatedAt: refTimestamp(1136178000), UpdatedAt: refTimestamp(1136178001)}, + {ID: new(int64(399444497)), RunNumber: new(296), CreatedAt: refTimestamp(1136178002), UpdatedAt: refTimestamp(1136178003)}, }, } if !cmp.Equal(runs, want) { @@ -77,10 +77,10 @@ func TestActionsService_ListWorkflowRunsFileName(t *testing.T) { } want := &WorkflowRuns{ - TotalCount: Ptr(4), + TotalCount: new(4), WorkflowRuns: []*WorkflowRun{ - {ID: Ptr(int64(399444496)), RunNumber: Ptr(296), CreatedAt: refTimestamp(1136178000), UpdatedAt: refTimestamp(1136178001)}, - {ID: Ptr(int64(399444497)), RunNumber: Ptr(296), CreatedAt: refTimestamp(1136178002), UpdatedAt: refTimestamp(1136178003)}, + {ID: new(int64(399444496)), RunNumber: new(296), CreatedAt: refTimestamp(1136178000), UpdatedAt: refTimestamp(1136178001)}, + {ID: new(int64(399444497)), RunNumber: new(296), CreatedAt: refTimestamp(1136178002), UpdatedAt: refTimestamp(1136178003)}, }, } if !cmp.Equal(runs, want) { @@ -118,8 +118,8 @@ func TestActionsService_GetWorkflowRunByID(t *testing.T) { } want := &WorkflowRun{ - ID: Ptr(int64(399444496)), - RunNumber: Ptr(296), + ID: new(int64(399444496)), + RunNumber: new(296), CreatedAt: refTimestamp(1136178000), UpdatedAt: refTimestamp(1136178001), } @@ -153,7 +153,7 @@ func TestActionsService_GetWorkflowRunAttempt(t *testing.T) { fmt.Fprint(w, `{"id":399444496,"run_number":296,"run_attempt":3,"created_at":`+refTimeStr(1136178000)+`,"updated_at":`+refTimeStr(1136178001)+`}`) }) - opts := &WorkflowRunAttemptOptions{ExcludePullRequests: Ptr(true)} + opts := &WorkflowRunAttemptOptions{ExcludePullRequests: new(true)} ctx := t.Context() runs, _, err := client.Actions.GetWorkflowRunAttempt(ctx, "o", "r", 29679449, 3, opts) if err != nil { @@ -161,9 +161,9 @@ func TestActionsService_GetWorkflowRunAttempt(t *testing.T) { } want := &WorkflowRun{ - ID: Ptr(int64(399444496)), - RunNumber: Ptr(296), - RunAttempt: Ptr(3), + ID: new(int64(399444496)), + RunNumber: new(296), + RunAttempt: new(3), CreatedAt: refTimestamp(1136178000), UpdatedAt: refTimestamp(1136178001), } @@ -714,10 +714,10 @@ func TestActionsService_ListRepositoryWorkflowRuns(t *testing.T) { } expected := &WorkflowRuns{ - TotalCount: Ptr(2), + TotalCount: new(2), WorkflowRuns: []*WorkflowRun{ - {ID: Ptr(int64(298499444)), RunNumber: Ptr(301), CreatedAt: refTimestamp(1136178000), UpdatedAt: refTimestamp(1136178001)}, - {ID: Ptr(int64(298499445)), RunNumber: Ptr(302), CreatedAt: refTimestamp(1136178002), UpdatedAt: refTimestamp(1136178003)}, + {ID: new(int64(298499444)), RunNumber: new(301), CreatedAt: refTimestamp(1136178000), UpdatedAt: refTimestamp(1136178001)}, + {ID: new(int64(298499445)), RunNumber: new(302), CreatedAt: refTimestamp(1136178002), UpdatedAt: refTimestamp(1136178003)}, }, } @@ -844,35 +844,35 @@ func TestActionsService_GetWorkflowRunUsageByID(t *testing.T) { want := &WorkflowRunUsage{ Billable: &WorkflowRunBillMap{ "UBUNTU": &WorkflowRunBill{ - TotalMS: Ptr(int64(180000)), - Jobs: Ptr(1), + TotalMS: new(int64(180000)), + Jobs: new(1), JobRuns: []*WorkflowRunJobRun{ { - JobID: Ptr(1), - DurationMS: Ptr(int64(60000)), + JobID: new(1), + DurationMS: new(int64(60000)), }, }, }, "MACOS": &WorkflowRunBill{ - TotalMS: Ptr(int64(240000)), - Jobs: Ptr(2), + TotalMS: new(int64(240000)), + Jobs: new(2), JobRuns: []*WorkflowRunJobRun{ { - JobID: Ptr(2), - DurationMS: Ptr(int64(30000)), + JobID: new(2), + DurationMS: new(int64(30000)), }, { - JobID: Ptr(3), - DurationMS: Ptr(int64(10000)), + JobID: new(3), + DurationMS: new(int64(10000)), }, }, }, "WINDOWS": &WorkflowRunBill{ - TotalMS: Ptr(int64(300000)), - Jobs: Ptr(2), + TotalMS: new(int64(300000)), + Jobs: new(2), }, }, - RunDurationMS: Ptr(int64(500000)), + RunDurationMS: new(int64(500000)), } if !cmp.Equal(workflowRunUsage, want) { @@ -912,7 +912,7 @@ func TestActionsService_PendingDeployments(t *testing.T) { t.Errorf("Actions.PendingDeployments returned error: %v", err) } - want := []*Deployment{{ID: Ptr(int64(1))}, {ID: Ptr(int64(2))}} + want := []*Deployment{{ID: new(int64(1))}, {ID: new(int64(2))}} if !cmp.Equal(deployments, want) { t.Errorf("Actions.PendingDeployments returned %+v, want %+v", deployments, want) } @@ -991,40 +991,40 @@ func TestActionsService_GetPendingDeployments(t *testing.T) { want := []*PendingDeployment{ { Environment: &PendingDeploymentEnvironment{ - ID: Ptr(int64(1)), - NodeID: Ptr("nid"), - Name: Ptr("n"), - URL: Ptr("u"), - HTMLURL: Ptr("hu"), + ID: new(int64(1)), + NodeID: new("nid"), + Name: new("n"), + URL: new("u"), + HTMLURL: new("hu"), }, - WaitTimer: Ptr(int64(0)), + WaitTimer: new(int64(0)), WaitTimerStartedAt: refTimestamp(1136178000), - CurrentUserCanApprove: Ptr(false), + CurrentUserCanApprove: new(false), Reviewers: []*RequiredReviewer{}, }, { Environment: &PendingDeploymentEnvironment{ - ID: Ptr(int64(2)), - NodeID: Ptr("nid"), - Name: Ptr("n"), - URL: Ptr("u"), - HTMLURL: Ptr("hu"), + ID: new(int64(2)), + NodeID: new("nid"), + Name: new("n"), + URL: new("u"), + HTMLURL: new("hu"), }, - WaitTimer: Ptr(int64(13)), + WaitTimer: new(int64(13)), WaitTimerStartedAt: refTimestamp(1136178001), - CurrentUserCanApprove: Ptr(true), + CurrentUserCanApprove: new(true), Reviewers: []*RequiredReviewer{ { - Type: Ptr("User"), + Type: new("User"), Reviewer: &User{ - Login: Ptr("l"), + Login: new("l"), }, }, { - Type: Ptr("Team"), + Type: new("Team"), Reviewer: &Team{ - Name: Ptr("t"), - Slug: Ptr("s"), + Name: new("t"), + Slug: new("s"), }, }, }, diff --git a/github/actions_workflows_test.go b/github/actions_workflows_test.go index a1c9ca728b1..c708c4af455 100644 --- a/github/actions_workflows_test.go +++ b/github/actions_workflows_test.go @@ -31,10 +31,10 @@ func TestActionsService_ListWorkflows(t *testing.T) { } want := &Workflows{ - TotalCount: Ptr(4), + TotalCount: new(4), Workflows: []*Workflow{ - {ID: Ptr(int64(72844)), CreatedAt: refTimestamp(1136178000), UpdatedAt: refTimestamp(1136178001)}, - {ID: Ptr(int64(72845)), CreatedAt: refTimestamp(1136178002), UpdatedAt: refTimestamp(1136178003)}, + {ID: new(int64(72844)), CreatedAt: refTimestamp(1136178000), UpdatedAt: refTimestamp(1136178001)}, + {ID: new(int64(72845)), CreatedAt: refTimestamp(1136178002), UpdatedAt: refTimestamp(1136178003)}, }, } if !cmp.Equal(workflows, want) { @@ -72,7 +72,7 @@ func TestActionsService_GetWorkflowByID(t *testing.T) { } want := &Workflow{ - ID: Ptr(int64(72844)), + ID: new(int64(72844)), CreatedAt: refTimestamp(1136178000), UpdatedAt: refTimestamp(1136178001), } @@ -111,7 +111,7 @@ func TestActionsService_GetWorkflowByFileName(t *testing.T) { } want := &Workflow{ - ID: Ptr(int64(72844)), + ID: new(int64(72844)), CreatedAt: refTimestamp(1136178000), UpdatedAt: refTimestamp(1136178001), } @@ -152,13 +152,13 @@ func TestActionsService_GetWorkflowUsageByID(t *testing.T) { want := &WorkflowUsage{ Billable: &WorkflowBillMap{ "UBUNTU": &WorkflowBill{ - TotalMS: Ptr(int64(180000)), + TotalMS: new(int64(180000)), }, "MACOS": &WorkflowBill{ - TotalMS: Ptr(int64(240000)), + TotalMS: new(int64(240000)), }, "WINDOWS": &WorkflowBill{ - TotalMS: Ptr(int64(300000)), + TotalMS: new(int64(300000)), }, }, } @@ -199,13 +199,13 @@ func TestActionsService_GetWorkflowUsageByFileName(t *testing.T) { want := &WorkflowUsage{ Billable: &WorkflowBillMap{ "UBUNTU": &WorkflowBill{ - TotalMS: Ptr(int64(180000)), + TotalMS: new(int64(180000)), }, "MACOS": &WorkflowBill{ - TotalMS: Ptr(int64(240000)), + TotalMS: new(int64(240000)), }, "WINDOWS": &WorkflowBill{ - TotalMS: Ptr(int64(300000)), + TotalMS: new(int64(300000)), }, }, } @@ -234,7 +234,7 @@ func TestActionsService_CreateWorkflowDispatchEventByID(t *testing.T) { event := CreateWorkflowDispatchEventRequest{ Ref: "d4cfb6e7", - ReturnRunDetails: Ptr(true), + ReturnRunDetails: new(true), Inputs: map[string]any{ "key": "value", }, @@ -253,9 +253,9 @@ func TestActionsService_CreateWorkflowDispatchEventByID(t *testing.T) { } want := &WorkflowDispatchRunDetails{ - WorkflowRunID: Ptr(int64(1)), - RunURL: Ptr("https://api.github.com/repos/o/r/actions/runs/1"), - HTMLURL: Ptr("https://github.com/o/r/actions/runs/1"), + WorkflowRunID: new(int64(1)), + RunURL: new("https://api.github.com/repos/o/r/actions/runs/1"), + HTMLURL: new("https://github.com/o/r/actions/runs/1"), } if !cmp.Equal(dispatchResponse, want) { t.Errorf("Actions.CreateWorkflowDispatchEventByID = %+v, want %+v", dispatchResponse, want) @@ -289,7 +289,7 @@ func TestActionsService_CreateWorkflowDispatchEventByFileName(t *testing.T) { event := CreateWorkflowDispatchEventRequest{ Ref: "d4cfb6e7", - ReturnRunDetails: Ptr(true), + ReturnRunDetails: new(true), Inputs: map[string]any{ "key": "value", }, @@ -308,9 +308,9 @@ func TestActionsService_CreateWorkflowDispatchEventByFileName(t *testing.T) { } want := &WorkflowDispatchRunDetails{ - WorkflowRunID: Ptr(int64(1)), - RunURL: Ptr("https://api.github.com/repos/o/r/actions/runs/1"), - HTMLURL: Ptr("https://github.com/o/r/actions/runs/1"), + WorkflowRunID: new(int64(1)), + RunURL: new("https://api.github.com/repos/o/r/actions/runs/1"), + HTMLURL: new("https://github.com/o/r/actions/runs/1"), } if !cmp.Equal(dispatchResponse, want) { t.Errorf("Actions.CreateWorkflowDispatchEventByFileName = %+v, want %+v", dispatchResponse, want) diff --git a/github/activity_events_test.go b/github/activity_events_test.go index 459c8ab4f46..983b6949015 100644 --- a/github/activity_events_test.go +++ b/github/activity_events_test.go @@ -33,7 +33,7 @@ func TestActivityService_ListEvents(t *testing.T) { t.Errorf("Activities.ListEvents returned error: %v", err) } - want := []*Event{{ID: Ptr("1")}, {ID: Ptr("2")}} + want := []*Event{{ID: new("1")}, {ID: new("2")}} if !cmp.Equal(events, want) { t.Errorf("Activities.ListEvents returned %+v, want %+v", events, want) } @@ -67,7 +67,7 @@ func TestActivityService_ListRepositoryEvents(t *testing.T) { t.Errorf("Activities.ListRepositoryEvents returned error: %v", err) } - want := []*Event{{ID: Ptr("1")}, {ID: Ptr("2")}} + want := []*Event{{ID: new("1")}, {ID: new("2")}} if !cmp.Equal(events, want) { t.Errorf("Activities.ListRepositoryEvents returned %+v, want %+v", events, want) } @@ -115,7 +115,7 @@ func TestActivityService_ListIssueEventsForRepository(t *testing.T) { t.Errorf("Activities.ListIssueEventsForRepository returned error: %v", err) } - want := []*IssueEvent{{ID: Ptr(int64(1))}, {ID: Ptr(int64(2))}} + want := []*IssueEvent{{ID: new(int64(1))}, {ID: new(int64(2))}} if !cmp.Equal(events, want) { t.Errorf("Activities.ListIssueEventsForRepository returned %+v, want %+v", events, want) } @@ -163,7 +163,7 @@ func TestActivityService_ListEventsForRepoNetwork(t *testing.T) { t.Errorf("Activity.ListEventsForRepoNetwork returned error: %v", err) } - want := []*Event{{ID: Ptr("1")}, {ID: Ptr("2")}} + want := []*Event{{ID: new("1")}, {ID: new("2")}} if !cmp.Equal(events, want) { t.Errorf("Activity.ListEventsForRepoNetwork returned %+v, want %+v", events, want) } @@ -211,7 +211,7 @@ func TestActivityService_ListEventsForOrganization(t *testing.T) { t.Errorf("Activity.ListEventsForOrganization returned error: %v", err) } - want := []*Event{{ID: Ptr("1")}, {ID: Ptr("2")}} + want := []*Event{{ID: new("1")}, {ID: new("2")}} if !cmp.Equal(events, want) { t.Errorf("Activity.ListEventsForOrganization returned %+v, want %+v", events, want) } @@ -259,7 +259,7 @@ func TestActivityService_ListEventsPerformedByUser_all(t *testing.T) { t.Errorf("Activity.ListEventsPerformedByUser returned error: %v", err) } - want := []*Event{{ID: Ptr("1")}, {ID: Ptr("2")}} + want := []*Event{{ID: new("1")}, {ID: new("2")}} if !cmp.Equal(events, want) { t.Errorf("Activity.ListEventsPerformedByUser returned %+v, want %+v", events, want) } @@ -294,7 +294,7 @@ func TestActivityService_ListEventsPerformedByUser_publicOnly(t *testing.T) { t.Errorf("Activity.ListEventsPerformedByUser returned error: %v", err) } - want := []*Event{{ID: Ptr("1")}, {ID: Ptr("2")}} + want := []*Event{{ID: new("1")}, {ID: new("2")}} if !cmp.Equal(events, want) { t.Errorf("Activity.ListEventsPerformedByUser returned %+v, want %+v", events, want) } @@ -328,7 +328,7 @@ func TestActivityService_ListEventsReceivedByUser_all(t *testing.T) { t.Errorf("Activity.ListEventsReceivedByUser returned error: %v", err) } - want := []*Event{{ID: Ptr("1")}, {ID: Ptr("2")}} + want := []*Event{{ID: new("1")}, {ID: new("2")}} if !cmp.Equal(events, want) { t.Errorf("Activity.ListEventsReceivedByUser returned %+v, want %+v", events, want) } @@ -363,7 +363,7 @@ func TestActivityService_ListEventsReceivedByUser_publicOnly(t *testing.T) { t.Errorf("Activity.ListEventsReceivedByUser returned error: %v", err) } - want := []*Event{{ID: Ptr("1")}, {ID: Ptr("2")}} + want := []*Event{{ID: new("1")}, {ID: new("2")}} if !cmp.Equal(events, want) { t.Errorf("Activity.ListEventsReceivedByUser returned %+v, want %+v", events, want) } @@ -397,7 +397,7 @@ func TestActivityService_ListUserEventsForOrganization(t *testing.T) { t.Errorf("Activity.ListUserEventsForOrganization returned error: %v", err) } - want := []*Event{{ID: Ptr("1")}, {ID: Ptr("2")}} + want := []*Event{{ID: new("1")}, {ID: new("2")}} if !cmp.Equal(events, want) { t.Errorf("Activity.ListUserEventsForOrganization returned %+v, want %+v", events, want) } @@ -425,7 +425,7 @@ func TestActivityService_EventParsePayload_typed(t *testing.T) { t.Fatalf("Unmarshal Event returned error: %v", err) } - want := &PushEvent{PushID: Ptr(int64(1))} + want := &PushEvent{PushID: new(int64(1))} got, err := event.ParsePayload() if err != nil { t.Fatalf("ParsePayload returned unexpected error: %v", err) @@ -464,7 +464,7 @@ func TestActivityService_EventParsePayload_installation(t *testing.T) { t.Fatalf("Unmarshal Event returned error: %v", err) } - want := &PullRequestEvent{Installation: &Installation{ID: Ptr(int64(1))}} + want := &PullRequestEvent{Installation: &Installation{ID: new(int64(1))}} got, err := event.ParsePayload() if err != nil { t.Fatalf("ParsePayload returned unexpected error: %v", err) diff --git a/github/activity_notifications_test.go b/github/activity_notifications_test.go index ef91f0b4303..bb76987ea0e 100644 --- a/github/activity_notifications_test.go +++ b/github/activity_notifications_test.go @@ -42,7 +42,7 @@ func TestActivityService_ListNotification(t *testing.T) { t.Errorf("Activity.ListNotifications returned error: %v", err) } - want := []*Notification{{ID: Ptr("1"), Subject: &NotificationSubject{Title: Ptr("t")}}} + want := []*Notification{{ID: new("1"), Subject: &NotificationSubject{Title: new("t")}}} if !cmp.Equal(notifications, want) { t.Errorf("Activity.ListNotifications returned %+v, want %+v", notifications, want) } @@ -72,7 +72,7 @@ func TestActivityService_ListRepositoryNotifications(t *testing.T) { t.Errorf("Activity.ListRepositoryNotifications returned error: %v", err) } - want := []*Notification{{ID: Ptr("1")}} + want := []*Notification{{ID: new("1")}} if !cmp.Equal(notifications, want) { t.Errorf("Activity.ListRepositoryNotifications returned %+v, want %+v", notifications, want) } @@ -209,7 +209,7 @@ func TestActivityService_GetThread(t *testing.T) { t.Errorf("Activity.GetThread returned error: %v", err) } - want := &Notification{ID: Ptr("1")} + want := &Notification{ID: new("1")} if !cmp.Equal(notification, want) { t.Errorf("Activity.GetThread returned %+v, want %+v", notification, want) } @@ -296,7 +296,7 @@ func TestActivityService_GetThreadSubscription(t *testing.T) { t.Errorf("Activity.GetThreadSubscription returned error: %v", err) } - want := &Subscription{Subscribed: Ptr(true)} + want := &Subscription{Subscribed: new(true)} if !cmp.Equal(sub, want) { t.Errorf("Activity.GetThreadSubscription returned %+v, want %+v", sub, want) } @@ -320,7 +320,7 @@ func TestActivityService_SetThreadSubscription(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - input := &Subscription{Subscribed: Ptr(true)} + input := &Subscription{Subscribed: new(true)} mux.HandleFunc("/notifications/threads/1/subscription", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "PUT") @@ -334,7 +334,7 @@ func TestActivityService_SetThreadSubscription(t *testing.T) { t.Errorf("Activity.SetThreadSubscription returned error: %v", err) } - want := &Subscription{Ignored: Ptr(true)} + want := &Subscription{Ignored: new(true)} if !cmp.Equal(sub, want) { t.Errorf("Activity.SetThreadSubscription returned %+v, want %+v", sub, want) } diff --git a/github/activity_star_test.go b/github/activity_star_test.go index 6286a166772..e3ddab7aeb6 100644 --- a/github/activity_star_test.go +++ b/github/activity_star_test.go @@ -34,7 +34,7 @@ func TestActivityService_ListStargazers(t *testing.T) { t.Errorf("Activity.ListStargazers returned error: %v", err) } - want := []*Stargazer{{StarredAt: &referenceTimestamp, User: &User{ID: Ptr(int64(1))}}} + want := []*Stargazer{{StarredAt: &referenceTimestamp, User: &User{ID: new(int64(1))}}} if !cmp.Equal(stargazers, want) { t.Errorf("Activity.ListStargazers returned %+v, want %+v", stargazers, want) } @@ -70,7 +70,7 @@ func TestActivityService_ListStarred_authenticatedUser(t *testing.T) { t.Errorf("Activity.ListStarred returned error: %v", err) } - want := []*StarredRepository{{StarredAt: &referenceTimestamp, Repository: &Repository{ID: Ptr(int64(1))}}} + want := []*StarredRepository{{StarredAt: &referenceTimestamp, Repository: &Repository{ID: new(int64(1))}}} if !cmp.Equal(repos, want) { t.Errorf("Activity.ListStarred returned %+v, want %+v", repos, want) } @@ -112,7 +112,7 @@ func TestActivityService_ListStarred_specifiedUser(t *testing.T) { t.Errorf("Activity.ListStarred returned error: %v", err) } - want := []*StarredRepository{{StarredAt: &referenceTimestamp, Repository: &Repository{ID: Ptr(int64(2))}}} + want := []*StarredRepository{{StarredAt: &referenceTimestamp, Repository: &Repository{ID: new(int64(2))}}} if !cmp.Equal(repos, want) { t.Errorf("Activity.ListStarred returned %+v, want %+v", repos, want) } diff --git a/github/activity_test.go b/github/activity_test.go index dc0090591df..f6068fbea60 100644 --- a/github/activity_test.go +++ b/github/activity_test.go @@ -87,44 +87,44 @@ var feedsJSON = []byte(`{ }`) var wantFeeds = &Feeds{ - TimelineURL: Ptr("https://github.com/timeline"), - UserURL: Ptr("https://github.com/{user}"), - CurrentUserPublicURL: Ptr("https://github.com/defunkt"), - CurrentUserURL: Ptr("https://github.com/defunkt.private?token=abc123"), - CurrentUserActorURL: Ptr("https://github.com/defunkt.private.actor?token=abc123"), - CurrentUserOrganizationURL: Ptr(""), + TimelineURL: new("https://github.com/timeline"), + UserURL: new("https://github.com/{user}"), + CurrentUserPublicURL: new("https://github.com/defunkt"), + CurrentUserURL: new("https://github.com/defunkt.private?token=abc123"), + CurrentUserActorURL: new("https://github.com/defunkt.private.actor?token=abc123"), + CurrentUserOrganizationURL: new(""), CurrentUserOrganizationURLs: []string{ "https://github.com/organizations/github/defunkt.private.atom?token=abc123", }, Links: &FeedLinks{ Timeline: &FeedLink{ - HRef: Ptr("https://github.com/timeline"), - Type: Ptr("application/atom+xml"), + HRef: new("https://github.com/timeline"), + Type: new("application/atom+xml"), }, User: &FeedLink{ - HRef: Ptr("https://github.com/{user}"), - Type: Ptr("application/atom+xml"), + HRef: new("https://github.com/{user}"), + Type: new("application/atom+xml"), }, CurrentUserPublic: &FeedLink{ - HRef: Ptr("https://github.com/defunkt"), - Type: Ptr("application/atom+xml"), + HRef: new("https://github.com/defunkt"), + Type: new("application/atom+xml"), }, CurrentUser: &FeedLink{ - HRef: Ptr("https://github.com/defunkt.private?token=abc123"), - Type: Ptr("application/atom+xml"), + HRef: new("https://github.com/defunkt.private?token=abc123"), + Type: new("application/atom+xml"), }, CurrentUserActor: &FeedLink{ - HRef: Ptr("https://github.com/defunkt.private.actor?token=abc123"), - Type: Ptr("application/atom+xml"), + HRef: new("https://github.com/defunkt.private.actor?token=abc123"), + Type: new("application/atom+xml"), }, CurrentUserOrganization: &FeedLink{ - HRef: Ptr(""), - Type: Ptr(""), + HRef: new(""), + Type: new(""), }, CurrentUserOrganizations: []*FeedLink{ { - HRef: Ptr("https://github.com/organizations/github/defunkt.private.atom?token=abc123"), - Type: Ptr("application/atom+xml"), + HRef: new("https://github.com/organizations/github/defunkt.private.atom?token=abc123"), + Type: new("application/atom+xml"), }, }, }, diff --git a/github/activity_watching_test.go b/github/activity_watching_test.go index a5f0c5979e2..ebfee64cb55 100644 --- a/github/activity_watching_test.go +++ b/github/activity_watching_test.go @@ -32,7 +32,7 @@ func TestActivityService_ListWatchers(t *testing.T) { t.Errorf("Activity.ListWatchers returned error: %v", err) } - want := []*User{{ID: Ptr(int64(1))}} + want := []*User{{ID: new(int64(1))}} if !cmp.Equal(watchers, want) { t.Errorf("Activity.ListWatchers returned %+v, want %+v", watchers, want) } @@ -70,7 +70,7 @@ func TestActivityService_ListWatched_authenticatedUser(t *testing.T) { t.Errorf("Activity.ListWatched returned error: %v", err) } - want := []*Repository{{ID: Ptr(int64(1))}} + want := []*Repository{{ID: new(int64(1))}} if !cmp.Equal(watched, want) { t.Errorf("Activity.ListWatched returned %+v, want %+v", watched, want) } @@ -108,7 +108,7 @@ func TestActivityService_ListWatched_specifiedUser(t *testing.T) { t.Errorf("Activity.ListWatched returned error: %v", err) } - want := []*Repository{{ID: Ptr(int64(1))}} + want := []*Repository{{ID: new(int64(1))}} if !cmp.Equal(watched, want) { t.Errorf("Activity.ListWatched returned %+v, want %+v", watched, want) } @@ -129,7 +129,7 @@ func TestActivityService_GetRepositorySubscription_true(t *testing.T) { t.Errorf("Activity.GetRepositorySubscription returned error: %v", err) } - want := &Subscription{Subscribed: Ptr(true)} + want := &Subscription{Subscribed: new(true)} if !cmp.Equal(sub, want) { t.Errorf("Activity.GetRepositorySubscription returned %+v, want %+v", sub, want) } @@ -190,7 +190,7 @@ func TestActivityService_SetRepositorySubscription(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - input := &Subscription{Subscribed: Ptr(true)} + input := &Subscription{Subscribed: new(true)} mux.HandleFunc("/repos/o/r/subscription", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "PUT") @@ -204,7 +204,7 @@ func TestActivityService_SetRepositorySubscription(t *testing.T) { t.Errorf("Activity.SetRepositorySubscription returned error: %v", err) } - want := &Subscription{Ignored: Ptr(true)} + want := &Subscription{Ignored: new(true)} if !cmp.Equal(sub, want) { t.Errorf("Activity.SetRepositorySubscription returned %+v, want %+v", sub, want) } diff --git a/github/admin_orgs_test.go b/github/admin_orgs_test.go index 83ef0ba963f..b8485ae4910 100644 --- a/github/admin_orgs_test.go +++ b/github/admin_orgs_test.go @@ -18,7 +18,7 @@ func TestAdminService_CreateOrg(t *testing.T) { client, mux, _ := setup(t) input := &Organization{ - Login: Ptr("github"), + Login: new("github"), } mux.HandleFunc("/admin/organizations", func(w http.ResponseWriter, r *http.Request) { @@ -33,7 +33,7 @@ func TestAdminService_CreateOrg(t *testing.T) { t.Errorf("Admin.CreateOrg returned error: %v", err) } - want := &Organization{ID: Ptr(int64(1)), Login: Ptr("github")} + want := &Organization{ID: new(int64(1)), Login: new("github")} if !cmp.Equal(org, want) { t.Errorf("Admin.CreateOrg returned %+v, want %+v", org, want) } @@ -53,12 +53,12 @@ func TestAdminService_RenameOrg(t *testing.T) { client, mux, _ := setup(t) input := &Organization{ - Login: Ptr("o"), + Login: new("o"), } mux.HandleFunc("/admin/organizations/o", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "PATCH") - want := &renameOrgRequest{Login: Ptr("the-new-octocats")} + want := &renameOrgRequest{Login: new("the-new-octocats")} testJSONBody(t, r, want) fmt.Fprint(w, `{"message":"Job queued to rename organization. It may take a few minutes to complete.","url":"https:///api/v3/organizations/1"}`) }) @@ -69,7 +69,7 @@ func TestAdminService_RenameOrg(t *testing.T) { t.Errorf("Admin.RenameOrgByName returned error: %v", err) } - want := &RenameOrgResponse{Message: Ptr("Job queued to rename organization. It may take a few minutes to complete."), URL: Ptr("https:///api/v3/organizations/1")} + want := &RenameOrgResponse{Message: new("Job queued to rename organization. It may take a few minutes to complete."), URL: new("https:///api/v3/organizations/1")} if !cmp.Equal(resp, want) { t.Errorf("Admin.RenameOrgByName returned %+v, want %+v", resp, want) } @@ -99,7 +99,7 @@ func TestAdminService_RenameOrgByName(t *testing.T) { mux.HandleFunc("/admin/organizations/o", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "PATCH") - want := &renameOrgRequest{Login: Ptr("the-new-octocats")} + want := &renameOrgRequest{Login: new("the-new-octocats")} testJSONBody(t, r, want) fmt.Fprint(w, `{"message":"Job queued to rename organization. It may take a few minutes to complete.","url":"https:///api/v3/organizations/1"}`) }) @@ -110,7 +110,7 @@ func TestAdminService_RenameOrgByName(t *testing.T) { t.Errorf("Admin.RenameOrgByName returned error: %v", err) } - want := &RenameOrgResponse{Message: Ptr("Job queued to rename organization. It may take a few minutes to complete."), URL: Ptr("https:///api/v3/organizations/1")} + want := &RenameOrgResponse{Message: new("Job queued to rename organization. It may take a few minutes to complete."), URL: new("https:///api/v3/organizations/1")} if !cmp.Equal(resp, want) { t.Errorf("Admin.RenameOrgByName returned %+v, want %+v", resp, want) } diff --git a/github/admin_stats_test.go b/github/admin_stats_test.go index 96c8e744cf2..4da04a94d80 100644 --- a/github/admin_stats_test.go +++ b/github/admin_stats_test.go @@ -160,57 +160,57 @@ func TestAdminService_Stringify(t *testing.T) { var testAdminStats = &AdminStats{ Repos: &RepoStats{ - TotalRepos: Ptr(212), - RootRepos: Ptr(194), - ForkRepos: Ptr(18), - OrgRepos: Ptr(51), - TotalPushes: Ptr(3082), - TotalWikis: Ptr(15), + TotalRepos: new(212), + RootRepos: new(194), + ForkRepos: new(18), + OrgRepos: new(51), + TotalPushes: new(3082), + TotalWikis: new(15), }, Hooks: &HookStats{ - TotalHooks: Ptr(27), - ActiveHooks: Ptr(23), - InactiveHooks: Ptr(4), + TotalHooks: new(27), + ActiveHooks: new(23), + InactiveHooks: new(4), }, Pages: &PageStats{ - TotalPages: Ptr(36), + TotalPages: new(36), }, Orgs: &OrgStats{ - TotalOrgs: Ptr(33), - DisabledOrgs: Ptr(0), - TotalTeams: Ptr(60), - TotalTeamMembers: Ptr(314), + TotalOrgs: new(33), + DisabledOrgs: new(0), + TotalTeams: new(60), + TotalTeamMembers: new(314), }, Users: &UserStats{ - TotalUsers: Ptr(254), - AdminUsers: Ptr(45), - SuspendedUsers: Ptr(21), + TotalUsers: new(254), + AdminUsers: new(45), + SuspendedUsers: new(21), }, Pulls: &PullStats{ - TotalPulls: Ptr(86), - MergedPulls: Ptr(60), - MergeablePulls: Ptr(21), - UnmergeablePulls: Ptr(3), + TotalPulls: new(86), + MergedPulls: new(60), + MergeablePulls: new(21), + UnmergeablePulls: new(3), }, Issues: &IssueStats{ - TotalIssues: Ptr(179), - OpenIssues: Ptr(83), - ClosedIssues: Ptr(96), + TotalIssues: new(179), + OpenIssues: new(83), + ClosedIssues: new(96), }, Milestones: &MilestoneStats{ - TotalMilestones: Ptr(7), - OpenMilestones: Ptr(6), - ClosedMilestones: Ptr(1), + TotalMilestones: new(7), + OpenMilestones: new(6), + ClosedMilestones: new(1), }, Gists: &GistStats{ - TotalGists: Ptr(178), - PrivateGists: Ptr(151), - PublicGists: Ptr(25), + TotalGists: new(178), + PrivateGists: new(151), + PublicGists: new(25), }, Comments: &CommentStats{ - TotalCommitComments: Ptr(6), - TotalGistComments: Ptr(28), - TotalIssueComments: Ptr(366), - TotalPullRequestComments: Ptr(30), + TotalCommitComments: new(6), + TotalGistComments: new(28), + TotalIssueComments: new(366), + TotalPullRequestComments: new(30), }, } diff --git a/github/admin_test.go b/github/admin_test.go index ca4fd3e4d56..c56c1c76ce3 100644 --- a/github/admin_test.go +++ b/github/admin_test.go @@ -34,8 +34,8 @@ func TestAdminService_UpdateUserLDAPMapping(t *testing.T) { } want := &UserLDAPMapping{ - ID: Ptr(int64(1)), - LDAPDN: Ptr("uid=asdf,ou=users,dc=github,dc=com"), + ID: new(int64(1)), + LDAPDN: new("uid=asdf,ou=users,dc=github,dc=com"), } if !cmp.Equal(mapping, want) { t.Errorf("Admin.UpdateUserLDAPMapping returned %+v, want %+v", mapping, want) @@ -77,8 +77,8 @@ func TestAdminService_UpdateTeamLDAPMapping(t *testing.T) { } want := &TeamLDAPMapping{ - ID: Ptr(int64(1)), - LDAPDN: Ptr("cn=Enterprise Ops,ou=teams,dc=github,dc=com"), + ID: new(int64(1)), + LDAPDN: new("cn=Enterprise Ops,ou=teams,dc=github,dc=com"), } if !cmp.Equal(mapping, want) { t.Errorf("Admin.UpdateTeamLDAPMapping returned %+v, want %+v", mapping, want) @@ -102,16 +102,16 @@ func TestAdminService_UpdateTeamLDAPMapping(t *testing.T) { func TestAdminService_TeamLDAPMapping_String(t *testing.T) { t.Parallel() v := &TeamLDAPMapping{ - ID: Ptr(int64(1)), - LDAPDN: Ptr("a"), - URL: Ptr("b"), - Name: Ptr("c"), - Slug: Ptr("d"), - Description: Ptr("e"), - Privacy: Ptr("f"), - Permission: Ptr("g"), - MembersURL: Ptr("h"), - RepositoriesURL: Ptr("i"), + ID: new(int64(1)), + LDAPDN: new("a"), + URL: new("b"), + Name: new("c"), + Slug: new("d"), + Description: new("e"), + Privacy: new("f"), + Permission: new("g"), + MembersURL: new("h"), + RepositoriesURL: new("i"), } want := `github.TeamLDAPMapping{ID:1, LDAPDN:"a", URL:"b", Name:"c", Slug:"d", Description:"e", Privacy:"f", Permission:"g", MembersURL:"h", RepositoriesURL:"i"}` @@ -123,23 +123,23 @@ func TestAdminService_TeamLDAPMapping_String(t *testing.T) { func TestAdminService_UserLDAPMapping_String(t *testing.T) { t.Parallel() v := &UserLDAPMapping{ - ID: Ptr(int64(1)), - LDAPDN: Ptr("a"), - Login: Ptr("b"), - AvatarURL: Ptr("c"), - GravatarID: Ptr("d"), - Type: Ptr("e"), - SiteAdmin: Ptr(true), - URL: Ptr("f"), - EventsURL: Ptr("g"), - FollowingURL: Ptr("h"), - FollowersURL: Ptr("i"), - GistsURL: Ptr("j"), - OrganizationsURL: Ptr("k"), - ReceivedEventsURL: Ptr("l"), - ReposURL: Ptr("m"), - StarredURL: Ptr("n"), - SubscriptionsURL: Ptr("o"), + ID: new(int64(1)), + LDAPDN: new("a"), + Login: new("b"), + AvatarURL: new("c"), + GravatarID: new("d"), + Type: new("e"), + SiteAdmin: new(true), + URL: new("f"), + EventsURL: new("g"), + FollowingURL: new("h"), + FollowersURL: new("i"), + GistsURL: new("j"), + OrganizationsURL: new("k"), + ReceivedEventsURL: new("l"), + ReposURL: new("m"), + StarredURL: new("n"), + SubscriptionsURL: new("o"), } want := `github.UserLDAPMapping{ID:1, LDAPDN:"a", Login:"b", AvatarURL:"c", GravatarID:"d", Type:"e", SiteAdmin:true, URL:"f", EventsURL:"g", FollowingURL:"h", FollowersURL:"i", GistsURL:"j", OrganizationsURL:"k", ReceivedEventsURL:"l", ReposURL:"m", StarredURL:"n", SubscriptionsURL:"o"}` diff --git a/github/admin_users_test.go b/github/admin_users_test.go index 5a0ed0536f5..325cf4fa0ab 100644 --- a/github/admin_users_test.go +++ b/github/admin_users_test.go @@ -17,7 +17,7 @@ func TestAdminUsers_Create(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - input := CreateUserRequest{Login: "github", Email: Ptr("email@example.com"), Suspended: Ptr(false)} + input := CreateUserRequest{Login: "github", Email: new("email@example.com"), Suspended: new(false)} mux.HandleFunc("/admin/users", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "POST") @@ -31,7 +31,7 @@ func TestAdminUsers_Create(t *testing.T) { t.Errorf("Admin.CreateUser returned error: %v", err) } - want := &User{ID: Ptr(int64(1)), Login: Ptr("github")} + want := &User{ID: new(int64(1)), Login: new("github")} if !cmp.Equal(org, want) { t.Errorf("Admin.CreateUser returned %+v, want %+v", org, want) } @@ -107,16 +107,16 @@ func TestUserImpersonation_Create(t *testing.T) { } want := &UserAuthorization{ - ID: Ptr(int64(1234)), - URL: Ptr("https://example.com/authorizations"), + ID: new(int64(1234)), + URL: new("https://example.com/authorizations"), App: &OAuthAPP{ - Name: Ptr("GitHub Site Administrator"), - URL: Ptr("https://docs.github.com/en/rest/enterprise/users/"), - ClientID: Ptr("1234"), + Name: new("GitHub Site Administrator"), + URL: new("https://docs.github.com/en/rest/enterprise/users/"), + ClientID: new("1234"), }, - Token: Ptr("1234"), - HashedToken: Ptr("1234"), - TokenLastEight: Ptr("1234"), + Token: new("1234"), + HashedToken: new("1234"), + TokenLastEight: new("1234"), Note: nil, NoteURL: nil, CreatedAt: refTimestamp(1136178000), diff --git a/github/agent_tasks_test.go b/github/agent_tasks_test.go index b5ecce27687..9b451c883b3 100644 --- a/github/agent_tasks_test.go +++ b/github/agent_tasks_test.go @@ -89,23 +89,23 @@ func agentTaskWithSessionsJSON() string { func agentTask() *AgentTask { return &AgentTask{ ID: "a1b2c3d4-e5f6-7890-abcd-ef1234567890", - URL: Ptr("https://api.github.com/agents/repos/octocat/hello-world/tasks/a1b2c3d4-e5f6-7890-abcd-ef1234567890"), - HTMLURL: Ptr("https://github.com/octocat/hello-world/copilot/tasks/a1b2c3d4-e5f6-7890-abcd-ef1234567890"), - Name: Ptr("Fix the login button on the homepage"), - Creator: &AgentTaskCreator{ID: Ptr(int64(1))}, - CreatorType: Ptr("user"), + URL: new("https://api.github.com/agents/repos/octocat/hello-world/tasks/a1b2c3d4-e5f6-7890-abcd-ef1234567890"), + HTMLURL: new("https://github.com/octocat/hello-world/copilot/tasks/a1b2c3d4-e5f6-7890-abcd-ef1234567890"), + Name: new("Fix the login button on the homepage"), + Creator: &AgentTaskCreator{ID: new(int64(1))}, + CreatorType: new("user"), UserCollaborators: []*User{ - {ID: Ptr(int64(3))}, + {ID: new(int64(3))}, }, - Owner: &AgentTaskOwner{ID: Ptr(int64(2))}, - Repository: &AgentTaskRepository{ID: Ptr(int64(1296269))}, + Owner: &AgentTaskOwner{ID: new(int64(2))}, + Repository: &AgentTaskRepository{ID: new(int64(1296269))}, State: "completed", - SessionCount: Ptr(1), + SessionCount: new(1), Artifacts: []*AgentTaskArtifact{ { Provider: "github", Type: "pull", - Data: &AgentTaskArtifactData{ID: Ptr(int64(42))}, + Data: &AgentTaskArtifactData{ID: new(int64(42))}, }, }, CreatedAt: Timestamp{time.Date(2025, time.March, 14, 0, 0, 0, 0, time.UTC)}, @@ -120,17 +120,17 @@ func agentTaskWithSessions() *AgentTask { task.Sessions = []*AgentTaskSession{ { ID: "s1a2b3c4-d5e6-7890-abcd-ef1234567890", - Name: Ptr("Fix the login button on the homepage"), - User: &User{ID: Ptr(int64(1))}, - Owner: &AgentTaskOwner{ID: Ptr(int64(2))}, - Repository: &AgentTaskRepository{ID: Ptr(int64(1296269))}, - TaskID: Ptr("a1b2c3d4-e5f6-7890-abcd-ef1234567890"), + Name: new("Fix the login button on the homepage"), + User: &User{ID: new(int64(1))}, + Owner: &AgentTaskOwner{ID: new(int64(2))}, + Repository: &AgentTaskRepository{ID: new(int64(1296269))}, + TaskID: new("a1b2c3d4-e5f6-7890-abcd-ef1234567890"), State: "failed", - Prompt: Ptr("Fix the login button on the homepage"), - HeadRef: Ptr("copilot/fix-1"), - BaseRef: Ptr("main"), - Model: Ptr("claude-sonnet-4.6"), - Error: &AgentTaskSessionError{Message: Ptr("agent task failed")}, + Prompt: new("Fix the login button on the homepage"), + HeadRef: new("copilot/fix-1"), + BaseRef: new("main"), + Model: new("claude-sonnet-4.6"), + Error: &AgentTaskSessionError{Message: new("agent task failed")}, CreatedAt: Timestamp{time.Date(2025, time.March, 14, 0, 0, 0, 0, time.UTC)}, UpdatedAt: &Timestamp{time.Date(2025, time.March, 14, 1, 0, 0, 0, time.UTC)}, CompletedAt: &Timestamp{time.Date(2025, time.March, 14, 1, 0, 0, 0, time.UTC)}, @@ -166,7 +166,7 @@ func TestAgentTasksService_ListByRepo(t *testing.T) { Direction: "asc", State: "queued,completed", IsArchived: true, - Since: Ptr(time.Date(2025, time.March, 14, 0, 0, 0, 0, time.UTC)), + Since: new(time.Date(2025, time.March, 14, 0, 0, 0, 0, time.UTC)), ListOptions: ListOptions{Page: 2, PerPage: 1}, }, CreatorID: []int64{1, 2}, @@ -180,8 +180,8 @@ func TestAgentTasksService_ListByRepo(t *testing.T) { want := &AgentTaskList{ Tasks: []*AgentTask{agentTask()}, - TotalActiveCount: Ptr(5), - TotalArchivedCount: Ptr(2), + TotalActiveCount: new(5), + TotalArchivedCount: new(2), } if diff := cmp.Diff(want, tasks); diff != "" { t.Errorf("AgentTasks.ListByRepo mismatch (-want +got):\n%v", diff) @@ -211,10 +211,10 @@ func TestAgentTasksService_Create(t *testing.T) { input := CreateAgentTaskRequest{ Prompt: "Fix the login button on the homepage", - Model: Ptr("gpt-5.3-codex"), - CreatePullRequest: Ptr(true), - HeadRef: Ptr("copilot/fix-1"), - BaseRef: Ptr("main"), + Model: new("gpt-5.3-codex"), + CreatePullRequest: new(true), + HeadRef: new("copilot/fix-1"), + BaseRef: new("main"), } mux.HandleFunc("/agents/repos/o/r/tasks", func(w http.ResponseWriter, r *http.Request) { @@ -307,7 +307,7 @@ func TestAgentTasksService_List(t *testing.T) { Direction: "desc", State: "completed", IsArchived: true, - Since: Ptr(time.Date(2025, time.March, 14, 0, 0, 0, 0, time.UTC)), + Since: new(time.Date(2025, time.March, 14, 0, 0, 0, 0, time.UTC)), ListOptions: ListOptions{Page: 2, PerPage: 1}, } @@ -319,8 +319,8 @@ func TestAgentTasksService_List(t *testing.T) { want := &AgentTaskList{ Tasks: []*AgentTask{agentTask()}, - TotalActiveCount: Ptr(5), - TotalArchivedCount: Ptr(2), + TotalActiveCount: new(5), + TotalArchivedCount: new(2), } if diff := cmp.Diff(want, tasks); diff != "" { t.Errorf("AgentTasks.List mismatch (-want +got):\n%v", diff) diff --git a/github/apps_hooks_deliveries_test.go b/github/apps_hooks_deliveries_test.go index 483611544ec..ac814a6b4c7 100644 --- a/github/apps_hooks_deliveries_test.go +++ b/github/apps_hooks_deliveries_test.go @@ -32,7 +32,7 @@ func TestAppsService_ListHookDeliveries(t *testing.T) { t.Errorf("Apps.ListHookDeliveries returned error: %v", err) } - want := []*HookDelivery{{ID: Ptr(int64(1))}, {ID: Ptr(int64(2))}} + want := []*HookDelivery{{ID: new(int64(1))}, {ID: new(int64(2))}} if d := cmp.Diff(deliveries, want); d != "" { t.Errorf("Apps.ListHooks want (-), got (+):\n%v", d) } @@ -62,7 +62,7 @@ func TestAppsService_GetHookDelivery(t *testing.T) { t.Errorf("Apps.GetHookDelivery returned error: %v", err) } - want := &HookDelivery{ID: Ptr(int64(1))} + want := &HookDelivery{ID: new(int64(1))} if !cmp.Equal(hook, want) { t.Errorf("Apps.GetHookDelivery returned %+v, want %+v", hook, want) } @@ -97,7 +97,7 @@ func TestAppsService_RedeliverHookDelivery(t *testing.T) { t.Errorf("Apps.RedeliverHookDelivery returned error: %v", err) } - want := &HookDelivery{ID: Ptr(int64(1))} + want := &HookDelivery{ID: new(int64(1))} if !cmp.Equal(hook, want) { t.Errorf("Apps.RedeliverHookDelivery returned %+v, want %+v", hook, want) } diff --git a/github/apps_hooks_test.go b/github/apps_hooks_test.go index 4ca7ded24d4..6d26299c744 100644 --- a/github/apps_hooks_test.go +++ b/github/apps_hooks_test.go @@ -34,10 +34,10 @@ func TestAppsService_GetHookConfig(t *testing.T) { } want := &HookConfig{ - ContentType: Ptr("json"), - InsecureSSL: Ptr("0"), - Secret: Ptr("********"), - URL: Ptr("https://example.com/webhook"), + ContentType: new("json"), + InsecureSSL: new("0"), + Secret: new("********"), + URL: new("https://example.com/webhook"), } if !cmp.Equal(config, want) { t.Errorf("Apps.GetHookConfig returned %+v, want %+v", config, want) @@ -58,10 +58,10 @@ func TestAppsService_UpdateHookConfig(t *testing.T) { client, mux, _ := setup(t) input := HookConfig{ - ContentType: Ptr("json"), - InsecureSSL: Ptr("1"), - Secret: Ptr("s"), - URL: Ptr("u"), + ContentType: new("json"), + InsecureSSL: new("1"), + Secret: new("s"), + URL: new("u"), } mux.HandleFunc("/app/hook/config", func(w http.ResponseWriter, r *http.Request) { @@ -82,10 +82,10 @@ func TestAppsService_UpdateHookConfig(t *testing.T) { } want := &HookConfig{ - ContentType: Ptr("json"), - InsecureSSL: Ptr("1"), - Secret: Ptr("********"), - URL: Ptr("u"), + ContentType: new("json"), + InsecureSSL: new("1"), + Secret: new("********"), + URL: new("u"), } if !cmp.Equal(config, want) { t.Errorf("Apps.UpdateHookConfig returned %+v, want %+v", config, want) diff --git a/github/apps_installation_test.go b/github/apps_installation_test.go index f8e833b1f23..5e63dd691c4 100644 --- a/github/apps_installation_test.go +++ b/github/apps_installation_test.go @@ -33,7 +33,7 @@ func TestAppsService_ListRepos(t *testing.T) { t.Errorf("Apps.ListRepos returned error: %v", err) } - want := &ListRepositories{TotalCount: Ptr(1), Repositories: []*Repository{{ID: Ptr(int64(1))}}} + want := &ListRepositories{TotalCount: new(1), Repositories: []*Repository{{ID: new(int64(1))}}} if !cmp.Equal(repositories, want) { t.Errorf("Apps.ListRepos returned %+v, want %+v", repositories, want) } @@ -68,7 +68,7 @@ func TestAppsService_ListUserRepos(t *testing.T) { t.Errorf("Apps.ListUserRepos returned error: %v", err) } - want := &ListRepositories{TotalCount: Ptr(1), Repositories: []*Repository{{ID: Ptr(int64(1))}}} + want := &ListRepositories{TotalCount: new(1), Repositories: []*Repository{{ID: new(int64(1))}}} if !cmp.Equal(repositories, want) { t.Errorf("Apps.ListUserRepos returned %+v, want %+v", repositories, want) } @@ -103,7 +103,7 @@ func TestAppsService_AddRepository(t *testing.T) { t.Errorf("Apps.AddRepository returned error: %v", err) } - want := &Repository{ID: Ptr(int64(1)), Name: Ptr("n"), Description: Ptr("d"), Owner: &User{Login: Ptr("l")}, License: &License{Key: Ptr("mit")}} + want := &Repository{ID: new(int64(1)), Name: new("n"), Description: new("d"), Owner: &User{Login: new("l")}, License: &License{Key: new("mit")}} if !cmp.Equal(repo, want) { t.Errorf("AddRepository returned %+v, want %+v", repo, want) } diff --git a/github/apps_manifest_test.go b/github/apps_manifest_test.go index 799bb2eb494..8f2bd77d9a1 100644 --- a/github/apps_manifest_test.go +++ b/github/apps_manifest_test.go @@ -40,11 +40,11 @@ func TestAppsService_CompleteAppManifest(t *testing.T) { } want := &AppConfig{ - ID: Ptr(int64(1)), - ClientID: Ptr("a"), - ClientSecret: Ptr("b"), - WebhookSecret: Ptr("c"), - PEM: Ptr("key"), + ID: new(int64(1)), + ClientID: new("a"), + ClientSecret: new("b"), + WebhookSecret: new("c"), + PEM: new("key"), } if !cmp.Equal(cfg, want) { diff --git a/github/apps_marketplace_test.go b/github/apps_marketplace_test.go index 8363f725dbb..c79a636736e 100644 --- a/github/apps_marketplace_test.go +++ b/github/apps_marketplace_test.go @@ -34,7 +34,7 @@ func TestMarketplaceService_ListPlans(t *testing.T) { t.Errorf("Marketplace.ListPlans returned error: %v", err) } - want := []*MarketplacePlan{{ID: Ptr(int64(1))}} + want := []*MarketplacePlan{{ID: new(int64(1))}} if !cmp.Equal(plans, want) { t.Errorf("Marketplace.ListPlans returned %+v, want %+v", plans, want) } @@ -66,7 +66,7 @@ func TestMarketplaceService_Stubbed_ListPlans(t *testing.T) { t.Errorf("Marketplace.ListPlans (Stubbed) returned error: %v", err) } - want := []*MarketplacePlan{{ID: Ptr(int64(1))}} + want := []*MarketplacePlan{{ID: new(int64(1))}} if !cmp.Equal(plans, want) { t.Errorf("Marketplace.ListPlans (Stubbed) returned %+v, want %+v", plans, want) } @@ -89,7 +89,7 @@ func TestMarketplaceService_ListPlanAccountsForPlan(t *testing.T) { t.Errorf("Marketplace.ListPlanAccountsForPlan returned error: %v", err) } - want := []*MarketplacePlanAccount{{ID: Ptr(int64(1))}} + want := []*MarketplacePlanAccount{{ID: new(int64(1))}} if !cmp.Equal(accounts, want) { t.Errorf("Marketplace.ListPlanAccountsForPlan returned %+v, want %+v", accounts, want) } @@ -121,7 +121,7 @@ func TestMarketplaceService_Stubbed_ListPlanAccountsForPlan(t *testing.T) { t.Errorf("Marketplace.ListPlanAccountsForPlan (Stubbed) returned error: %v", err) } - want := []*MarketplacePlanAccount{{ID: Ptr(int64(1))}} + want := []*MarketplacePlanAccount{{ID: new(int64(1))}} if !cmp.Equal(accounts, want) { t.Errorf("Marketplace.ListPlanAccountsForPlan (Stubbed) returned %+v, want %+v", accounts, want) } @@ -143,7 +143,7 @@ func TestMarketplaceService_GetPlanAccountForAccount(t *testing.T) { t.Errorf("Marketplace.GetPlanAccountForAccount returned error: %v", err) } - want := &MarketplacePlanAccount{ID: Ptr(int64(1)), MarketplacePendingChange: &MarketplacePendingChange{ID: Ptr(int64(77))}} + want := &MarketplacePlanAccount{ID: new(int64(1)), MarketplacePendingChange: &MarketplacePendingChange{ID: new(int64(77))}} if !cmp.Equal(account, want) { t.Errorf("Marketplace.GetPlanAccountForAccount returned %+v, want %+v", account, want) } @@ -174,7 +174,7 @@ func TestMarketplaceService_Stubbed_GetPlanAccountForAccount(t *testing.T) { t.Errorf("Marketplace.GetPlanAccountForAccount (Stubbed) returned error: %v", err) } - want := &MarketplacePlanAccount{ID: Ptr(int64(1))} + want := &MarketplacePlanAccount{ID: new(int64(1))} if !cmp.Equal(account, want) { t.Errorf("Marketplace.GetPlanAccountForAccount (Stubbed) returned %+v, want %+v", account, want) } @@ -197,7 +197,7 @@ func TestMarketplaceService_ListMarketplacePurchasesForUser(t *testing.T) { t.Errorf("Marketplace.ListMarketplacePurchasesForUser returned error: %v", err) } - want := []*MarketplacePurchase{{BillingCycle: Ptr("monthly")}} + want := []*MarketplacePurchase{{BillingCycle: new("monthly")}} if !cmp.Equal(purchases, want) { t.Errorf("Marketplace.ListMarketplacePurchasesForUser returned %+v, want %+v", purchases, want) } @@ -229,7 +229,7 @@ func TestMarketplaceService_Stubbed_ListMarketplacePurchasesForUser(t *testing.T t.Errorf("Marketplace.ListMarketplacePurchasesForUser returned error: %v", err) } - want := []*MarketplacePurchase{{BillingCycle: Ptr("monthly")}} + want := []*MarketplacePurchase{{BillingCycle: new("monthly")}} if !cmp.Equal(purchases, want) { t.Errorf("Marketplace.ListMarketplacePurchasesForUser returned %+v, want %+v", purchases, want) } diff --git a/github/apps_test.go b/github/apps_test.go index d936a4f3aac..1c1e00b3f71 100644 --- a/github/apps_test.go +++ b/github/apps_test.go @@ -28,7 +28,7 @@ func TestAppsService_Get_authenticatedApp(t *testing.T) { t.Errorf("Apps.Get returned error: %v", err) } - want := &App{ID: Ptr(int64(1))} + want := &App{ID: new(int64(1))} if !cmp.Equal(app, want) { t.Errorf("Apps.Get returned %+v, want %+v", app, want) } @@ -63,7 +63,7 @@ func TestAppsService_Get_specifiedApp(t *testing.T) { t.Errorf("Apps.Get returned error: %v", err) } - want := &App{HTMLURL: Ptr("https://github.com/apps/a")} + want := &App{HTMLURL: new("https://github.com/apps/a")} if !cmp.Equal(app, want) { t.Errorf("Apps.Get returned %+v, want %+v", *app.HTMLURL, *want.HTMLURL) } @@ -96,9 +96,9 @@ func TestAppsService_ListInstallationRequests(t *testing.T) { } want := []*InstallationRequest{{ - ID: Ptr(int64(1)), - Account: &User{ID: Ptr(int64(2))}, - Requester: &User{ID: Ptr(int64(3))}, + ID: new(int64(1)), + Account: &User{ID: new(int64(2))}, + Requester: &User{ID: new(int64(3))}, CreatedAt: &referenceTimestamp, }} if !cmp.Equal(installationRequests, want) { @@ -187,49 +187,49 @@ func TestAppsService_ListInstallations(t *testing.T) { } want := []*Installation{{ - ID: Ptr(int64(1)), - AppID: Ptr(int64(1)), - TargetID: Ptr(int64(1)), - TargetType: Ptr("Organization"), - SingleFileName: Ptr("config.yml"), - RepositorySelection: Ptr("selected"), + ID: new(int64(1)), + AppID: new(int64(1)), + TargetID: new(int64(1)), + TargetType: new("Organization"), + SingleFileName: new("config.yml"), + RepositorySelection: new("selected"), Permissions: &InstallationPermissions{ - Actions: Ptr("read"), - Administration: Ptr("read"), - Checks: Ptr("read"), - Contents: Ptr("read"), - ContentReferences: Ptr("read"), - Deployments: Ptr("read"), - Environments: Ptr("read"), - Issues: Ptr("write"), - Metadata: Ptr("read"), - Members: Ptr("read"), - OrganizationAdministration: Ptr("write"), - OrganizationCustomRoles: Ptr("write"), - OrganizationHooks: Ptr("write"), - OrganizationPackages: Ptr("write"), - OrganizationPersonalAccessTokens: Ptr("read"), - OrganizationPersonalAccessTokenRequests: Ptr("read"), - OrganizationPlan: Ptr("read"), - OrganizationPreReceiveHooks: Ptr("write"), - OrganizationProjects: Ptr("read"), - OrganizationSecrets: Ptr("read"), - OrganizationSelfHostedRunners: Ptr("read"), - OrganizationUserBlocking: Ptr("write"), - Packages: Ptr("read"), - Pages: Ptr("read"), - PullRequests: Ptr("write"), - RepositoryHooks: Ptr("write"), - RepositoryProjects: Ptr("read"), - RepositoryPreReceiveHooks: Ptr("read"), - Secrets: Ptr("read"), - SecretScanningAlerts: Ptr("read"), - SecurityEvents: Ptr("read"), - SingleFile: Ptr("write"), - Statuses: Ptr("write"), - TeamDiscussions: Ptr("read"), - VulnerabilityAlerts: Ptr("read"), - Workflows: Ptr("write"), + Actions: new("read"), + Administration: new("read"), + Checks: new("read"), + Contents: new("read"), + ContentReferences: new("read"), + Deployments: new("read"), + Environments: new("read"), + Issues: new("write"), + Metadata: new("read"), + Members: new("read"), + OrganizationAdministration: new("write"), + OrganizationCustomRoles: new("write"), + OrganizationHooks: new("write"), + OrganizationPackages: new("write"), + OrganizationPersonalAccessTokens: new("read"), + OrganizationPersonalAccessTokenRequests: new("read"), + OrganizationPlan: new("read"), + OrganizationPreReceiveHooks: new("write"), + OrganizationProjects: new("read"), + OrganizationSecrets: new("read"), + OrganizationSelfHostedRunners: new("read"), + OrganizationUserBlocking: new("write"), + Packages: new("read"), + Pages: new("read"), + PullRequests: new("write"), + RepositoryHooks: new("write"), + RepositoryProjects: new("read"), + RepositoryPreReceiveHooks: new("read"), + Secrets: new("read"), + SecretScanningAlerts: new("read"), + SecurityEvents: new("read"), + SingleFile: new("write"), + Statuses: new("write"), + TeamDiscussions: new("read"), + VulnerabilityAlerts: new("read"), + Workflows: new("write"), }, Events: []string{"push", "pull_request"}, CreatedAt: refTimestamp(1136178000), @@ -264,7 +264,7 @@ func TestAppsService_GetInstallation(t *testing.T) { t.Errorf("Apps.GetInstallation returned error: %v", err) } - want := &Installation{ID: Ptr(int64(1)), AppID: Ptr(int64(1)), TargetID: Ptr(int64(1)), TargetType: Ptr("Organization")} + want := &Installation{ID: new(int64(1)), AppID: new(int64(1)), TargetID: new(int64(1)), TargetType: new("Organization")} if !cmp.Equal(installation, want) { t.Errorf("Apps.GetInstallation returned %+v, want %+v", installation, want) } @@ -304,7 +304,7 @@ func TestAppsService_ListUserInstallations(t *testing.T) { t.Errorf("Apps.ListUserInstallations returned error: %v", err) } - want := []*Installation{{ID: Ptr(int64(1)), AppID: Ptr(int64(1)), TargetID: Ptr(int64(1)), TargetType: Ptr("Organization")}} + want := []*Installation{{ID: new(int64(1)), AppID: new(int64(1)), TargetID: new(int64(1)), TargetType: new("Organization")}} if !cmp.Equal(installations, want) { t.Errorf("Apps.ListUserInstallations returned %+v, want %+v", installations, want) } @@ -412,7 +412,7 @@ func TestAppsService_CreateInstallationToken(t *testing.T) { t.Errorf("Apps.CreateInstallationToken returned error: %v", err) } - want := &InstallationToken{Token: Ptr("t")} + want := &InstallationToken{Token: new("t")} if !cmp.Equal(token, want) { t.Errorf("Apps.CreateInstallationToken returned %+v, want %+v", token, want) } @@ -440,8 +440,8 @@ func TestAppsService_CreateInstallationTokenWithOptions(t *testing.T) { RepositoryIDs: []int64{1234}, Repositories: []string{"foo"}, Permissions: &InstallationPermissions{ - Contents: Ptr("write"), - Issues: Ptr("read"), + Contents: new("write"), + Issues: new("read"), }, } @@ -457,7 +457,7 @@ func TestAppsService_CreateInstallationTokenWithOptions(t *testing.T) { t.Errorf("Apps.CreateInstallationToken returned error: %v", err) } - want := &InstallationToken{Token: Ptr("t")} + want := &InstallationToken{Token: new("t")} if !cmp.Equal(token, want) { t.Errorf("Apps.CreateInstallationToken returned %+v, want %+v", token, want) } @@ -470,8 +470,8 @@ func TestAppsService_CreateInstallationTokenListReposWithOptions(t *testing.T) { installationTokenListRepoOptions := &InstallationTokenListRepoOptions{ Repositories: []string{"foo"}, Permissions: &InstallationPermissions{ - Contents: Ptr("write"), - Issues: Ptr("read"), + Contents: new("write"), + Issues: new("read"), }, } @@ -487,7 +487,7 @@ func TestAppsService_CreateInstallationTokenListReposWithOptions(t *testing.T) { t.Errorf("Apps.CreateInstallationTokenListRepos returned error: %v", err) } - want := &InstallationToken{Token: Ptr("t")} + want := &InstallationToken{Token: new("t")} if !cmp.Equal(token, want) { t.Errorf("Apps.CreateInstallationTokenListRepos returned %+v, want %+v", token, want) } @@ -508,7 +508,7 @@ func TestAppsService_CreateInstallationTokenListReposWithNoOptions(t *testing.T) t.Errorf("Apps.CreateInstallationTokenListRepos returned error: %v", err) } - want := &InstallationToken{Token: Ptr("t")} + want := &InstallationToken{Token: new("t")} if !cmp.Equal(token, want) { t.Errorf("Apps.CreateInstallationTokenListRepos returned %+v, want %+v", token, want) } @@ -546,7 +546,7 @@ func TestAppsService_CreateAttachment(t *testing.T) { t.Errorf("CreateAttachment returned error: %v", err) } - want := &Attachment{ID: Ptr(int64(1)), Title: Ptr("title1"), Body: Ptr("body1")} + want := &Attachment{ID: new(int64(1)), Title: new("title1"), Body: new("body1")} if !cmp.Equal(got, want) { t.Errorf("CreateAttachment = %+v, want %+v", got, want) } @@ -581,7 +581,7 @@ func TestAppsService_GetOrganizationInstallation(t *testing.T) { t.Errorf("Apps.GetOrganizationInstallation returned error: %v", err) } - want := &Installation{ID: Ptr(int64(1)), AppID: Ptr(int64(1)), TargetID: Ptr(int64(1)), TargetType: Ptr("Organization")} + want := &Installation{ID: new(int64(1)), AppID: new(int64(1)), TargetID: new(int64(1)), TargetType: new("Organization")} if !cmp.Equal(installation, want) { t.Errorf("Apps.GetOrganizationInstallation returned %+v, want %+v", installation, want) } @@ -616,7 +616,7 @@ func TestAppsService_GetEnterpriseInstallation(t *testing.T) { t.Errorf("Apps.GetEnterpriseInstallation returned error: %v", err) } - want := &Installation{ID: Ptr(int64(1)), AppID: Ptr(int64(1)), TargetID: Ptr(int64(1)), TargetType: Ptr("Enterprise")} + want := &Installation{ID: new(int64(1)), AppID: new(int64(1)), TargetID: new(int64(1)), TargetType: new("Enterprise")} if !cmp.Equal(installation, want) { t.Errorf("Apps.GetEnterpriseInstallation returned %+v, want %+v", installation, want) } @@ -651,7 +651,7 @@ func TestAppsService_GetRepositoryInstallation(t *testing.T) { t.Errorf("Apps.GetRepositoryInstallation returned error: %v", err) } - want := &Installation{ID: Ptr(int64(1)), AppID: Ptr(int64(1)), TargetID: Ptr(int64(1)), TargetType: Ptr("Organization")} + want := &Installation{ID: new(int64(1)), AppID: new(int64(1)), TargetID: new(int64(1)), TargetType: new("Organization")} if !cmp.Equal(installation, want) { t.Errorf("Apps.GetRepositoryInstallation returned %+v, want %+v", installation, want) } @@ -686,7 +686,7 @@ func TestAppsService_GetRepositoryInstallationByID(t *testing.T) { t.Errorf("Apps.GetRepositoryInstallationByID returned error: %v", err) } - want := &Installation{ID: Ptr(int64(1)), AppID: Ptr(int64(1)), TargetID: Ptr(int64(1)), TargetType: Ptr("Organization")} + want := &Installation{ID: new(int64(1)), AppID: new(int64(1)), TargetID: new(int64(1)), TargetType: new("Organization")} if !cmp.Equal(installation, want) { t.Errorf("Apps.GetRepositoryInstallationByID returned %+v, want %+v", installation, want) } @@ -721,7 +721,7 @@ func TestAppsService_GetUserInstallation(t *testing.T) { t.Errorf("Apps.GetUserInstallation returned error: %v", err) } - want := &Installation{ID: Ptr(int64(1)), AppID: Ptr(int64(1)), TargetID: Ptr(int64(1)), TargetType: Ptr("User")} + want := &Installation{ID: new(int64(1)), AppID: new(int64(1)), TargetID: new(int64(1)), TargetType: new("User")} if !cmp.Equal(installation, want) { t.Errorf("Apps.GetUserInstallation returned %+v, want %+v", installation, want) } diff --git a/github/authorizations_test.go b/github/authorizations_test.go index d1867728655..f7dce7ea7f1 100644 --- a/github/authorizations_test.go +++ b/github/authorizations_test.go @@ -34,7 +34,7 @@ func TestAuthorizationsService_Check(t *testing.T) { t.Errorf("Authorizations.Check returned error: %v", err) } - want := &Authorization{ID: Ptr(int64(1))} + want := &Authorization{ID: new(int64(1))} if !cmp.Equal(got, want) { t.Errorf("Authorizations.Check returned auth %+v, want %+v", got, want) } @@ -75,7 +75,7 @@ func TestAuthorizationsService_Reset(t *testing.T) { t.Errorf("Authorizations.Reset returned error: %v", err) } - want := &Authorization{ID: Ptr(int64(1))} + want := &Authorization{ID: new(int64(1))} if !cmp.Equal(got, want) { t.Errorf("Authorizations.Reset returned auth %+v, want %+v", got, want) } @@ -176,7 +176,7 @@ func TestAuthorizationsService_CreateImpersonation(t *testing.T) { t.Errorf("Authorizations.CreateImpersonation returned error: %+v", err) } - want := &Authorization{ID: Ptr(int64(1))} + want := &Authorization{ID: new(int64(1))} if !cmp.Equal(got, want) { t.Errorf("Authorizations.CreateImpersonation returned %+v, want %+v", *got.ID, *want.ID) } diff --git a/github/billing_test.go b/github/billing_test.go index fc6c48fbd1c..fca1522f192 100644 --- a/github/billing_test.go +++ b/github/billing_test.go @@ -259,10 +259,10 @@ func TestBillingService_GetOrganizationAdvancedSecurityActiveCommitters(t *testi } want := &ActiveCommitters{ - TotalAdvancedSecurityCommitters: Ptr(2), - TotalCount: Ptr(2), - MaximumAdvancedSecurityCommitters: Ptr(3), - PurchasedAdvancedSecurityCommitters: Ptr(4), + TotalAdvancedSecurityCommitters: new(2), + TotalCount: new(2), + MaximumAdvancedSecurityCommitters: new(3), + PurchasedAdvancedSecurityCommitters: new(4), Repositories: []*RepositoryActiveCommitters{ { Name: "octocat-org/Hello-World", @@ -336,8 +336,8 @@ func TestBillingService_GetOrganizationUsageReport(t *testing.T) { ctx := t.Context() opts := &UsageReportOptions{ - Year: Ptr(2023), - Month: Ptr(8), + Year: new(2023), + Month: new(8), } report, _, err := client.Billing.GetOrganizationUsageReport(ctx, "o", opts) if err != nil { @@ -356,8 +356,8 @@ func TestBillingService_GetOrganizationUsageReport(t *testing.T) { GrossAmount: 0.8, DiscountAmount: 0.0, NetAmount: 0.8, - OrganizationName: Ptr("GitHub"), - RepositoryName: Ptr("github/example"), + OrganizationName: new("GitHub"), + RepositoryName: new("github/example"), }, }, } @@ -418,7 +418,7 @@ func TestBillingService_GetUsageReport(t *testing.T) { ctx := t.Context() opts := &UsageReportOptions{ - Day: Ptr(15), + Day: new(15), } report, _, err := client.Billing.GetUsageReport(ctx, "u", opts) if err != nil { @@ -437,7 +437,7 @@ func TestBillingService_GetUsageReport(t *testing.T) { GrossAmount: 9.0, DiscountAmount: 1.0, NetAmount: 8.0, - RepositoryName: Ptr("user/example"), + RepositoryName: new("user/example"), }, }, } @@ -507,9 +507,9 @@ func TestBillingService_GetOrganizationPremiumRequestUsageReport(t *testing.T) { }) ctx := t.Context() opts := &PremiumRequestUsageReportOptions{ - Year: Ptr(2025), - Month: Ptr(10), - User: Ptr("testuser"), + Year: new(2025), + Month: new(10), + User: new("testuser"), } report, _, err := client.Billing.GetOrganizationPremiumRequestUsageReport(ctx, "o", opts) if err != nil { @@ -518,12 +518,12 @@ func TestBillingService_GetOrganizationPremiumRequestUsageReport(t *testing.T) { want := &PremiumRequestUsageReport{ TimePeriod: PremiumRequestUsageTimePeriod{ Year: 2025, - Month: Ptr(10), + Month: new(10), }, - Organization: Ptr("GitHub"), - User: Ptr("testuser"), - Product: Ptr("Copilot"), - Model: Ptr("GPT-5"), + Organization: new("GitHub"), + User: new("testuser"), + Product: new("Copilot"), + Model: new("GPT-5"), UsageItems: []*PremiumRequestUsageItem{ { Product: "Copilot", @@ -603,8 +603,8 @@ func TestBillingService_GetPremiumRequestUsageReport(t *testing.T) { }) ctx := t.Context() opts := &PremiumRequestUsageReportOptions{ - Year: Ptr(2025), - Day: Ptr(15), + Year: new(2025), + Day: new(15), } report, _, err := client.Billing.GetPremiumRequestUsageReport(ctx, "u", opts) if err != nil { @@ -613,10 +613,10 @@ func TestBillingService_GetPremiumRequestUsageReport(t *testing.T) { want := &PremiumRequestUsageReport{ TimePeriod: PremiumRequestUsageTimePeriod{ Year: 2025, - Day: Ptr(15), + Day: new(15), }, - User: Ptr("User"), - Product: Ptr("Copilot"), + User: new("User"), + Product: new("Copilot"), UsageItems: []*PremiumRequestUsageItem{ { Product: "Copilot", @@ -697,9 +697,9 @@ func TestBillingService_PremiumRequestUsageItem_FloatQuantities(t *testing.T) { want := &PremiumRequestUsageReport{ TimePeriod: PremiumRequestUsageTimePeriod{ Year: 2026, - Month: Ptr(2), + Month: new(2), }, - Organization: Ptr("testorg"), + Organization: new("testorg"), UsageItems: []*PremiumRequestUsageItem{ { Product: "Copilot", @@ -761,9 +761,9 @@ func TestBillingService_GetOrgAICreditUsage(t *testing.T) { ctx := t.Context() opts := &PremiumRequestUsageReportOptions{ - Year: Ptr(2025), - Month: Ptr(6), - User: Ptr("testuser"), + Year: new(2025), + Month: new(6), + User: new("testuser"), } report, _, err := client.Billing.GetOrgAICreditUsage(ctx, "o", opts) if err != nil { @@ -773,12 +773,12 @@ func TestBillingService_GetOrgAICreditUsage(t *testing.T) { want := &PremiumRequestUsageReport{ TimePeriod: PremiumRequestUsageTimePeriod{ Year: 2025, - Month: Ptr(6), + Month: new(6), }, - Organization: Ptr("GitHub"), - User: Ptr("testuser"), - Product: Ptr("Copilot"), - Model: Ptr("GPT-5"), + Organization: new("GitHub"), + User: new("testuser"), + Product: new("Copilot"), + Model: new("GPT-5"), UsageItems: []*PremiumRequestUsageItem{ { Product: "Copilot", @@ -863,10 +863,10 @@ func TestBillingService_GetOrgAICreditUsage_FloatQuantities(t *testing.T) { want := &PremiumRequestUsageReport{ TimePeriod: PremiumRequestUsageTimePeriod{ Year: 2025, - Month: Ptr(6), - Day: Ptr(15), + Month: new(6), + Day: new(15), }, - Organization: Ptr("testorg"), + Organization: new("testorg"), UsageItems: []*PremiumRequestUsageItem{ { Product: "Copilot", @@ -927,9 +927,9 @@ func TestBillingService_GetUserAICreditUsage(t *testing.T) { ctx := t.Context() opts := &PremiumRequestUsageReportOptions{ - Year: Ptr(2025), - Month: Ptr(6), - User: Ptr("testuser"), + Year: new(2025), + Month: new(6), + User: new("testuser"), } report, _, err := client.Billing.GetUserAICreditUsage(ctx, "u", opts) if err != nil { @@ -939,11 +939,11 @@ func TestBillingService_GetUserAICreditUsage(t *testing.T) { want := &PremiumRequestUsageReport{ TimePeriod: PremiumRequestUsageTimePeriod{ Year: 2025, - Month: Ptr(6), + Month: new(6), }, - User: Ptr("testuser"), - Product: Ptr("Copilot"), - Model: Ptr("GPT-5"), + User: new("testuser"), + Product: new("Copilot"), + Model: new("GPT-5"), UsageItems: []*PremiumRequestUsageItem{ { Product: "Copilot", @@ -1028,10 +1028,10 @@ func TestBillingService_GetUserAICreditUsage_FloatQuantities(t *testing.T) { want := &PremiumRequestUsageReport{ TimePeriod: PremiumRequestUsageTimePeriod{ Year: 2025, - Month: Ptr(6), - Day: Ptr(15), + Month: new(6), + Day: new(15), }, - User: Ptr("testuser"), + User: new("testuser"), UsageItems: []*PremiumRequestUsageItem{ { Product: "Copilot", diff --git a/github/checks_test.go b/github/checks_test.go index c66483c6b33..2c37405a023 100644 --- a/github/checks_test.go +++ b/github/checks_test.go @@ -38,12 +38,12 @@ func TestChecksService_GetCheckRun(t *testing.T) { completeAt, _ := time.Parse(time.RFC3339, "2018-05-04T01:14:52Z") want := &CheckRun{ - ID: Ptr(int64(1)), - Status: Ptr("completed"), - Conclusion: Ptr("neutral"), + ID: new(int64(1)), + Status: new("completed"), + Conclusion: new("neutral"), StartedAt: &Timestamp{startedAt}, CompletedAt: &Timestamp{completeAt}, - Name: Ptr("testCheckRun"), + Name: new("testCheckRun"), } if !cmp.Equal(checkRun, want) { t.Errorf("Checks.GetCheckRun return %+v, want %+v", checkRun, want) @@ -86,13 +86,13 @@ func TestChecksService_GetCheckSuite(t *testing.T) { t.Errorf("Checks.GetCheckSuite return error: %v", err) } want := &CheckSuite{ - ID: Ptr(int64(1)), - HeadBranch: Ptr("master"), - HeadSHA: Ptr("deadbeef"), - AfterSHA: Ptr("deadbeefa"), - BeforeSHA: Ptr("deadbeefb"), - Status: Ptr("completed"), - Conclusion: Ptr("neutral"), + ID: new(int64(1)), + HeadBranch: new("master"), + HeadSHA: new("deadbeef"), + AfterSHA: new("deadbeefa"), + BeforeSHA: new("deadbeefb"), + Status: new("completed"), + Conclusion: new("neutral"), } if !cmp.Equal(checkSuite, want) { t.Errorf("Checks.GetCheckSuite return %+v, want %+v", checkSuite, want) @@ -134,12 +134,12 @@ func TestChecksService_CreateCheckRun(t *testing.T) { checkRunOpt := CreateCheckRunOptions{ Name: "testCreateCheckRun", HeadSHA: "deadbeef", - Status: Ptr("in_progress"), + Status: new("in_progress"), StartedAt: &Timestamp{startedAt}, Output: &CheckRunOutput{ - Title: Ptr("Mighty test report"), - Summary: Ptr(""), - Text: Ptr(""), + Title: new("Mighty test report"), + Summary: new(""), + Text: new(""), }, } @@ -150,15 +150,15 @@ func TestChecksService_CreateCheckRun(t *testing.T) { } want := &CheckRun{ - ID: Ptr(int64(1)), - Status: Ptr("in_progress"), + ID: new(int64(1)), + Status: new("in_progress"), StartedAt: &Timestamp{startedAt}, - HeadSHA: Ptr("deadbeef"), - Name: Ptr("testCreateCheckRun"), + HeadSHA: new("deadbeef"), + Name: new("testCreateCheckRun"), Output: &CheckRunOutput{ - Title: Ptr("Mighty test report"), - Summary: Ptr(""), - Text: Ptr(""), + Title: new("Mighty test report"), + Summary: new(""), + Text: new(""), }, } if !cmp.Equal(checkRun, want) { @@ -210,15 +210,15 @@ func TestChecksService_ListCheckRunAnnotations(t *testing.T) { } want := []*CheckRunAnnotation{{ - Path: Ptr("README.md"), - StartLine: Ptr(2), - EndLine: Ptr(2), - StartColumn: Ptr(1), - EndColumn: Ptr(5), - AnnotationLevel: Ptr("warning"), - Message: Ptr("Check your spelling for 'banaas'."), - Title: Ptr("Spell check"), - RawDetails: Ptr("Do you mean 'bananas' or 'banana'?"), + Path: new("README.md"), + StartLine: new(2), + EndLine: new(2), + StartColumn: new(1), + EndColumn: new(5), + AnnotationLevel: new("warning"), + Message: new("Check your spelling for 'banaas'."), + Title: new("Spell check"), + RawDetails: new("Do you mean 'bananas' or 'banana'?"), }} if !cmp.Equal(checkRunAnnotations, want) { @@ -259,12 +259,12 @@ func TestChecksService_UpdateCheckRun(t *testing.T) { startedAt, _ := time.Parse(time.RFC3339, "2018-05-04T01:14:52Z") updateCheckRunOpt := UpdateCheckRunOptions{ Name: "testUpdateCheckRun", - Status: Ptr("completed"), + Status: new("completed"), CompletedAt: &Timestamp{startedAt}, Output: &CheckRunOutput{ - Title: Ptr("Mighty test report"), - Summary: Ptr("There are 0 failures, 2 warnings and 1 notice"), - Text: Ptr("You may have misspelled some words."), + Title: new("Mighty test report"), + Summary: new("There are 0 failures, 2 warnings and 1 notice"), + Text: new("You may have misspelled some words."), }, } @@ -275,16 +275,16 @@ func TestChecksService_UpdateCheckRun(t *testing.T) { } want := &CheckRun{ - ID: Ptr(int64(1)), - Status: Ptr("completed"), + ID: new(int64(1)), + Status: new("completed"), StartedAt: &Timestamp{startedAt}, CompletedAt: &Timestamp{startedAt}, - Conclusion: Ptr("neutral"), - Name: Ptr("testUpdateCheckRun"), + Conclusion: new("neutral"), + Name: new("testUpdateCheckRun"), Output: &CheckRunOutput{ - Title: Ptr("Mighty test report"), - Summary: Ptr("There are 0 failures, 2 warnings and 1 notice"), - Text: Ptr("You may have misspelled some words."), + Title: new("Mighty test report"), + Summary: new("There are 0 failures, 2 warnings and 1 notice"), + Text: new("You may have misspelled some words."), }, } if !cmp.Equal(checkRun, want) { @@ -334,10 +334,10 @@ func TestChecksService_ListCheckRunsForRef(t *testing.T) { }) opt := &ListCheckRunsOptions{ - CheckName: Ptr("testing"), - Status: Ptr("completed"), - Filter: Ptr("all"), - AppID: Ptr(int64(1)), + CheckName: new("testing"), + Status: new("completed"), + Filter: new("all"), + AppID: new(int64(1)), ListOptions: ListOptions{Page: 1}, } ctx := t.Context() @@ -347,15 +347,15 @@ func TestChecksService_ListCheckRunsForRef(t *testing.T) { } startedAt, _ := time.Parse(time.RFC3339, "2018-05-04T01:14:52Z") want := &ListCheckRunsResults{ - Total: Ptr(1), + Total: new(1), CheckRuns: []*CheckRun{{ - ID: Ptr(int64(1)), - Status: Ptr("completed"), + ID: new(int64(1)), + Status: new("completed"), StartedAt: &Timestamp{startedAt}, CompletedAt: &Timestamp{startedAt}, - Conclusion: Ptr("neutral"), - HeadSHA: Ptr("deadbeef"), - App: &App{ID: Ptr(int64(1))}, + Conclusion: new("neutral"), + HeadSHA: new("deadbeef"), + App: &App{ID: new(int64(1))}, }}, } @@ -403,9 +403,9 @@ func TestChecksService_ListCheckRunsCheckSuite(t *testing.T) { }) opt := &ListCheckRunsOptions{ - CheckName: Ptr("testing"), - Status: Ptr("completed"), - Filter: Ptr("all"), + CheckName: new("testing"), + Status: new("completed"), + Filter: new("all"), ListOptions: ListOptions{Page: 1}, } ctx := t.Context() @@ -415,14 +415,14 @@ func TestChecksService_ListCheckRunsCheckSuite(t *testing.T) { } startedAt, _ := time.Parse(time.RFC3339, "2018-05-04T01:14:52Z") want := &ListCheckRunsResults{ - Total: Ptr(1), + Total: new(1), CheckRuns: []*CheckRun{{ - ID: Ptr(int64(1)), - Status: Ptr("completed"), + ID: new(int64(1)), + Status: new("completed"), StartedAt: &Timestamp{startedAt}, CompletedAt: &Timestamp{startedAt}, - Conclusion: Ptr("neutral"), - HeadSHA: Ptr("deadbeef"), + Conclusion: new("neutral"), + HeadSHA: new("deadbeef"), }}, } @@ -470,8 +470,8 @@ func TestChecksService_ListCheckSuiteForRef(t *testing.T) { }) opt := &ListCheckSuiteOptions{ - CheckName: Ptr("testing"), - AppID: Ptr(int64(2)), + CheckName: new("testing"), + AppID: new(int64(2)), ListOptions: ListOptions{Page: 1}, } ctx := t.Context() @@ -480,15 +480,15 @@ func TestChecksService_ListCheckSuiteForRef(t *testing.T) { t.Errorf("Checks.ListCheckSuitesForRef return error: %v", err) } want := &ListCheckSuiteResults{ - Total: Ptr(1), + Total: new(1), CheckSuites: []*CheckSuite{{ - ID: Ptr(int64(1)), - Status: Ptr("completed"), - Conclusion: Ptr("neutral"), - HeadSHA: Ptr("deadbeef"), - HeadBranch: Ptr("master"), - BeforeSHA: Ptr("deadbeefb"), - AfterSHA: Ptr("deadbeefa"), + ID: new(int64(1)), + Status: new("completed"), + Conclusion: new("neutral"), + HeadSHA: new("deadbeef"), + HeadBranch: new("master"), + BeforeSHA: new("deadbeefb"), + AfterSHA: new("deadbeefa"), }}, } @@ -516,8 +516,8 @@ func TestChecksService_SetCheckSuitePreferences(t *testing.T) { client, mux, _ := setup(t) a := []*AutoTriggerCheck{{ - AppID: Ptr(int64(2)), - Setting: Ptr(false), + AppID: new(int64(2)), + Setting: new(false), }} opt := CheckSuitePreferenceOptions{AutoTriggerChecks: a} @@ -579,7 +579,7 @@ func TestChecksService_CreateCheckSuite(t *testing.T) { checkSuiteOpt := CreateCheckSuiteOptions{ HeadSHA: "deadbeef", - HeadBranch: Ptr("master"), + HeadBranch: new("master"), } ctx := t.Context() @@ -589,13 +589,13 @@ func TestChecksService_CreateCheckSuite(t *testing.T) { } want := &CheckSuite{ - ID: Ptr(int64(2)), - Status: Ptr("completed"), - HeadSHA: Ptr("deadbeef"), - HeadBranch: Ptr("master"), - Conclusion: Ptr("neutral"), - BeforeSHA: Ptr("deadbeefb"), - AfterSHA: Ptr("deadbeefa"), + ID: new(int64(2)), + Status: new("completed"), + HeadSHA: new("deadbeef"), + HeadBranch: new("master"), + Conclusion: new("neutral"), + BeforeSHA: new("deadbeefb"), + AfterSHA: new("deadbeefa"), } if !cmp.Equal(checkSuite, want) { t.Errorf("Checks.CreateCheckSuite return %+v, want %+v", checkSuite, want) diff --git a/github/classroom_test.go b/github/classroom_test.go index 9cc64b98946..7edef005298 100644 --- a/github/classroom_test.go +++ b/github/classroom_test.go @@ -61,36 +61,36 @@ func TestClassroomService_GetAssignment(t *testing.T) { } want := &ClassroomAssignment{ - ID: Ptr(int64(12)), - PublicRepo: Ptr(false), - Title: Ptr("Intro to Binaries"), - Type: Ptr("individual"), - InviteLink: Ptr("https://example.com/a/Lx7jiUgx"), - InvitationsEnabled: Ptr(true), - Slug: Ptr("intro-to-binaries"), - StudentsAreRepoAdmins: Ptr(false), - FeedbackPullRequestsEnabled: Ptr(true), - MaxTeams: Ptr(0), - MaxMembers: Ptr(0), - Editor: Ptr("codespaces"), - Accepted: Ptr(100), - Submitted: Ptr(40), - Passing: Ptr(10), - Language: Ptr("ruby"), + ID: new(int64(12)), + PublicRepo: new(false), + Title: new("Intro to Binaries"), + Type: new("individual"), + InviteLink: new("https://example.com/a/Lx7jiUgx"), + InvitationsEnabled: new(true), + Slug: new("intro-to-binaries"), + StudentsAreRepoAdmins: new(false), + FeedbackPullRequestsEnabled: new(true), + MaxTeams: new(0), + MaxMembers: new(0), + Editor: new("codespaces"), + Accepted: new(100), + Submitted: new(40), + Passing: new(10), + Language: new("ruby"), Deadline: &referenceTimestamp, StarterCodeRepository: &Repository{ - ID: Ptr(int64(1296269)), - FullName: Ptr("octocat/Hello-World"), - HTMLURL: Ptr("https://example.com/octocat/Hello-World"), - NodeID: Ptr("MDEwOlJlcG9zaXRvcnkxMjk2MjY5"), - Private: Ptr(false), - DefaultBranch: Ptr("main"), + ID: new(int64(1296269)), + FullName: new("octocat/Hello-World"), + HTMLURL: new("https://example.com/octocat/Hello-World"), + NodeID: new("MDEwOlJlcG9zaXRvcnkxMjk2MjY5"), + Private: new(false), + DefaultBranch: new("main"), }, Classroom: &Classroom{ - ID: Ptr(int64(1296269)), - Name: Ptr("Programming Elixir"), - Archived: Ptr(false), - URL: Ptr("https://example.com/classrooms/programming"), + ID: new(int64(1296269)), + Name: new("Programming Elixir"), + Archived: new(false), + URL: new("https://example.com/classrooms/programming"), }, } @@ -142,18 +142,18 @@ func TestClassroomService_GetClassroom(t *testing.T) { } want := &Classroom{ - ID: Ptr(int64(1296269)), - Name: Ptr("Programming Elixir"), - Archived: Ptr(false), + ID: new(int64(1296269)), + Name: new("Programming Elixir"), + Archived: new(false), Organization: &Organization{ - ID: Ptr(int64(1)), - Login: Ptr("programming-elixir"), - NodeID: Ptr("MDEyOk9yZ2FuaXphdGlvbjE="), - HTMLURL: Ptr("https://example.com/programming-elixir"), - Name: Ptr("Learn how to build fault tolerant applications"), - AvatarURL: Ptr("https://example.com/avatars/u/9919?v=4"), + ID: new(int64(1)), + Login: new("programming-elixir"), + NodeID: new("MDEyOk9yZ2FuaXphdGlvbjE="), + HTMLURL: new("https://example.com/programming-elixir"), + Name: new("Learn how to build fault tolerant applications"), + AvatarURL: new("https://example.com/avatars/u/9919?v=4"), }, - URL: Ptr("https://example.com/classrooms/programming"), + URL: new("https://example.com/classrooms/programming"), } if !cmp.Equal(classroom, want) { @@ -207,16 +207,16 @@ func TestClassroomService_ListClassrooms(t *testing.T) { want := []*Classroom{ { - ID: Ptr(int64(1296269)), - Name: Ptr("Programming Elixir"), - Archived: Ptr(false), - URL: Ptr("https://example.com/classrooms/programming"), + ID: new(int64(1296269)), + Name: new("Programming Elixir"), + Archived: new(false), + URL: new("https://example.com/classrooms/programming"), }, { - ID: Ptr(int64(1296270)), - Name: Ptr("Advanced Programming"), - Archived: Ptr(true), - URL: Ptr("https://example.com/classrooms/2-advanced-programming"), + ID: new(int64(1296270)), + Name: new("Advanced Programming"), + Archived: new(true), + URL: new("https://example.com/classrooms/2-advanced-programming"), }, } @@ -304,53 +304,53 @@ func TestClassroomService_ListClassroomAssignments(t *testing.T) { want := []*ClassroomAssignment{ { - ID: Ptr(int64(12)), - PublicRepo: Ptr(false), - Title: Ptr("Intro to Binaries"), - Type: Ptr("individual"), - InviteLink: Ptr("https://example.com/a/Lx7jiUgx"), - InvitationsEnabled: Ptr(true), - Slug: Ptr("intro-to-binaries"), - StudentsAreRepoAdmins: Ptr(false), - FeedbackPullRequestsEnabled: Ptr(true), - MaxTeams: Ptr(0), - MaxMembers: Ptr(0), - Editor: Ptr("codespaces"), - Accepted: Ptr(100), - Submitted: Ptr(40), - Passing: Ptr(10), - Language: Ptr("ruby"), + ID: new(int64(12)), + PublicRepo: new(false), + Title: new("Intro to Binaries"), + Type: new("individual"), + InviteLink: new("https://example.com/a/Lx7jiUgx"), + InvitationsEnabled: new(true), + Slug: new("intro-to-binaries"), + StudentsAreRepoAdmins: new(false), + FeedbackPullRequestsEnabled: new(true), + MaxTeams: new(0), + MaxMembers: new(0), + Editor: new("codespaces"), + Accepted: new(100), + Submitted: new(40), + Passing: new(10), + Language: new("ruby"), Deadline: &referenceTimestamp, Classroom: &Classroom{ - ID: Ptr(int64(1296269)), - Name: Ptr("Programming Elixir"), - Archived: Ptr(false), - URL: Ptr("https://example.com/classrooms/programming"), + ID: new(int64(1296269)), + Name: new("Programming Elixir"), + Archived: new(false), + URL: new("https://example.com/classrooms/programming"), }, }, { - ID: Ptr(int64(13)), - PublicRepo: Ptr(true), - Title: Ptr("Advanced Programming"), - Type: Ptr("group"), - InviteLink: Ptr("https://example.com/a/AdvancedProg"), - InvitationsEnabled: Ptr(true), - Slug: Ptr("advanced-programming"), - StudentsAreRepoAdmins: Ptr(true), - FeedbackPullRequestsEnabled: Ptr(false), - MaxTeams: Ptr(5), - MaxMembers: Ptr(3), - Editor: Ptr("vscode"), - Accepted: Ptr(50), - Submitted: Ptr(25), - Passing: Ptr(20), - Language: Ptr("python"), + ID: new(int64(13)), + PublicRepo: new(true), + Title: new("Advanced Programming"), + Type: new("group"), + InviteLink: new("https://example.com/a/AdvancedProg"), + InvitationsEnabled: new(true), + Slug: new("advanced-programming"), + StudentsAreRepoAdmins: new(true), + FeedbackPullRequestsEnabled: new(false), + MaxTeams: new(5), + MaxMembers: new(3), + Editor: new("vscode"), + Accepted: new(50), + Submitted: new(25), + Passing: new(20), + Language: new("python"), Deadline: &referenceTimestamp, Classroom: &Classroom{ - ID: Ptr(int64(1296269)), - Name: Ptr("Programming Elixir"), - Archived: Ptr(false), - URL: Ptr("https://example.com/classrooms/programming"), + ID: new(int64(1296269)), + Name: new("Programming Elixir"), + Archived: new(false), + URL: new("https://example.com/classrooms/programming"), }, }, } @@ -490,98 +490,98 @@ func TestClassroomService_ListAcceptedAssignments(t *testing.T) { want := []*AcceptedAssignment{ { - ID: Ptr(int64(42)), - Submitted: Ptr(true), - Passing: Ptr(true), - CommitCount: Ptr(5), - Grade: Ptr("10/10"), + ID: new(int64(42)), + Submitted: new(true), + Passing: new(true), + CommitCount: new(5), + Grade: new("10/10"), Students: []*ClassroomUser{ { - ID: Ptr(int64(1)), - Login: Ptr("octocat"), - AvatarURL: Ptr("https://github.com/images/error/octocat_happy.gif"), - HTMLURL: Ptr("https://github.com/octocat"), + ID: new(int64(1)), + Login: new("octocat"), + AvatarURL: new("https://github.com/images/error/octocat_happy.gif"), + HTMLURL: new("https://github.com/octocat"), }, }, Repository: &Repository{ - ID: Ptr(int64(1296269)), - FullName: Ptr("octocat/Hello-World"), - HTMLURL: Ptr("https://github.com/octocat/Hello-World"), - NodeID: Ptr("MDEwOlJlcG9zaXRvcnkxMjk2MjY5"), - Private: Ptr(false), - DefaultBranch: Ptr("main"), + ID: new(int64(1296269)), + FullName: new("octocat/Hello-World"), + HTMLURL: new("https://github.com/octocat/Hello-World"), + NodeID: new("MDEwOlJlcG9zaXRvcnkxMjk2MjY5"), + Private: new(false), + DefaultBranch: new("main"), }, Assignment: &ClassroomAssignment{ - ID: Ptr(int64(12)), - PublicRepo: Ptr(false), - Title: Ptr("Intro to Binaries"), - Type: Ptr("individual"), - InviteLink: Ptr("https://example.com/a/Lx7jiUgx"), - InvitationsEnabled: Ptr(true), - Slug: Ptr("intro-to-binaries"), - StudentsAreRepoAdmins: Ptr(false), - FeedbackPullRequestsEnabled: Ptr(true), - MaxTeams: Ptr(0), - MaxMembers: Ptr(0), - Editor: Ptr("codespaces"), - Accepted: Ptr(100), - Submitted: Ptr(40), - Passing: Ptr(10), - Language: Ptr("ruby"), + ID: new(int64(12)), + PublicRepo: new(false), + Title: new("Intro to Binaries"), + Type: new("individual"), + InviteLink: new("https://example.com/a/Lx7jiUgx"), + InvitationsEnabled: new(true), + Slug: new("intro-to-binaries"), + StudentsAreRepoAdmins: new(false), + FeedbackPullRequestsEnabled: new(true), + MaxTeams: new(0), + MaxMembers: new(0), + Editor: new("codespaces"), + Accepted: new(100), + Submitted: new(40), + Passing: new(10), + Language: new("ruby"), Deadline: &referenceTimestamp, Classroom: &Classroom{ - ID: Ptr(int64(1296269)), - Name: Ptr("Programming Elixir"), - Archived: Ptr(false), - URL: Ptr("https://example.com/classrooms/programming"), + ID: new(int64(1296269)), + Name: new("Programming Elixir"), + Archived: new(false), + URL: new("https://example.com/classrooms/programming"), }, }, }, { - ID: Ptr(int64(43)), - Submitted: Ptr(false), - Passing: Ptr(false), - CommitCount: Ptr(2), - Grade: Ptr("5/10"), + ID: new(int64(43)), + Submitted: new(false), + Passing: new(false), + CommitCount: new(2), + Grade: new("5/10"), Students: []*ClassroomUser{ { - ID: Ptr(int64(2)), - Login: Ptr("monalisa"), - AvatarURL: Ptr("https://github.com/images/error/monalisa_happy.gif"), - HTMLURL: Ptr("https://github.com/monalisa"), + ID: new(int64(2)), + Login: new("monalisa"), + AvatarURL: new("https://github.com/images/error/monalisa_happy.gif"), + HTMLURL: new("https://github.com/monalisa"), }, }, Repository: &Repository{ - ID: Ptr(int64(1296270)), - FullName: Ptr("monalisa/Hello-World"), - HTMLURL: Ptr("https://github.com/monalisa/Hello-World"), - NodeID: Ptr("MDEwOlJlcG9zaXRvcnkxMjk2Mjcw"), - Private: Ptr(true), - DefaultBranch: Ptr("main"), + ID: new(int64(1296270)), + FullName: new("monalisa/Hello-World"), + HTMLURL: new("https://github.com/monalisa/Hello-World"), + NodeID: new("MDEwOlJlcG9zaXRvcnkxMjk2Mjcw"), + Private: new(true), + DefaultBranch: new("main"), }, Assignment: &ClassroomAssignment{ - ID: Ptr(int64(12)), - PublicRepo: Ptr(false), - Title: Ptr("Intro to Binaries"), - Type: Ptr("individual"), - InviteLink: Ptr("https://example.com/a/Lx7jiUgx"), - InvitationsEnabled: Ptr(true), - Slug: Ptr("intro-to-binaries"), - StudentsAreRepoAdmins: Ptr(false), - FeedbackPullRequestsEnabled: Ptr(true), - MaxTeams: Ptr(0), - MaxMembers: Ptr(0), - Editor: Ptr("codespaces"), - Accepted: Ptr(100), - Submitted: Ptr(40), - Passing: Ptr(10), - Language: Ptr("ruby"), + ID: new(int64(12)), + PublicRepo: new(false), + Title: new("Intro to Binaries"), + Type: new("individual"), + InviteLink: new("https://example.com/a/Lx7jiUgx"), + InvitationsEnabled: new(true), + Slug: new("intro-to-binaries"), + StudentsAreRepoAdmins: new(false), + FeedbackPullRequestsEnabled: new(true), + MaxTeams: new(0), + MaxMembers: new(0), + Editor: new("codespaces"), + Accepted: new(100), + Submitted: new(40), + Passing: new(10), + Language: new("ruby"), Deadline: &referenceTimestamp, Classroom: &Classroom{ - ID: Ptr(int64(1296269)), - Name: Ptr("Programming Elixir"), - Archived: Ptr(false), - URL: Ptr("https://example.com/classrooms/programming"), + ID: new(int64(1296269)), + Name: new("Programming Elixir"), + Archived: new(false), + URL: new("https://example.com/classrooms/programming"), }, }, }, @@ -650,30 +650,30 @@ func TestClassroomService_GetAssignmentGrades(t *testing.T) { want := []*AssignmentGrade{ { - AssignmentName: Ptr("Intro to Binaries"), - AssignmentURL: Ptr("https://classroom.github.com/assignments/12"), - StarterCodeURL: Ptr("https://github.com/octocat/Hello-World"), - GithubUsername: Ptr("octocat"), - RosterIdentifier: Ptr("student123"), - StudentRepositoryName: Ptr("octocat/intro-to-binaries"), - StudentRepositoryURL: Ptr("https://github.com/octocat/intro-to-binaries"), + AssignmentName: new("Intro to Binaries"), + AssignmentURL: new("https://classroom.github.com/assignments/12"), + StarterCodeURL: new("https://github.com/octocat/Hello-World"), + GithubUsername: new("octocat"), + RosterIdentifier: new("student123"), + StudentRepositoryName: new("octocat/intro-to-binaries"), + StudentRepositoryURL: new("https://github.com/octocat/intro-to-binaries"), SubmissionTimestamp: &referenceTimestamp, - PointsAwarded: Ptr(10), - PointsAvailable: Ptr(10), - GroupName: Ptr("Team Alpha"), + PointsAwarded: new(10), + PointsAvailable: new(10), + GroupName: new("Team Alpha"), }, { - AssignmentName: Ptr("Intro to Binaries"), - AssignmentURL: Ptr("https://classroom.github.com/assignments/12"), - StarterCodeURL: Ptr("https://github.com/octocat/Hello-World"), - GithubUsername: Ptr("monalisa"), - RosterIdentifier: Ptr("student456"), - StudentRepositoryName: Ptr("monalisa/intro-to-binaries"), - StudentRepositoryURL: Ptr("https://github.com/monalisa/intro-to-binaries"), + AssignmentName: new("Intro to Binaries"), + AssignmentURL: new("https://classroom.github.com/assignments/12"), + StarterCodeURL: new("https://github.com/octocat/Hello-World"), + GithubUsername: new("monalisa"), + RosterIdentifier: new("student456"), + StudentRepositoryName: new("monalisa/intro-to-binaries"), + StudentRepositoryURL: new("https://github.com/monalisa/intro-to-binaries"), SubmissionTimestamp: &referenceTimestamp, - PointsAwarded: Ptr(8), - PointsAvailable: Ptr(10), - GroupName: Ptr("Team Beta"), + PointsAwarded: new(8), + PointsAvailable: new(10), + GroupName: new("Team Beta"), }, } diff --git a/github/code_quality_test.go b/github/code_quality_test.go index 2a90bf85702..673ad2ff134 100644 --- a/github/code_quality_test.go +++ b/github/code_quality_test.go @@ -36,11 +36,11 @@ func TestCodeQualityService_GetSetup(t *testing.T) { } want := &CodeQualitySetupConfiguration{ - State: Ptr("configured"), + State: new("configured"), Languages: []string{"javascript-typescript", "python"}, - RunnerType: Ptr("standard"), + RunnerType: new("standard"), UpdatedAt: &referenceTimestamp, - Schedule: Ptr("weekly"), + Schedule: new("weekly"), } if diff := cmp.Diff(want, cfg); diff != "" { t.Errorf("CodeQuality.GetSetup mismatch (-want +got):\n%v", diff) @@ -66,7 +66,7 @@ func TestCodeQualityService_UpdateSetup(t *testing.T) { client, mux, _ := setup(t) input := &CodeQualityUpdateSetupRequest{ - State: Ptr("configured"), + State: new("configured"), Languages: []string{"javascript-typescript", "python", "ruby"}, } @@ -86,8 +86,8 @@ func TestCodeQualityService_UpdateSetup(t *testing.T) { } want := &CodeQualityUpdateSetupResponse{ - RunID: Ptr(int64(42)), - RunURL: Ptr("https://api.github.com/repos/octocat/hello-world/actions/runs/42"), + RunID: new(int64(42)), + RunURL: new("https://api.github.com/repos/octocat/hello-world/actions/runs/42"), } if diff := cmp.Diff(want, result); diff != "" { t.Errorf("CodeQuality.UpdateSetup mismatch (-want +got):\n%v", diff) @@ -113,9 +113,9 @@ func TestCodeQualityService_UpdateSetup_withRunnerLabel(t *testing.T) { client, mux, _ := setup(t) input := &CodeQualityUpdateSetupRequest{ - State: Ptr("configured"), - RunnerType: Ptr("labeled"), - RunnerLabel: Ptr("my-runner"), + State: new("configured"), + RunnerType: new("labeled"), + RunnerLabel: new("my-runner"), Languages: []string{"go", "python"}, } @@ -135,8 +135,8 @@ func TestCodeQualityService_UpdateSetup_withRunnerLabel(t *testing.T) { } want := &CodeQualityUpdateSetupResponse{ - RunID: Ptr(int64(99)), - RunURL: Ptr("https://api.github.com/repos/octocat/hello-world/actions/runs/99"), + RunID: new(int64(99)), + RunURL: new("https://api.github.com/repos/octocat/hello-world/actions/runs/99"), } if diff := cmp.Diff(want, result); diff != "" { t.Errorf("CodeQuality.UpdateSetup mismatch (-want +got):\n%v", diff) @@ -148,7 +148,7 @@ func TestCodeQualityService_UpdateSetup_notConfigured(t *testing.T) { client, mux, _ := setup(t) input := &CodeQualityUpdateSetupRequest{ - State: Ptr("not-configured"), + State: new("not-configured"), } mux.HandleFunc("/repos/o/r/code-quality/setup", func(w http.ResponseWriter, r *http.Request) { @@ -241,16 +241,16 @@ func TestCodeQualityService_ListFindings(t *testing.T) { ID: "rule-1", Title: "Example Rule", Description: "An example rule description", - Help: Ptr("How to fix it"), + Help: new("How to fix it"), Severity: "warning", Category: "maintainability", }, Location: CodeQualityFindingLocation{ Path: "src/main.go", - StartLine: Ptr(10), - EndLine: Ptr(10), - StartColumn: Ptr(1), - EndColumn: Ptr(20), + StartLine: new(10), + EndLine: new(10), + StartColumn: new(1), + EndColumn: new(20), }, Message: CodeQualityFindingMessage{ Text: "Issue found", @@ -347,8 +347,8 @@ func TestCodeQualityService_GetFinding(t *testing.T) { }, Location: CodeQualityFindingLocation{ Path: "src/main.go", - StartLine: Ptr(5), - EndLine: Ptr(5), + StartLine: new(5), + EndLine: new(5), }, Message: CodeQualityFindingMessage{ Text: "Critical issue", diff --git a/github/code_scanning_test.go b/github/code_scanning_test.go index bc1321db4e2..c4e4a70ccf7 100644 --- a/github/code_scanning_test.go +++ b/github/code_scanning_test.go @@ -26,7 +26,7 @@ func TestCodeScanningService_Alert_ID(t *testing.T) { // Test: Valid HTMLURL a = &Alert{ - HTMLURL: Ptr("https://github.com/o/r/security/code-scanning/88"), + HTMLURL: new("https://github.com/o/r/security/code-scanning/88"), } id = a.ID() want = 88 @@ -44,7 +44,7 @@ func TestCodeScanningService_Alert_ID(t *testing.T) { // Test: ID can't be parsed as an int a = &Alert{ - HTMLURL: Ptr("https://github.com/o/r/security/code-scanning/bad88"), + HTMLURL: new("https://github.com/o/r/security/code-scanning/bad88"), } id = a.ID() want = 0 @@ -58,11 +58,11 @@ func TestCodeScanningService_UploadSarif(t *testing.T) { client, mux, _ := setup(t) expectedSarifID := &SarifID{ - ID: Ptr("testid"), - URL: Ptr("https://example.com/testurl"), + ID: new("testid"), + URL: new("https://example.com/testurl"), } - sarifAnalysis := SarifAnalysis{CommitSHA: "abc", Ref: "ref/head/main", Sarif: "abc", CheckoutURI: Ptr("uri"), StartedAt: &referenceTimestamp, ToolName: Ptr("codeql-cli"), Validate: Ptr(true)} + sarifAnalysis := SarifAnalysis{CommitSHA: "abc", Ref: "ref/head/main", Sarif: "abc", CheckoutURI: new("uri"), StartedAt: &referenceTimestamp, ToolName: new("codeql-cli"), Validate: new(true)} mux.HandleFunc("/repos/o/r/code-scanning/sarifs", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "POST") @@ -112,8 +112,8 @@ func TestCodeScanningService_GetSARIF(t *testing.T) { } want := &SARIFUpload{ - ProcessingStatus: Ptr("s"), - AnalysesURL: Ptr("u"), + ProcessingStatus: new("s"), + AnalysesURL: new("u"), } if !cmp.Equal(sarifUpload, want) { t.Errorf("CodeScanning.GetSARIF returned %+v, want %+v", sarifUpload, want) @@ -242,77 +242,77 @@ func TestCodeScanningService_ListAlertsForOrg(t *testing.T) { want := []*Alert{ { Repository: &Repository{ - ID: Ptr(int64(1)), - URL: Ptr("url"), - Name: Ptr("n"), + ID: new(int64(1)), + URL: new("url"), + Name: new("n"), }, - RuleID: Ptr("js/trivial-conditional"), - RuleSeverity: Ptr("warning"), - RuleDescription: Ptr("Useless conditional"), - Tool: &Tool{Name: Ptr("CodeQL"), GUID: Ptr("guid"), Version: Ptr("1.4.0")}, + RuleID: new("js/trivial-conditional"), + RuleSeverity: new("warning"), + RuleDescription: new("Useless conditional"), + Tool: &Tool{Name: new("CodeQL"), GUID: new("guid"), Version: new("1.4.0")}, Rule: &Rule{ - ID: Ptr("js/trivial-conditional"), - Severity: Ptr("warning"), - Description: Ptr("Useless conditional"), - Name: Ptr("js/trivial-conditional"), - FullDescription: Ptr("Expression has no effect"), - Help: Ptr("Expression has no effect"), + ID: new("js/trivial-conditional"), + Severity: new("warning"), + Description: new("Useless conditional"), + Name: new("js/trivial-conditional"), + FullDescription: new("Expression has no effect"), + Help: new("Expression has no effect"), }, CreatedAt: &referenceTimestamp, - State: Ptr("open"), + State: new("open"), ClosedBy: nil, ClosedAt: nil, - URL: Ptr("https://api.github.com/repos/o/r/code-scanning/alerts/25"), - HTMLURL: Ptr("https://github.com/o/r/security/code-scanning/25"), + URL: new("https://api.github.com/repos/o/r/code-scanning/alerts/25"), + HTMLURL: new("https://github.com/o/r/security/code-scanning/25"), MostRecentInstance: &MostRecentInstance{ - Ref: Ptr("refs/heads/main"), - State: Ptr("open"), - CommitSHA: Ptr("abcdefg12345"), + Ref: new("refs/heads/main"), + State: new("open"), + CommitSHA: new("abcdefg12345"), Message: &Message{ - Text: Ptr("This path depends on a user-provided value."), + Text: new("This path depends on a user-provided value."), }, Location: &Location{ - Path: Ptr("spec-main/api-session-spec.ts"), - StartLine: Ptr(917), - EndLine: Ptr(917), - StartColumn: Ptr(7), - EndColumn: Ptr(18), + Path: new("spec-main/api-session-spec.ts"), + StartLine: new(917), + EndLine: new(917), + StartColumn: new(7), + EndColumn: new(18), }, Classifications: []string{"test"}, }, }, { - RuleID: Ptr("js/useless-expression"), - RuleSeverity: Ptr("warning"), - RuleDescription: Ptr("Expression has no effect"), - Tool: &Tool{Name: Ptr("CodeQL"), GUID: nil, Version: Ptr("1.4.0")}, + RuleID: new("js/useless-expression"), + RuleSeverity: new("warning"), + RuleDescription: new("Expression has no effect"), + Tool: &Tool{Name: new("CodeQL"), GUID: nil, Version: new("1.4.0")}, Rule: &Rule{ - ID: Ptr("js/useless-expression"), - Severity: Ptr("warning"), - Description: Ptr("Expression has no effect"), - Name: Ptr("js/useless-expression"), - FullDescription: Ptr("Expression has no effect"), - Help: Ptr("Expression has no effect"), + ID: new("js/useless-expression"), + Severity: new("warning"), + Description: new("Expression has no effect"), + Name: new("js/useless-expression"), + FullDescription: new("Expression has no effect"), + Help: new("Expression has no effect"), }, CreatedAt: &referenceTimestamp, - State: Ptr("open"), + State: new("open"), ClosedBy: nil, ClosedAt: nil, - URL: Ptr("https://api.github.com/repos/o/r/code-scanning/alerts/88"), - HTMLURL: Ptr("https://github.com/o/r/security/code-scanning/88"), + URL: new("https://api.github.com/repos/o/r/code-scanning/alerts/88"), + HTMLURL: new("https://github.com/o/r/security/code-scanning/88"), MostRecentInstance: &MostRecentInstance{ - Ref: Ptr("refs/heads/main"), - State: Ptr("open"), - CommitSHA: Ptr("abcdefg12345"), + Ref: new("refs/heads/main"), + State: new("open"), + CommitSHA: new("abcdefg12345"), Message: &Message{ - Text: Ptr("This path depends on a user-provided value."), + Text: new("This path depends on a user-provided value."), }, Location: &Location{ - Path: Ptr("spec-main/api-session-spec.ts"), - StartLine: Ptr(917), - EndLine: Ptr(917), - StartColumn: Ptr(7), - EndColumn: Ptr(18), + Path: new("spec-main/api-session-spec.ts"), + StartLine: new(917), + EndLine: new(917), + StartColumn: new(7), + EndColumn: new(18), }, Classifications: []string{"test"}, }, @@ -403,41 +403,41 @@ func TestCodeScanningService_ListAlertsForOrgLisCursorOptions(t *testing.T) { want := []*Alert{ { Repository: &Repository{ - ID: Ptr(int64(1)), - URL: Ptr("url"), - Name: Ptr("n"), + ID: new(int64(1)), + URL: new("url"), + Name: new("n"), }, - RuleID: Ptr("js/trivial-conditional"), - RuleSeverity: Ptr("warning"), - RuleDescription: Ptr("Useless conditional"), - Tool: &Tool{Name: Ptr("CodeQL"), GUID: nil, Version: Ptr("1.4.0")}, + RuleID: new("js/trivial-conditional"), + RuleSeverity: new("warning"), + RuleDescription: new("Useless conditional"), + Tool: &Tool{Name: new("CodeQL"), GUID: nil, Version: new("1.4.0")}, Rule: &Rule{ - ID: Ptr("js/trivial-conditional"), - Severity: Ptr("warning"), - Description: Ptr("Useless conditional"), - Name: Ptr("js/trivial-conditional"), - FullDescription: Ptr("Expression has no effect"), - Help: Ptr("Expression has no effect"), + ID: new("js/trivial-conditional"), + Severity: new("warning"), + Description: new("Useless conditional"), + Name: new("js/trivial-conditional"), + FullDescription: new("Expression has no effect"), + Help: new("Expression has no effect"), }, CreatedAt: &referenceTimestamp, - State: Ptr("open"), + State: new("open"), ClosedBy: nil, ClosedAt: nil, - URL: Ptr("https://api.github.com/repos/o/r/code-scanning/alerts/25"), - HTMLURL: Ptr("https://github.com/o/r/security/code-scanning/25"), + URL: new("https://api.github.com/repos/o/r/code-scanning/alerts/25"), + HTMLURL: new("https://github.com/o/r/security/code-scanning/25"), MostRecentInstance: &MostRecentInstance{ - Ref: Ptr("refs/heads/main"), - State: Ptr("open"), - CommitSHA: Ptr("abcdefg12345"), + Ref: new("refs/heads/main"), + State: new("open"), + CommitSHA: new("abcdefg12345"), Message: &Message{ - Text: Ptr("This path depends on a user-provided value."), + Text: new("This path depends on a user-provided value."), }, Location: &Location{ - Path: Ptr("spec-main/api-session-spec.ts"), - StartLine: Ptr(917), - EndLine: Ptr(917), - StartColumn: Ptr(7), - EndColumn: Ptr(18), + Path: new("spec-main/api-session-spec.ts"), + StartLine: new(917), + EndLine: new(917), + StartColumn: new(7), + EndColumn: new(18), }, Classifications: []string{"test"}, }, @@ -564,73 +564,73 @@ func TestCodeScanningService_ListAlertsForRepo(t *testing.T) { want := []*Alert{ { - RuleID: Ptr("js/trivial-conditional"), - RuleSeverity: Ptr("warning"), - RuleDescription: Ptr("Useless conditional"), - Tool: &Tool{Name: Ptr("CodeQL"), GUID: Ptr("guid"), Version: Ptr("1.4.0")}, + RuleID: new("js/trivial-conditional"), + RuleSeverity: new("warning"), + RuleDescription: new("Useless conditional"), + Tool: &Tool{Name: new("CodeQL"), GUID: new("guid"), Version: new("1.4.0")}, Rule: &Rule{ - ID: Ptr("js/trivial-conditional"), - Severity: Ptr("warning"), - Description: Ptr("Useless conditional"), - Name: Ptr("js/trivial-conditional"), - FullDescription: Ptr("Expression has no effect"), - Help: Ptr("Expression has no effect"), + ID: new("js/trivial-conditional"), + Severity: new("warning"), + Description: new("Useless conditional"), + Name: new("js/trivial-conditional"), + FullDescription: new("Expression has no effect"), + Help: new("Expression has no effect"), }, CreatedAt: &referenceTimestamp, - State: Ptr("open"), + State: new("open"), ClosedBy: nil, ClosedAt: nil, - URL: Ptr("https://api.github.com/repos/o/r/code-scanning/alerts/25"), - HTMLURL: Ptr("https://github.com/o/r/security/code-scanning/25"), + URL: new("https://api.github.com/repos/o/r/code-scanning/alerts/25"), + HTMLURL: new("https://github.com/o/r/security/code-scanning/25"), MostRecentInstance: &MostRecentInstance{ - Ref: Ptr("refs/heads/main"), - State: Ptr("open"), - CommitSHA: Ptr("abcdefg12345"), + Ref: new("refs/heads/main"), + State: new("open"), + CommitSHA: new("abcdefg12345"), Message: &Message{ - Text: Ptr("This path depends on a user-provided value."), + Text: new("This path depends on a user-provided value."), }, Location: &Location{ - Path: Ptr("spec-main/api-session-spec.ts"), - StartLine: Ptr(917), - EndLine: Ptr(917), - StartColumn: Ptr(7), - EndColumn: Ptr(18), + Path: new("spec-main/api-session-spec.ts"), + StartLine: new(917), + EndLine: new(917), + StartColumn: new(7), + EndColumn: new(18), }, Classifications: []string{"test"}, }, }, { - RuleID: Ptr("js/useless-expression"), - RuleSeverity: Ptr("warning"), - RuleDescription: Ptr("Expression has no effect"), - Tool: &Tool{Name: Ptr("CodeQL"), GUID: Ptr("guid"), Version: Ptr("1.4.0")}, + RuleID: new("js/useless-expression"), + RuleSeverity: new("warning"), + RuleDescription: new("Expression has no effect"), + Tool: &Tool{Name: new("CodeQL"), GUID: new("guid"), Version: new("1.4.0")}, Rule: &Rule{ - ID: Ptr("js/useless-expression"), - Severity: Ptr("warning"), - Description: Ptr("Expression has no effect"), - Name: Ptr("js/useless-expression"), - FullDescription: Ptr("Expression has no effect"), - Help: Ptr("Expression has no effect"), + ID: new("js/useless-expression"), + Severity: new("warning"), + Description: new("Expression has no effect"), + Name: new("js/useless-expression"), + FullDescription: new("Expression has no effect"), + Help: new("Expression has no effect"), }, CreatedAt: &referenceTimestamp, - State: Ptr("open"), + State: new("open"), ClosedBy: nil, ClosedAt: nil, - URL: Ptr("https://api.github.com/repos/o/r/code-scanning/alerts/88"), - HTMLURL: Ptr("https://github.com/o/r/security/code-scanning/88"), + URL: new("https://api.github.com/repos/o/r/code-scanning/alerts/88"), + HTMLURL: new("https://github.com/o/r/security/code-scanning/88"), MostRecentInstance: &MostRecentInstance{ - Ref: Ptr("refs/heads/main"), - State: Ptr("open"), - CommitSHA: Ptr("abcdefg12345"), + Ref: new("refs/heads/main"), + State: new("open"), + CommitSHA: new("abcdefg12345"), Message: &Message{ - Text: Ptr("This path depends on a user-provided value."), + Text: new("This path depends on a user-provided value."), }, Location: &Location{ - Path: Ptr("spec-main/api-session-spec.ts"), - StartLine: Ptr(917), - EndLine: Ptr(917), - StartColumn: Ptr(7), - EndColumn: Ptr(18), + Path: new("spec-main/api-session-spec.ts"), + StartLine: new(917), + EndLine: new(917), + StartColumn: new(7), + EndColumn: new(18), }, Classifications: []string{"test"}, }, @@ -706,9 +706,9 @@ func TestCodeScanningService_UpdateAlert(t *testing.T) { }) ctx := t.Context() - dismissedComment := Ptr("This alert is not actually correct as sanitizer is used") - dismissedReason := Ptr("false positive") - state := Ptr("dismissed") + dismissedComment := new("This alert is not actually correct as sanitizer is used") + dismissedReason := new("false positive") + state := new("dismissed") stateInfo := &CodeScanningAlertState{State: *state, DismissedReason: dismissedReason, DismissedComment: dismissedComment} alert, _, err := client.CodeScanning.UpdateAlert(ctx, "o", "r", 88, stateInfo) if err != nil { @@ -716,17 +716,17 @@ func TestCodeScanningService_UpdateAlert(t *testing.T) { } want := &Alert{ - RuleID: Ptr("js/useless-expression"), - RuleSeverity: Ptr("warning"), - RuleDescription: Ptr("Expression has no effect"), - Tool: &Tool{Name: Ptr("CodeQL"), GUID: nil, Version: Ptr("1.4.0")}, + RuleID: new("js/useless-expression"), + RuleSeverity: new("warning"), + RuleDescription: new("Expression has no effect"), + Tool: &Tool{Name: new("CodeQL"), GUID: nil, Version: new("1.4.0")}, Rule: &Rule{ - ID: Ptr("useless expression"), - Severity: Ptr("warning"), - Description: Ptr("Expression has no effect"), - Name: Ptr("useless expression"), - FullDescription: Ptr("Expression has no effect"), - Help: Ptr("Expression has no effect"), + ID: new("useless expression"), + Severity: new("warning"), + Description: new("Expression has no effect"), + Name: new("useless expression"), + FullDescription: new("Expression has no effect"), + Help: new("Expression has no effect"), }, CreatedAt: &referenceTimestamp, State: state, @@ -734,21 +734,21 @@ func TestCodeScanningService_UpdateAlert(t *testing.T) { DismissedComment: dismissedComment, ClosedBy: nil, ClosedAt: nil, - URL: Ptr("https://api.github.com/repos/o/r/code-scanning/alerts/88"), - HTMLURL: Ptr("https://github.com/o/r/security/code-scanning/88"), + URL: new("https://api.github.com/repos/o/r/code-scanning/alerts/88"), + HTMLURL: new("https://github.com/o/r/security/code-scanning/88"), MostRecentInstance: &MostRecentInstance{ - Ref: Ptr("refs/heads/main"), - State: Ptr("dismissed"), - CommitSHA: Ptr("abcdefg12345"), + Ref: new("refs/heads/main"), + State: new("dismissed"), + CommitSHA: new("abcdefg12345"), Message: &Message{ - Text: Ptr("This path depends on a user-provided value."), + Text: new("This path depends on a user-provided value."), }, Location: &Location{ - Path: Ptr("spec-main/api-session-spec.ts"), - StartLine: Ptr(917), - EndLine: Ptr(917), - StartColumn: Ptr(7), - EndColumn: Ptr(18), + Path: new("spec-main/api-session-spec.ts"), + StartLine: new(917), + EndLine: new(917), + StartColumn: new(7), + EndColumn: new(18), }, Classifications: []string{"test"}, }, @@ -813,21 +813,21 @@ func TestCodeScanningService_ListAlertInstances(t *testing.T) { want := []*MostRecentInstance{ { - Ref: Ptr("refs/heads/main"), - AnalysisKey: Ptr(".github/workflows/codeql-analysis.yml:analyze"), - Category: Ptr(".github/workflows/codeql-analysis.yml:analyze"), - Environment: Ptr(""), - State: Ptr("open"), - CommitSHA: Ptr("abcdefg12345"), + Ref: new("refs/heads/main"), + AnalysisKey: new(".github/workflows/codeql-analysis.yml:analyze"), + Category: new(".github/workflows/codeql-analysis.yml:analyze"), + Environment: new(""), + State: new("open"), + CommitSHA: new("abcdefg12345"), Message: &Message{ - Text: Ptr("This path depends on a user-provided value."), + Text: new("This path depends on a user-provided value."), }, Location: &Location{ - Path: Ptr("spec-main/api-session-spec.ts"), - StartLine: Ptr(917), - EndLine: Ptr(917), - StartColumn: Ptr(7), - EndColumn: Ptr(18), + Path: new("spec-main/api-session-spec.ts"), + StartLine: new(917), + EndLine: new(917), + StartColumn: new(7), + EndColumn: new(18), }, Classifications: []string{"test"}, }, @@ -908,37 +908,37 @@ func TestCodeScanningService_GetAlert(t *testing.T) { } want := &Alert{ - RuleID: Ptr("js/useless-expression"), - RuleSeverity: Ptr("warning"), - RuleDescription: Ptr("Expression has no effect"), - Tool: &Tool{Name: Ptr("CodeQL"), GUID: nil, Version: Ptr("1.4.0")}, + RuleID: new("js/useless-expression"), + RuleSeverity: new("warning"), + RuleDescription: new("Expression has no effect"), + Tool: &Tool{Name: new("CodeQL"), GUID: nil, Version: new("1.4.0")}, Rule: &Rule{ - ID: Ptr("useless expression"), - Severity: Ptr("warning"), - Description: Ptr("Expression has no effect"), - Name: Ptr("useless expression"), - FullDescription: Ptr("Expression has no effect"), - Help: Ptr("Expression has no effect"), + ID: new("useless expression"), + Severity: new("warning"), + Description: new("Expression has no effect"), + Name: new("useless expression"), + FullDescription: new("Expression has no effect"), + Help: new("Expression has no effect"), }, CreatedAt: &referenceTimestamp, - State: Ptr("open"), + State: new("open"), ClosedBy: nil, ClosedAt: nil, - URL: Ptr("https://api.github.com/repos/o/r/code-scanning/alerts/88"), - HTMLURL: Ptr("https://github.com/o/r/security/code-scanning/88"), + URL: new("https://api.github.com/repos/o/r/code-scanning/alerts/88"), + HTMLURL: new("https://github.com/o/r/security/code-scanning/88"), MostRecentInstance: &MostRecentInstance{ - Ref: Ptr("refs/heads/main"), - State: Ptr("open"), - CommitSHA: Ptr("abcdefg12345"), + Ref: new("refs/heads/main"), + State: new("open"), + CommitSHA: new("abcdefg12345"), Message: &Message{ - Text: Ptr("This path depends on a user-provided value."), + Text: new("This path depends on a user-provided value."), }, Location: &Location{ - Path: Ptr("spec-main/api-session-spec.ts"), - StartLine: Ptr(917), - EndLine: Ptr(917), - StartColumn: Ptr(7), - EndColumn: Ptr(18), + Path: new("spec-main/api-session-spec.ts"), + StartLine: new(917), + EndLine: new(917), + StartColumn: new(7), + EndColumn: new(18), }, Classifications: []string{"test"}, }, @@ -1015,7 +1015,7 @@ func TestCodeScanningService_ListAnalysesForRepo(t *testing.T) { ]`) }) - opts := &AnalysesListOptions{SarifID: Ptr("8981cd8e-b078-4ac3-a3be-1dad7dbd0b582"), Ref: Ptr("heads/master")} + opts := &AnalysesListOptions{SarifID: new("8981cd8e-b078-4ac3-a3be-1dad7dbd0b582"), Ref: new("heads/master")} ctx := t.Context() analyses, _, err := client.CodeScanning.ListAnalysesForRepo(ctx, "o", "r", opts) if err != nil { @@ -1024,46 +1024,46 @@ func TestCodeScanningService_ListAnalysesForRepo(t *testing.T) { want := []*ScanningAnalysis{ { - ID: Ptr(int64(201)), - Ref: Ptr("refs/heads/main"), - CommitSHA: Ptr("d99612c3e1f2970085cfbaeadf8f010ef69bad83"), - AnalysisKey: Ptr(".github/workflows/codeql-analysis.yml:analyze"), - Environment: Ptr("{\"language\":\"python\"}"), - Error: Ptr(""), - Category: Ptr(".github/workflows/codeql-analysis.yml:analyze/language:python"), + ID: new(int64(201)), + Ref: new("refs/heads/main"), + CommitSHA: new("d99612c3e1f2970085cfbaeadf8f010ef69bad83"), + AnalysisKey: new(".github/workflows/codeql-analysis.yml:analyze"), + Environment: new("{\"language\":\"python\"}"), + Error: new(""), + Category: new(".github/workflows/codeql-analysis.yml:analyze/language:python"), CreatedAt: &referenceTimestamp, - ResultsCount: Ptr(17), - RulesCount: Ptr(49), - URL: Ptr("https://api.github.com/repos/o/r/code-scanning/analyses/201"), - SarifID: Ptr("8981cd8e-b078-4ac3-a3be-1dad7dbd0b582"), + ResultsCount: new(17), + RulesCount: new(49), + URL: new("https://api.github.com/repos/o/r/code-scanning/analyses/201"), + SarifID: new("8981cd8e-b078-4ac3-a3be-1dad7dbd0b582"), Tool: &Tool{ - Name: Ptr("CodeQL"), + Name: new("CodeQL"), GUID: nil, - Version: Ptr("2.4.0"), + Version: new("2.4.0"), }, - Deletable: Ptr(true), - Warning: Ptr(""), + Deletable: new(true), + Warning: new(""), }, { - ID: Ptr(int64(200)), - Ref: Ptr("refs/heads/my-branch"), - CommitSHA: Ptr("c8cff6510d4d084fb1b4aa13b64b97ca12b07321"), - AnalysisKey: Ptr(".github/workflows/shiftleft.yml:build"), - Environment: Ptr("{}"), - Error: Ptr(""), - Category: Ptr(".github/workflows/shiftleft.yml:build/"), + ID: new(int64(200)), + Ref: new("refs/heads/my-branch"), + CommitSHA: new("c8cff6510d4d084fb1b4aa13b64b97ca12b07321"), + AnalysisKey: new(".github/workflows/shiftleft.yml:build"), + Environment: new("{}"), + Error: new(""), + Category: new(".github/workflows/shiftleft.yml:build/"), CreatedAt: &referenceTimestamp, - ResultsCount: Ptr(17), - RulesCount: Ptr(32), - URL: Ptr("https://api.github.com/repos/o/r/code-scanning/analyses/200"), - SarifID: Ptr("8981cd8e-b078-4ac3-a3be-1dad7dbd0b582"), + ResultsCount: new(17), + RulesCount: new(32), + URL: new("https://api.github.com/repos/o/r/code-scanning/analyses/200"), + SarifID: new("8981cd8e-b078-4ac3-a3be-1dad7dbd0b582"), Tool: &Tool{ - Name: Ptr("Python Security ScanningAnalysis"), + Name: new("Python Security ScanningAnalysis"), GUID: nil, - Version: Ptr("1.2.0"), + Version: new("1.2.0"), }, - Deletable: Ptr(true), - Warning: Ptr(""), + Deletable: new(true), + Warning: new(""), }, } if !cmp.Equal(analyses, want) { @@ -1121,25 +1121,25 @@ func TestCodeScanningService_GetAnalysis(t *testing.T) { } want := &ScanningAnalysis{ - ID: Ptr(int64(3602840)), - Ref: Ptr("refs/heads/main"), - CommitSHA: Ptr("c18c69115654ff0166991962832dc2bd7756e655"), - AnalysisKey: Ptr(".github/workflows/codeql-analysis.yml:analyze"), - Environment: Ptr("{\"language\":\"javascript\"}"), - Error: Ptr(""), - Category: Ptr(".github/workflows/codeql-analysis.yml:analyze/language:javascript"), + ID: new(int64(3602840)), + Ref: new("refs/heads/main"), + CommitSHA: new("c18c69115654ff0166991962832dc2bd7756e655"), + AnalysisKey: new(".github/workflows/codeql-analysis.yml:analyze"), + Environment: new("{\"language\":\"javascript\"}"), + Error: new(""), + Category: new(".github/workflows/codeql-analysis.yml:analyze/language:javascript"), CreatedAt: &referenceTimestamp, - ResultsCount: Ptr(3), - RulesCount: Ptr(67), - URL: Ptr("https://api.github.com/repos/o/r/code-scanning/analyses/201"), - SarifID: Ptr("47177e22-5596-11eb-80a1-c1e54ef945c6"), + ResultsCount: new(3), + RulesCount: new(67), + URL: new("https://api.github.com/repos/o/r/code-scanning/analyses/201"), + SarifID: new("47177e22-5596-11eb-80a1-c1e54ef945c6"), Tool: &Tool{ - Name: Ptr("CodeQL"), + Name: new("CodeQL"), GUID: nil, - Version: Ptr("2.4.0"), + Version: new("2.4.0"), }, - Deletable: Ptr(true), - Warning: Ptr(""), + Deletable: new(true), + Warning: new(""), } if !cmp.Equal(analysis, want) { t.Errorf("CodeScanning.GetAnalysis returned %+v, want %+v", analysis, want) @@ -1179,8 +1179,8 @@ func TestCodeScanningService_DeleteAnalysis(t *testing.T) { } want := &DeleteAnalysis{ - NextAnalysisURL: Ptr("a"), - ConfirmDeleteURL: Ptr("b"), + NextAnalysisURL: new("a"), + ConfirmDeleteURL: new("b"), } if !cmp.Equal(analysis, want) { t.Errorf("CodeScanning.DeleteAnalysis returned %+v, want %+v", analysis, want) @@ -1249,34 +1249,34 @@ func TestCodeScanningService_ListCodeQLDatabases(t *testing.T) { want := []*CodeQLDatabase{ { - ID: Ptr(int64(1)), - Name: Ptr("name"), - Language: Ptr("language"), + ID: new(int64(1)), + Name: new("name"), + Language: new("language"), Uploader: &User{ - Login: Ptr("a"), - ID: Ptr(int64(1)), - NodeID: Ptr("b"), - AvatarURL: Ptr("c"), - GravatarID: Ptr("d"), - URL: Ptr("e"), - HTMLURL: Ptr("f"), - FollowersURL: Ptr("g"), - FollowingURL: Ptr("h"), - GistsURL: Ptr("i"), - StarredURL: Ptr("j"), - SubscriptionsURL: Ptr("k"), - OrganizationsURL: Ptr("l"), - ReposURL: Ptr("m"), - EventsURL: Ptr("n"), - ReceivedEventsURL: Ptr("o"), - Type: Ptr("p"), - SiteAdmin: Ptr(false), + Login: new("a"), + ID: new(int64(1)), + NodeID: new("b"), + AvatarURL: new("c"), + GravatarID: new("d"), + URL: new("e"), + HTMLURL: new("f"), + FollowersURL: new("g"), + FollowingURL: new("h"), + GistsURL: new("i"), + StarredURL: new("j"), + SubscriptionsURL: new("k"), + OrganizationsURL: new("l"), + ReposURL: new("m"), + EventsURL: new("n"), + ReceivedEventsURL: new("o"), + Type: new("p"), + SiteAdmin: new(false), }, - ContentType: Ptr("r"), - Size: Ptr(int64(1024)), + ContentType: new("r"), + Size: new(int64(1024)), CreatedAt: refTimestamp(1136178000), UpdatedAt: refTimestamp(1136178001), - URL: Ptr("s"), + URL: new("s"), }, } @@ -1344,34 +1344,34 @@ func TestCodeScanningService_GetCodeQLDatabase(t *testing.T) { } want := &CodeQLDatabase{ - ID: Ptr(int64(1)), - Name: Ptr("name"), - Language: Ptr("language"), + ID: new(int64(1)), + Name: new("name"), + Language: new("language"), Uploader: &User{ - Login: Ptr("a"), - ID: Ptr(int64(1)), - NodeID: Ptr("b"), - AvatarURL: Ptr("c"), - GravatarID: Ptr("d"), - URL: Ptr("e"), - HTMLURL: Ptr("f"), - FollowersURL: Ptr("g"), - FollowingURL: Ptr("h"), - GistsURL: Ptr("i"), - StarredURL: Ptr("j"), - SubscriptionsURL: Ptr("k"), - OrganizationsURL: Ptr("l"), - ReposURL: Ptr("m"), - EventsURL: Ptr("n"), - ReceivedEventsURL: Ptr("o"), - Type: Ptr("p"), - SiteAdmin: Ptr(false), + Login: new("a"), + ID: new(int64(1)), + NodeID: new("b"), + AvatarURL: new("c"), + GravatarID: new("d"), + URL: new("e"), + HTMLURL: new("f"), + FollowersURL: new("g"), + FollowingURL: new("h"), + GistsURL: new("i"), + StarredURL: new("j"), + SubscriptionsURL: new("k"), + OrganizationsURL: new("l"), + ReposURL: new("m"), + EventsURL: new("n"), + ReceivedEventsURL: new("o"), + Type: new("p"), + SiteAdmin: new(false), }, - ContentType: Ptr("r"), - Size: Ptr(int64(1024)), + ContentType: new("r"), + Size: new(int64(1024)), CreatedAt: refTimestamp(1136178000), UpdatedAt: refTimestamp(1136178001), - URL: Ptr("s"), + URL: new("s"), } if !cmp.Equal(database, want) { @@ -1447,9 +1447,9 @@ func TestCodeScanningService_GetDefaultSetupConfiguration(t *testing.T) { } want := &DefaultSetupConfiguration{ - State: Ptr("configured"), + State: new("configured"), Languages: []string{"javascript", "javascript-typescript", "typescript"}, - QuerySuite: Ptr("default"), + QuerySuite: new("default"), UpdatedAt: &referenceTimestamp, } if !cmp.Equal(cfg, want) { @@ -1490,7 +1490,7 @@ func TestCodeScanningService_UpdateDefaultSetupConfiguration(t *testing.T) { options := &UpdateDefaultSetupConfigurationOptions{ State: "configured", Languages: []string{"go"}, - QuerySuite: Ptr("default"), + QuerySuite: new("default"), } got, _, err := client.CodeScanning.UpdateDefaultSetupConfiguration(ctx, "o", "r", options) if err != nil { @@ -1498,8 +1498,8 @@ func TestCodeScanningService_UpdateDefaultSetupConfiguration(t *testing.T) { } want := &UpdateDefaultSetupConfigurationResponse{ - RunID: Ptr(int64(5301214200)), - RunURL: Ptr("https://api.github.com/repos/o/r/actions/runs/5301214200"), + RunID: new(int64(5301214200)), + RunURL: new("https://api.github.com/repos/o/r/actions/runs/5301214200"), } if !cmp.Equal(got, want) { t.Errorf("CodeScanning.UpdateDefaultSetupConfiguration returned %+v, want %+v", got, want) diff --git a/github/codesofconduct_test.go b/github/codesofconduct_test.go index 281eb8d5749..f8598a622ba 100644 --- a/github/codesofconduct_test.go +++ b/github/codesofconduct_test.go @@ -33,9 +33,9 @@ func TestCodesOfConductService_List(t *testing.T) { want := []*CodeOfConduct{ { - Key: Ptr("key"), - Name: Ptr("name"), - URL: Ptr("url"), + Key: new("key"), + Name: new("name"), + URL: new("url"), }, } if !cmp.Equal(want, cs) { @@ -72,10 +72,10 @@ func TestCodesOfConductService_Get(t *testing.T) { assertNilError(t, err) want := &CodeOfConduct{ - Key: Ptr("key"), - Name: Ptr("name"), - URL: Ptr("url"), - Body: Ptr("body"), + Key: new("key"), + Name: new("name"), + URL: new("url"), + Body: new("body"), } if !cmp.Equal(want, coc) { t.Errorf("returned %+v, want %+v", coc, want) diff --git a/github/codespaces_machines_test.go b/github/codespaces_machines_test.go index d413d168b93..1dd422ec70c 100644 --- a/github/codespaces_machines_test.go +++ b/github/codespaces_machines_test.go @@ -42,9 +42,9 @@ func TestCodespacesService_ListRepositoryMachineTypes(t *testing.T) { ctx := t.Context() opts := &ListRepoMachineTypesOptions{ - Ref: Ptr("main"), - Location: Ptr("WestUs2"), - ClientIP: Ptr("1.2.3.4"), + Ref: new("main"), + Location: new("WestUs2"), + ClientIP: new("1.2.3.4"), } got, _, err := client.Codespaces.ListRepositoryMachineTypes( @@ -61,13 +61,13 @@ func TestCodespacesService_ListRepositoryMachineTypes(t *testing.T) { TotalCount: 1, Machines: []*CodespacesMachine{ { - Name: Ptr("standardLinux"), - DisplayName: Ptr("4 cores, 8 GB RAM, 64 GB storage"), - OperatingSystem: Ptr("linux"), - StorageInBytes: Ptr(int64(68719476736)), - MemoryInBytes: Ptr(int64(17179869184)), - CPUs: Ptr(4), - PrebuildAvailability: Ptr("ready"), + Name: new("standardLinux"), + DisplayName: new("4 cores, 8 GB RAM, 64 GB storage"), + OperatingSystem: new("linux"), + StorageInBytes: new(int64(68719476736)), + MemoryInBytes: new(int64(17179869184)), + CPUs: new(4), + PrebuildAvailability: new("ready"), }, }, } @@ -123,13 +123,13 @@ func TestCodespacesService_ListCodespaceMachineTypes(t *testing.T) { TotalCount: 1, Machines: []*CodespacesMachine{ { - Name: Ptr("standardLinux"), - DisplayName: Ptr("4 cores, 8 GB RAM, 64 GB storage"), - OperatingSystem: Ptr("linux"), - StorageInBytes: Ptr(int64(68719476736)), - MemoryInBytes: Ptr(int64(17179869184)), - CPUs: Ptr(4), - PrebuildAvailability: Ptr("ready"), + Name: new("standardLinux"), + DisplayName: new("4 cores, 8 GB RAM, 64 GB storage"), + OperatingSystem: new("linux"), + StorageInBytes: new(int64(68719476736)), + MemoryInBytes: new(int64(17179869184)), + CPUs: new(4), + PrebuildAvailability: new("ready"), }, }, } diff --git a/github/codespaces_orgs_test.go b/github/codespaces_orgs_test.go index f0661628eb2..fa18acbdc88 100644 --- a/github/codespaces_orgs_test.go +++ b/github/codespaces_orgs_test.go @@ -30,9 +30,9 @@ func TestCodespacesService_ListInOrg(t *testing.T) { } want := &ListCodespaces{ - TotalCount: Ptr(1), + TotalCount: new(1), Codespaces: []*Codespace{ - {ID: Ptr(int64(1))}, + {ID: new(int64(1))}, }, } @@ -171,9 +171,9 @@ func TestCodespacesService_ListUserCodespacesInOrg(t *testing.T) { } want := &ListCodespaces{ - TotalCount: Ptr(1), + TotalCount: new(1), Codespaces: []*Codespace{ - {ID: Ptr(int64(1))}, + {ID: new(int64(1))}, }, } diff --git a/github/codespaces_secrets_test.go b/github/codespaces_secrets_test.go index d495b7003d5..7ed53c41daa 100644 --- a/github/codespaces_secrets_test.go +++ b/github/codespaces_secrets_test.go @@ -466,7 +466,7 @@ func TestCodespacesService_GetPublicKey(t *testing.T) { t.Errorf("Codespaces.%v returned error: %v", tt.methodName, err) } - want := &PublicKey{KeyID: Ptr("1234"), Key: Ptr("2Sg8iYjAxxmI2LvUXpJjkYrMxURPc8r+dB7TJyvv1234")} + want := &PublicKey{KeyID: new("1234"), Key: new("2Sg8iYjAxxmI2LvUXpJjkYrMxURPc8r+dB7TJyvv1234")} if !cmp.Equal(key, want) { t.Errorf("Codespaces.%v returned %+v, want %+v", tt.methodName, key, want) } @@ -545,9 +545,9 @@ func TestCodespacesService_ListSelectedReposForSecret(t *testing.T) { } want := &SelectedReposList{ - TotalCount: Ptr(1), + TotalCount: new(1), Repositories: []*Repository{ - {ID: Ptr(int64(1))}, + {ID: new(int64(1))}, }, } @@ -659,7 +659,7 @@ func TestCodespacesService_AddSelectedReposForSecret(t *testing.T) { badCall func(context.Context, *Client) (*Response, error) methodName string } - repo := &Repository{ID: Ptr(int64(1234))} + repo := &Repository{ID: new(int64(1234))} tests := []*test{ { name: "User", @@ -729,7 +729,7 @@ func TestCodespacesService_RemoveSelectedReposFromSecret(t *testing.T) { badCall func(context.Context, *Client) (*Response, error) methodName string } - repo := &Repository{ID: Ptr(int64(1234))} + repo := &Repository{ID: new(int64(1234))} tests := []*test{ { name: "User", diff --git a/github/codespaces_test.go b/github/codespaces_test.go index 7be8eb434f8..709de4bc6ec 100644 --- a/github/codespaces_test.go +++ b/github/codespaces_test.go @@ -33,55 +33,55 @@ func TestCodespacesService_ListInRepo(t *testing.T) { t.Errorf("Codespaces.ListInRepo returned error: %v", err) } - want := &ListCodespaces{TotalCount: Ptr(2), Codespaces: []*Codespace{ + want := &ListCodespaces{TotalCount: new(2), Codespaces: []*Codespace{ { - ID: Ptr(int64(1)), - Name: Ptr("monalisa-octocat-hello-world-g4wpq6h95q"), - EnvironmentID: Ptr("26a7c758-7299-4a73-b978-5a92a7ae98a0"), + ID: new(int64(1)), + Name: new("monalisa-octocat-hello-world-g4wpq6h95q"), + EnvironmentID: new("26a7c758-7299-4a73-b978-5a92a7ae98a0"), Owner: &User{ - Login: Ptr("octocat"), + Login: new("octocat"), }, BillableOwner: &User{ - Login: Ptr("octocat"), + Login: new("octocat"), }, Repository: &Repository{ - ID: Ptr(int64(1296269)), + ID: new(int64(1296269)), }, Machine: &CodespacesMachine{ - Name: Ptr("standardLinux"), - DisplayName: Ptr("4 cores, 8 GB RAM, 64 GB storage"), - OperatingSystem: Ptr("linux"), - StorageInBytes: Ptr(int64(68719476736)), - MemoryInBytes: Ptr(int64(8589934592)), - CPUs: Ptr(4), + Name: new("standardLinux"), + DisplayName: new("4 cores, 8 GB RAM, 64 GB storage"), + OperatingSystem: new("linux"), + StorageInBytes: new(int64(68719476736)), + MemoryInBytes: new(int64(8589934592)), + CPUs: new(4), }, - Prebuild: Ptr(false), - DevcontainerPath: Ptr(".devcontainer/devcontainer.json"), + Prebuild: new(false), + DevcontainerPath: new(".devcontainer/devcontainer.json"), CreatedAt: refTimestamp(1136178000), UpdatedAt: refTimestamp(1136178001), LastUsedAt: refTimestamp(1136178002), - State: Ptr("Available"), - URL: Ptr("https://api.github.com/user/codespaces/monalisa-octocat-hello-world-g4wpq6h95q"), + State: new("Available"), + URL: new("https://api.github.com/user/codespaces/monalisa-octocat-hello-world-g4wpq6h95q"), GitStatus: &CodespacesGitStatus{ - Ahead: Ptr(0), - Behind: Ptr(0), - HasUnpushedChanges: Ptr(false), - HasUncommittedChanges: Ptr(false), - Ref: Ptr("main"), + Ahead: new(0), + Behind: new(0), + HasUnpushedChanges: new(false), + HasUncommittedChanges: new(false), + Ref: new("main"), }, - Location: Ptr("WestUs2"), - IdleTimeoutMinutes: Ptr(60), - WebURL: Ptr("https://monalisa-octocat-hello-world-g4wpq6h95q.github.dev"), - MachinesURL: Ptr("https://api.github.com/user/codespaces/monalisa-octocat-hello-world-g4wpq6h95q/machines"), - StartURL: Ptr("https://api.github.com/user/codespaces/monalisa-octocat-hello-world-g4wpq6h95q/start"), - StopURL: Ptr("https://api.github.com/user/codespaces/monalisa-octocat-hello-world-g4wpq6h95q/stop"), + Location: new("WestUs2"), + IdleTimeoutMinutes: new(60), + WebURL: new("https://monalisa-octocat-hello-world-g4wpq6h95q.github.dev"), + MachinesURL: new("https://api.github.com/user/codespaces/monalisa-octocat-hello-world-g4wpq6h95q/machines"), + StartURL: new("https://api.github.com/user/codespaces/monalisa-octocat-hello-world-g4wpq6h95q/start"), + StopURL: new("https://api.github.com/user/codespaces/monalisa-octocat-hello-world-g4wpq6h95q/stop"), RecentFolders: []string{ "testfolder1", "testfolder2", }, }, { - ID: Ptr(int64(2)), + ID: new(int64(2)), }, }} if !cmp.Equal(codespaces, want) { @@ -119,11 +119,11 @@ func TestCodespacesService_List(t *testing.T) { t.Errorf("Codespaces.List returned error: %v", err) } - want := &ListCodespaces{TotalCount: Ptr(1), Codespaces: []*Codespace{ + want := &ListCodespaces{TotalCount: new(1), Codespaces: []*Codespace{ { - ID: Ptr(int64(1)), + ID: new(int64(1)), Repository: &Repository{ - ID: Ptr(int64(1296269)), + ID: new(int64(1296269)), }, }, }} @@ -146,10 +146,10 @@ func TestCodespacesService_CreateInRepo(t *testing.T) { client, mux, _ := setup(t) input := &CreateCodespaceOptions{ - Ref: Ptr("main"), - Geo: Ptr("WestUs2"), - Machine: Ptr("standardLinux"), - IdleTimeoutMinutes: Ptr(60), + Ref: new("main"), + Geo: new("WestUs2"), + Machine: new("standardLinux"), + IdleTimeoutMinutes: new(60), } mux.HandleFunc("/repos/owner/repo/codespaces", func(w http.ResponseWriter, r *http.Request) { @@ -165,9 +165,9 @@ func TestCodespacesService_CreateInRepo(t *testing.T) { t.Errorf("Codespaces.CreateInRepo returned error: %v", err) } want := &Codespace{ - ID: Ptr(int64(1)), + ID: new(int64(1)), Repository: &Repository{ - ID: Ptr(int64(1296269)), + ID: new(int64(1296269)), }, } @@ -204,9 +204,9 @@ func TestCodespacesService_Start(t *testing.T) { t.Errorf("Codespaces.Start returned error: %v", err) } want := &Codespace{ - ID: Ptr(int64(1)), + ID: new(int64(1)), Repository: &Repository{ - ID: Ptr(int64(1296269)), + ID: new(int64(1296269)), }, } @@ -243,9 +243,9 @@ func TestCodespacesService_Stop(t *testing.T) { t.Errorf("Codespaces.Stop returned error: %v", err) } want := &Codespace{ - ID: Ptr(int64(1)), + ID: new(int64(1)), Repository: &Repository{ - ID: Ptr(int64(1296269)), + ID: new(int64(1296269)), }, } @@ -322,8 +322,8 @@ func TestCodespacesService_ListDevContainerConfigurations(t *testing.T) { Devcontainers: []*DevContainer{ { Path: ".devcontainer/foobar/devcontainer.json", - Name: Ptr("foobar"), - DisplayName: Ptr("foobar"), + Name: new("foobar"), + DisplayName: new("foobar"), }, }, } @@ -370,8 +370,8 @@ func TestCodespacesService_GetDefaultAttributes(t *testing.T) { ctx := t.Context() opt := &CodespaceGetDefaultAttributesOptions{ - Ref: Ptr("main"), - ClientIP: Ptr("1.2.3.4"), + Ref: new("main"), + ClientIP: new("1.2.3.4"), } got, _, err := client.Codespaces.GetDefaultAttributes(ctx, "o", "r", opt) @@ -381,12 +381,12 @@ func TestCodespacesService_GetDefaultAttributes(t *testing.T) { want := &CodespaceDefaultAttributes{ BillableOwner: &User{ - Login: Ptr("user1"), - ID: Ptr(int64(1001)), - URL: Ptr("https://example.com/user1"), + Login: new("user1"), + ID: new(int64(1001)), + URL: new("https://example.com/user1"), }, Defaults: &CodespaceDefaults{ - DevcontainerPath: Ptr(".devcontainer/devcontainer.json"), + DevcontainerPath: new(".devcontainer/devcontainer.json"), Location: "WestUs2", }, } @@ -452,8 +452,8 @@ func TestCodespacesService_CreateFromPullRequest(t *testing.T) { client, mux, _ := setup(t) input := &CreateCodespaceOptions{ - Machine: Ptr("standardLinux"), - IdleTimeoutMinutes: Ptr(60), + Machine: new("standardLinux"), + IdleTimeoutMinutes: new(60), } mux.HandleFunc("/repos/owner/repo/pulls/42/codespaces", func(w http.ResponseWriter, r *http.Request) { @@ -468,9 +468,9 @@ func TestCodespacesService_CreateFromPullRequest(t *testing.T) { t.Errorf("Codespaces.CreateFromPullRequest returned error: %v", err) } want := &Codespace{ - ID: Ptr(int64(1)), + ID: new(int64(1)), Repository: &Repository{ - ID: Ptr(int64(1)), + ID: new(int64(1)), }, } @@ -498,10 +498,10 @@ func TestCodespacesService_Create(t *testing.T) { client, mux, _ := setup(t) opt := &CodespaceCreateForUserOptions{ - Ref: Ptr("main"), - Geo: Ptr("WestUs2"), - Machine: Ptr("standardLinux"), - IdleTimeoutMinutes: Ptr(60), + Ref: new("main"), + Geo: new("WestUs2"), + Machine: new("standardLinux"), + IdleTimeoutMinutes: new(60), RepositoryID: int64(111), PullRequest: nil, } @@ -522,9 +522,9 @@ func TestCodespacesService_Create(t *testing.T) { } want := &Codespace{ - ID: Ptr(int64(1)), + ID: new(int64(1)), Repository: &Repository{ - ID: Ptr(int64(111)), + ID: new(int64(111)), }, } @@ -561,9 +561,9 @@ func TestCodespacesService_Get(t *testing.T) { } want := &Codespace{ - ID: Ptr(int64(1)), + ID: new(int64(1)), Repository: &Repository{ - ID: Ptr(int64(111)), + ID: new(int64(111)), }, } @@ -586,7 +586,7 @@ func TestCodespacesService_Update(t *testing.T) { client, mux, _ := setup(t) opt := &UpdateCodespaceOptions{ - Machine: Ptr("standardLinux"), + Machine: new("standardLinux"), RecentFolders: []string{ "folder1", "folder2", @@ -610,9 +610,9 @@ func TestCodespacesService_Update(t *testing.T) { } want := &Codespace{ - ID: Ptr(int64(1)), + ID: new(int64(1)), Repository: &Repository{ - ID: Ptr(int64(111)), + ID: new(int64(111)), }, } @@ -655,10 +655,10 @@ func TestCodespacesService_ExportCodespace(t *testing.T) { } want := &CodespaceExport{ - State: Ptr("succeeded"), + State: new("succeeded"), CompletedAt: &referenceTimestamp, - Branch: Ptr("main"), - ExportURL: Ptr("https://api.github.com/user/codespaces/:name/exports/latest"), + Branch: new("main"), + ExportURL: new("https://api.github.com/user/codespaces/:name/exports/latest"), } if !cmp.Equal(export, want) { @@ -696,10 +696,10 @@ func TestCodespacesService_GetLatestCodespaceExport(t *testing.T) { } want := &CodespaceExport{ - State: Ptr("succeeded"), + State: new("succeeded"), CompletedAt: &referenceTimestamp, - Branch: Ptr("main"), - ExportURL: Ptr("https://api.github.com/user/codespaces/:name/exports/latest"), + Branch: new("main"), + ExportURL: new("https://api.github.com/user/codespaces/:name/exports/latest"), } if !cmp.Equal(export, want) { @@ -721,8 +721,8 @@ func TestCodespacesService_Publish(t *testing.T) { client, mux, _ := setup(t) opt := &PublishCodespaceOptions{ - Name: Ptr("repo"), - Private: Ptr(true), + Name: new("repo"), + Private: new(true), } mux.HandleFunc("/user/codespaces/codespace_1/publish", func(w http.ResponseWriter, r *http.Request) { @@ -742,9 +742,9 @@ func TestCodespacesService_Publish(t *testing.T) { } want := &Codespace{ - ID: Ptr(int64(1)), + ID: new(int64(1)), Repository: &Repository{ - ID: Ptr(int64(111)), + ID: new(int64(111)), }, } if !cmp.Equal(repo, want) { diff --git a/github/copilot_test.go b/github/copilot_test.go index fae2e446da8..9fd71a41422 100644 --- a/github/copilot_test.go +++ b/github/copilot_test.go @@ -154,8 +154,8 @@ func TestCopilotService_GetSeatDetailsUser(t *testing.T) { } want := &User{ - ID: Ptr(int64(1)), - Type: Ptr("User"), + ID: new(int64(1)), + Type: new("User"), } if got, ok := seatDetails.GetUser(); ok && !cmp.Equal(got, want) { @@ -172,8 +172,8 @@ func TestCopilotService_GetSeatDetailsUser(t *testing.T) { }` bad := &Organization{ - ID: Ptr(int64(1)), - Type: Ptr("Organization"), + ID: new(int64(1)), + Type: new("Organization"), } err = json.Unmarshal([]byte(data), seatDetails) @@ -203,8 +203,8 @@ func TestCopilotService_GetSeatDetailsTeam(t *testing.T) { } want := &Team{ - ID: Ptr(int64(1)), - Type: Ptr("Team"), + ID: new(int64(1)), + Type: new("Team"), } if got, ok := seatDetails.GetTeam(); ok && !cmp.Equal(got, want) { @@ -221,8 +221,8 @@ func TestCopilotService_GetSeatDetailsTeam(t *testing.T) { }` bad := &User{ - ID: Ptr(int64(1)), - Type: Ptr("User"), + ID: new(int64(1)), + Type: new("User"), } err = json.Unmarshal([]byte(data), seatDetails) @@ -252,8 +252,8 @@ func TestCopilotService_GetSeatDetailsOrganization(t *testing.T) { } want := &Organization{ - ID: Ptr(int64(1)), - Type: Ptr("Organization"), + ID: new(int64(1)), + Type: new("Organization"), } if got, ok := seatDetails.GetOrganization(); ok && !cmp.Equal(got, want) { @@ -270,7 +270,7 @@ func TestCopilotService_GetSeatDetailsOrganization(t *testing.T) { }` bad := &Team{ - ID: Ptr(int64(1)), + ID: new(int64(1)), } err = json.Unmarshal([]byte(data), seatDetails) @@ -464,38 +464,38 @@ func TestCopilotService_ListCopilotSeats(t *testing.T) { Seats: []*CopilotSeatDetails{ { Assignee: &User{ - Login: Ptr("octocat"), - ID: Ptr(int64(1)), - NodeID: Ptr("MDQ6VXNlcjE="), - AvatarURL: Ptr("https://github.com/images/error/octocat_happy.gif"), - GravatarID: Ptr(""), - URL: Ptr("https://api.github.com/users/octocat"), - HTMLURL: Ptr("https://github.com/octocat"), - FollowersURL: Ptr("https://api.github.com/users/octocat/followers"), - FollowingURL: Ptr("https://api.github.com/users/octocat/following{/other_user}"), - GistsURL: Ptr("https://api.github.com/users/octocat/gists{/gist_id}"), - StarredURL: Ptr("https://api.github.com/users/octocat/starred{/owner}{/repo}"), - SubscriptionsURL: Ptr("https://api.github.com/users/octocat/subscriptions"), - OrganizationsURL: Ptr("https://api.github.com/users/octocat/orgs"), - ReposURL: Ptr("https://api.github.com/users/octocat/repos"), - EventsURL: Ptr("https://api.github.com/users/octocat/events{/privacy}"), - ReceivedEventsURL: Ptr("https://api.github.com/users/octocat/received_events"), - Type: Ptr("User"), - SiteAdmin: Ptr(false), + Login: new("octocat"), + ID: new(int64(1)), + NodeID: new("MDQ6VXNlcjE="), + AvatarURL: new("https://github.com/images/error/octocat_happy.gif"), + GravatarID: new(""), + URL: new("https://api.github.com/users/octocat"), + HTMLURL: new("https://github.com/octocat"), + FollowersURL: new("https://api.github.com/users/octocat/followers"), + FollowingURL: new("https://api.github.com/users/octocat/following{/other_user}"), + GistsURL: new("https://api.github.com/users/octocat/gists{/gist_id}"), + StarredURL: new("https://api.github.com/users/octocat/starred{/owner}{/repo}"), + SubscriptionsURL: new("https://api.github.com/users/octocat/subscriptions"), + OrganizationsURL: new("https://api.github.com/users/octocat/orgs"), + ReposURL: new("https://api.github.com/users/octocat/repos"), + EventsURL: new("https://api.github.com/users/octocat/events{/privacy}"), + ReceivedEventsURL: new("https://api.github.com/users/octocat/received_events"), + Type: new("User"), + SiteAdmin: new(false), }, AssigningTeam: &Team{ - ID: Ptr(int64(1)), - NodeID: Ptr("MDQ6VGVhbTE="), - URL: Ptr("https://api.github.com/teams/1"), - HTMLURL: Ptr("https://github.com/orgs/github/teams/justice-league"), - Name: Ptr("Justice League"), - Slug: Ptr("justice-league"), - Description: Ptr("A great team."), - Privacy: Ptr("closed"), - Permission: Ptr("admin"), - NotificationSetting: Ptr("notifications_enabled"), - MembersURL: Ptr("https://api.github.com/teams/1/members{/member}"), - RepositoriesURL: Ptr("https://api.github.com/teams/1/repos"), + ID: new(int64(1)), + NodeID: new("MDQ6VGVhbTE="), + URL: new("https://api.github.com/teams/1"), + HTMLURL: new("https://github.com/orgs/github/teams/justice-league"), + Name: new("Justice League"), + Slug: new("justice-league"), + Description: new("A great team."), + Privacy: new("closed"), + Permission: new("admin"), + NotificationSetting: new("notifications_enabled"), + MembersURL: new("https://api.github.com/teams/1/members{/member}"), + RepositoriesURL: new("https://api.github.com/teams/1/repos"), Parent: nil, }, @@ -503,61 +503,61 @@ func TestCopilotService_ListCopilotSeats(t *testing.T) { UpdatedAt: refTimestamp(1136178001), PendingCancellationDate: nil, LastActivityAt: refTimestamp(1136178002), - LastActivityEditor: Ptr("vscode/1.77.3/copilot/1.86.82"), + LastActivityEditor: new("vscode/1.77.3/copilot/1.86.82"), }, { Assignee: &User{ - Login: Ptr("octokitten"), - ID: Ptr(int64(1)), - NodeID: Ptr("MDQ76VNlcjE="), - AvatarURL: Ptr("https://github.com/images/error/octokitten_happy.gif"), - GravatarID: Ptr(""), - URL: Ptr("https://api.github.com/users/octokitten"), - HTMLURL: Ptr("https://github.com/octokitten"), - FollowersURL: Ptr("https://api.github.com/users/octokitten/followers"), - FollowingURL: Ptr("https://api.github.com/users/octokitten/following{/other_user}"), - GistsURL: Ptr("https://api.github.com/users/octokitten/gists{/gist_id}"), - StarredURL: Ptr("https://api.github.com/users/octokitten/starred{/owner}{/repo}"), - SubscriptionsURL: Ptr("https://api.github.com/users/octokitten/subscriptions"), - OrganizationsURL: Ptr("https://api.github.com/users/octokitten/orgs"), - ReposURL: Ptr("https://api.github.com/users/octokitten/repos"), - EventsURL: Ptr("https://api.github.com/users/octokitten/events{/privacy}"), - ReceivedEventsURL: Ptr("https://api.github.com/users/octokitten/received_events"), - Type: Ptr("User"), - SiteAdmin: Ptr(false), + Login: new("octokitten"), + ID: new(int64(1)), + NodeID: new("MDQ76VNlcjE="), + AvatarURL: new("https://github.com/images/error/octokitten_happy.gif"), + GravatarID: new(""), + URL: new("https://api.github.com/users/octokitten"), + HTMLURL: new("https://github.com/octokitten"), + FollowersURL: new("https://api.github.com/users/octokitten/followers"), + FollowingURL: new("https://api.github.com/users/octokitten/following{/other_user}"), + GistsURL: new("https://api.github.com/users/octokitten/gists{/gist_id}"), + StarredURL: new("https://api.github.com/users/octokitten/starred{/owner}{/repo}"), + SubscriptionsURL: new("https://api.github.com/users/octokitten/subscriptions"), + OrganizationsURL: new("https://api.github.com/users/octokitten/orgs"), + ReposURL: new("https://api.github.com/users/octokitten/repos"), + EventsURL: new("https://api.github.com/users/octokitten/events{/privacy}"), + ReceivedEventsURL: new("https://api.github.com/users/octokitten/received_events"), + Type: new("User"), + SiteAdmin: new(false), }, AssigningTeam: nil, CreatedAt: refTimestamp(1136178000), UpdatedAt: refTimestamp(1136178001), - PendingCancellationDate: Ptr("2021-11-01"), + PendingCancellationDate: new("2021-11-01"), LastActivityAt: refTimestamp(1136178002), - LastActivityEditor: Ptr("vscode/1.77.3/copilot/1.86.82"), + LastActivityEditor: new("vscode/1.77.3/copilot/1.86.82"), }, { Assignee: &Team{ - ID: Ptr(int64(1)), - Name: Ptr("octokittens"), - Type: Ptr("Team"), + ID: new(int64(1)), + Name: new("octokittens"), + Type: new("Team"), }, AssigningTeam: nil, CreatedAt: refTimestamp(1136178000), UpdatedAt: refTimestamp(1136178001), - PendingCancellationDate: Ptr("2021-11-01"), + PendingCancellationDate: new("2021-11-01"), LastActivityAt: refTimestamp(1136178002), - LastActivityEditor: Ptr("vscode/1.77.3/copilot/1.86.82"), + LastActivityEditor: new("vscode/1.77.3/copilot/1.86.82"), }, { Assignee: &Organization{ - ID: Ptr(int64(1)), - Name: Ptr("octocats"), - Type: Ptr("Organization"), + ID: new(int64(1)), + Name: new("octocats"), + Type: new("Organization"), }, AssigningTeam: nil, CreatedAt: refTimestamp(1136178000), UpdatedAt: refTimestamp(1136178001), - PendingCancellationDate: Ptr("2021-11-01"), + PendingCancellationDate: new("2021-11-01"), LastActivityAt: refTimestamp(1136178002), - LastActivityEditor: Ptr("vscode/1.77.3/copilot/1.86.82"), + LastActivityEditor: new("vscode/1.77.3/copilot/1.86.82"), }, }, } @@ -679,74 +679,74 @@ func TestCopilotService_ListCopilotEnterpriseSeats(t *testing.T) { Seats: []*CopilotSeatDetails{ { Assignee: &User{ - Login: Ptr("octocat"), - ID: Ptr(int64(1)), - NodeID: Ptr("MDQ6VXNlcjE="), - AvatarURL: Ptr("https://github.com/images/error/octocat_happy.gif"), - GravatarID: Ptr(""), - URL: Ptr("https://api.github.com/users/octocat"), - HTMLURL: Ptr("https://github.com/octocat"), - FollowersURL: Ptr("https://api.github.com/users/octocat/followers"), - FollowingURL: Ptr("https://api.github.com/users/octocat/following{/other_user}"), - GistsURL: Ptr("https://api.github.com/users/octocat/gists{/gist_id}"), - StarredURL: Ptr("https://api.github.com/users/octocat/starred{/owner}{/repo}"), - SubscriptionsURL: Ptr("https://api.github.com/users/octocat/subscriptions"), - OrganizationsURL: Ptr("https://api.github.com/users/octocat/orgs"), - ReposURL: Ptr("https://api.github.com/users/octocat/repos"), - EventsURL: Ptr("https://api.github.com/users/octocat/events{/privacy}"), - ReceivedEventsURL: Ptr("https://api.github.com/users/octocat/received_events"), - Type: Ptr("User"), - SiteAdmin: Ptr(false), + Login: new("octocat"), + ID: new(int64(1)), + NodeID: new("MDQ6VXNlcjE="), + AvatarURL: new("https://github.com/images/error/octocat_happy.gif"), + GravatarID: new(""), + URL: new("https://api.github.com/users/octocat"), + HTMLURL: new("https://github.com/octocat"), + FollowersURL: new("https://api.github.com/users/octocat/followers"), + FollowingURL: new("https://api.github.com/users/octocat/following{/other_user}"), + GistsURL: new("https://api.github.com/users/octocat/gists{/gist_id}"), + StarredURL: new("https://api.github.com/users/octocat/starred{/owner}{/repo}"), + SubscriptionsURL: new("https://api.github.com/users/octocat/subscriptions"), + OrganizationsURL: new("https://api.github.com/users/octocat/orgs"), + ReposURL: new("https://api.github.com/users/octocat/repos"), + EventsURL: new("https://api.github.com/users/octocat/events{/privacy}"), + ReceivedEventsURL: new("https://api.github.com/users/octocat/received_events"), + Type: new("User"), + SiteAdmin: new(false), }, AssigningTeam: &Team{ - ID: Ptr(int64(1)), - NodeID: Ptr("MDQ6VGVhbTE="), - URL: Ptr("https://api.github.com/teams/1"), - HTMLURL: Ptr("https://github.com/orgs/github/teams/justice-league"), - Name: Ptr("Justice League"), - Slug: Ptr("justice-league"), - Description: Ptr("A great team."), - Privacy: Ptr("closed"), - NotificationSetting: Ptr("notifications_enabled"), - Permission: Ptr("admin"), - MembersURL: Ptr("https://api.github.com/teams/1/members{/member}"), - RepositoriesURL: Ptr("https://api.github.com/teams/1/repos"), + ID: new(int64(1)), + NodeID: new("MDQ6VGVhbTE="), + URL: new("https://api.github.com/teams/1"), + HTMLURL: new("https://github.com/orgs/github/teams/justice-league"), + Name: new("Justice League"), + Slug: new("justice-league"), + Description: new("A great team."), + Privacy: new("closed"), + NotificationSetting: new("notifications_enabled"), + Permission: new("admin"), + MembersURL: new("https://api.github.com/teams/1/members{/member}"), + RepositoriesURL: new("https://api.github.com/teams/1/repos"), Parent: nil, }, CreatedAt: refTimestamp(1136178000), UpdatedAt: refTimestamp(1136178001), PendingCancellationDate: nil, LastActivityAt: refTimestamp(1136178002), - LastActivityEditor: Ptr("vscode/1.77.3/copilot/1.86.82"), - PlanType: Ptr("business"), + LastActivityEditor: new("vscode/1.77.3/copilot/1.86.82"), + PlanType: new("business"), }, { Assignee: &User{ - Login: Ptr("octokitten"), - ID: Ptr(int64(1)), - NodeID: Ptr("MDQ76VNlcjE="), - AvatarURL: Ptr("https://github.com/images/error/octokitten_happy.gif"), - GravatarID: Ptr(""), - URL: Ptr("https://api.github.com/users/octokitten"), - HTMLURL: Ptr("https://github.com/octokitten"), - FollowersURL: Ptr("https://api.github.com/users/octokitten/followers"), - FollowingURL: Ptr("https://api.github.com/users/octokitten/following{/other_user}"), - GistsURL: Ptr("https://api.github.com/users/octokitten/gists{/gist_id}"), - StarredURL: Ptr("https://api.github.com/users/octokitten/starred{/owner}{/repo}"), - SubscriptionsURL: Ptr("https://api.github.com/users/octokitten/subscriptions"), - OrganizationsURL: Ptr("https://api.github.com/users/octokitten/orgs"), - ReposURL: Ptr("https://api.github.com/users/octokitten/repos"), - EventsURL: Ptr("https://api.github.com/users/octokitten/events{/privacy}"), - ReceivedEventsURL: Ptr("https://api.github.com/users/octokitten/received_events"), - Type: Ptr("User"), - SiteAdmin: Ptr(false), + Login: new("octokitten"), + ID: new(int64(1)), + NodeID: new("MDQ76VNlcjE="), + AvatarURL: new("https://github.com/images/error/octokitten_happy.gif"), + GravatarID: new(""), + URL: new("https://api.github.com/users/octokitten"), + HTMLURL: new("https://github.com/octokitten"), + FollowersURL: new("https://api.github.com/users/octokitten/followers"), + FollowingURL: new("https://api.github.com/users/octokitten/following{/other_user}"), + GistsURL: new("https://api.github.com/users/octokitten/gists{/gist_id}"), + StarredURL: new("https://api.github.com/users/octokitten/starred{/owner}{/repo}"), + SubscriptionsURL: new("https://api.github.com/users/octokitten/subscriptions"), + OrganizationsURL: new("https://api.github.com/users/octokitten/orgs"), + ReposURL: new("https://api.github.com/users/octokitten/repos"), + EventsURL: new("https://api.github.com/users/octokitten/events{/privacy}"), + ReceivedEventsURL: new("https://api.github.com/users/octokitten/received_events"), + Type: new("User"), + SiteAdmin: new(false), }, AssigningTeam: nil, CreatedAt: refTimestamp(1136178000), UpdatedAt: refTimestamp(1136178001), - PendingCancellationDate: Ptr("2021-11-01"), + PendingCancellationDate: new("2021-11-01"), LastActivityAt: refTimestamp(1136178002), - LastActivityEditor: Ptr("vscode/1.77.3/copilot/1.86.82"), + LastActivityEditor: new("vscode/1.77.3/copilot/1.86.82"), PlanType: nil, }, }, @@ -803,8 +803,8 @@ func TestCopilotService_ListOrganizationCodingAgentRepositories(t *testing.T) { want := &ListOrganizationCopilotCodingAgentRepositoriesResponse{ TotalCount: 2, Repositories: []*Repository{ - {ID: Ptr(int64(1)), Name: Ptr("Hello-World"), FullName: Ptr("octocat/Hello-World")}, - {ID: Ptr(int64(2)), Name: Ptr("Hello-World-2"), FullName: Ptr("octocat/Hello-World-2")}, + {ID: new(int64(1)), Name: new("Hello-World"), FullName: new("octocat/Hello-World")}, + {ID: new(int64(2)), Name: new("Hello-World-2"), FullName: new("octocat/Hello-World-2")}, }, } if !cmp.Equal(got, want) { @@ -1103,45 +1103,45 @@ func TestCopilotService_GetSeatDetails(t *testing.T) { want := &CopilotSeatDetails{ Assignee: &User{ - Login: Ptr("octocat"), - ID: Ptr(int64(1)), - NodeID: Ptr("MDQ6VXNlcjE="), - AvatarURL: Ptr("https://github.com/images/error/octocat_happy.gif"), - GravatarID: Ptr(""), - URL: Ptr("https://api.github.com/users/octocat"), - HTMLURL: Ptr("https://github.com/octocat"), - FollowersURL: Ptr("https://api.github.com/users/octocat/followers"), - FollowingURL: Ptr("https://api.github.com/users/octocat/following{/other_user}"), - GistsURL: Ptr("https://api.github.com/users/octocat/gists{/gist_id}"), - StarredURL: Ptr("https://api.github.com/users/octocat/starred{/owner}{/repo}"), - SubscriptionsURL: Ptr("https://api.github.com/users/octocat/subscriptions"), - OrganizationsURL: Ptr("https://api.github.com/users/octocat/orgs"), - ReposURL: Ptr("https://api.github.com/users/octocat/repos"), - EventsURL: Ptr("https://api.github.com/users/octocat/events{/privacy}"), - ReceivedEventsURL: Ptr("https://api.github.com/users/octocat/received_events"), - Type: Ptr("User"), - SiteAdmin: Ptr(false), + Login: new("octocat"), + ID: new(int64(1)), + NodeID: new("MDQ6VXNlcjE="), + AvatarURL: new("https://github.com/images/error/octocat_happy.gif"), + GravatarID: new(""), + URL: new("https://api.github.com/users/octocat"), + HTMLURL: new("https://github.com/octocat"), + FollowersURL: new("https://api.github.com/users/octocat/followers"), + FollowingURL: new("https://api.github.com/users/octocat/following{/other_user}"), + GistsURL: new("https://api.github.com/users/octocat/gists{/gist_id}"), + StarredURL: new("https://api.github.com/users/octocat/starred{/owner}{/repo}"), + SubscriptionsURL: new("https://api.github.com/users/octocat/subscriptions"), + OrganizationsURL: new("https://api.github.com/users/octocat/orgs"), + ReposURL: new("https://api.github.com/users/octocat/repos"), + EventsURL: new("https://api.github.com/users/octocat/events{/privacy}"), + ReceivedEventsURL: new("https://api.github.com/users/octocat/received_events"), + Type: new("User"), + SiteAdmin: new(false), }, AssigningTeam: &Team{ - ID: Ptr(int64(1)), - NodeID: Ptr("MDQ6VGVhbTE="), - URL: Ptr("https://api.github.com/teams/1"), - HTMLURL: Ptr("https://github.com/orgs/github/teams/justice-league"), - Name: Ptr("Justice League"), - Slug: Ptr("justice-league"), - Description: Ptr("A great team."), - Privacy: Ptr("closed"), - NotificationSetting: Ptr("notifications_enabled"), - Permission: Ptr("admin"), - MembersURL: Ptr("https://api.github.com/teams/1/members{/member}"), - RepositoriesURL: Ptr("https://api.github.com/teams/1/repos"), + ID: new(int64(1)), + NodeID: new("MDQ6VGVhbTE="), + URL: new("https://api.github.com/teams/1"), + HTMLURL: new("https://github.com/orgs/github/teams/justice-league"), + Name: new("Justice League"), + Slug: new("justice-league"), + Description: new("A great team."), + Privacy: new("closed"), + NotificationSetting: new("notifications_enabled"), + Permission: new("admin"), + MembersURL: new("https://api.github.com/teams/1/members{/member}"), + RepositoriesURL: new("https://api.github.com/teams/1/repos"), Parent: nil, }, CreatedAt: refTimestamp(1136178000), UpdatedAt: refTimestamp(1136178001), PendingCancellationDate: nil, LastActivityAt: refTimestamp(1136178002), - LastActivityEditor: Ptr("vscode/1.77.3/copilot/1.86.82"), + LastActivityEditor: new("vscode/1.77.3/copilot/1.86.82"), } if !cmp.Equal(got, want) { @@ -1334,8 +1334,8 @@ func TestCopilotService_GetEnterpriseMetrics(t *testing.T) { want := []*CopilotMetrics{ { Date: "2024-06-24", - TotalActiveUsers: Ptr(24), - TotalEngagedUsers: Ptr(20), + TotalActiveUsers: new(24), + TotalEngagedUsers: new(20), CopilotIDECodeCompletions: &CopilotIDECodeCompletions{ TotalEngagedUsers: 20, Languages: []*CopilotIDECodeCompletionsLanguage{ @@ -1386,7 +1386,7 @@ func TestCopilotService_GetEnterpriseMetrics(t *testing.T) { { Name: "a-custom-model", IsCustomModel: true, - CustomModelTrainingDate: Ptr("2024-02-01"), + CustomModelTrainingDate: new("2024-02-01"), Languages: []*CopilotIDECodeCompletionsModelLanguage{ { Name: "typescript", @@ -1429,7 +1429,7 @@ func TestCopilotService_GetEnterpriseMetrics(t *testing.T) { { Name: "a-custom-model", IsCustomModel: true, - CustomModelTrainingDate: Ptr("2024-02-01"), + CustomModelTrainingDate: new("2024-02-01"), TotalEngagedUsers: 1, TotalChats: 10, TotalChatInsertionEvents: 11, @@ -1474,7 +1474,7 @@ func TestCopilotService_GetEnterpriseMetrics(t *testing.T) { { Name: "a-custom-model", IsCustomModel: true, - CustomModelTrainingDate: Ptr("2024-02-01"), + CustomModelTrainingDate: new("2024-02-01"), TotalPRSummariesCreated: 10, TotalEngagedUsers: 4, }, @@ -1675,8 +1675,8 @@ func TestCopilotService_GetEnterpriseTeamMetrics(t *testing.T) { want := []*CopilotMetrics{ { Date: "2024-06-24", - TotalActiveUsers: Ptr(24), - TotalEngagedUsers: Ptr(20), + TotalActiveUsers: new(24), + TotalEngagedUsers: new(20), CopilotIDECodeCompletions: &CopilotIDECodeCompletions{ TotalEngagedUsers: 20, Languages: []*CopilotIDECodeCompletionsLanguage{ @@ -1727,7 +1727,7 @@ func TestCopilotService_GetEnterpriseTeamMetrics(t *testing.T) { { Name: "a-custom-model", IsCustomModel: true, - CustomModelTrainingDate: Ptr("2024-02-01"), + CustomModelTrainingDate: new("2024-02-01"), Languages: []*CopilotIDECodeCompletionsModelLanguage{ { Name: "typescript", @@ -1770,7 +1770,7 @@ func TestCopilotService_GetEnterpriseTeamMetrics(t *testing.T) { { Name: "a-custom-model", IsCustomModel: true, - CustomModelTrainingDate: Ptr("2024-02-01"), + CustomModelTrainingDate: new("2024-02-01"), TotalEngagedUsers: 1, TotalChats: 10, TotalChatInsertionEvents: 11, @@ -1815,7 +1815,7 @@ func TestCopilotService_GetEnterpriseTeamMetrics(t *testing.T) { { Name: "a-custom-model", IsCustomModel: true, - CustomModelTrainingDate: Ptr("2024-02-01"), + CustomModelTrainingDate: new("2024-02-01"), TotalPRSummariesCreated: 10, TotalEngagedUsers: 4, }, @@ -2016,8 +2016,8 @@ func TestCopilotService_GetOrganizationMetrics(t *testing.T) { want := []*CopilotMetrics{ { Date: "2024-06-24", - TotalActiveUsers: Ptr(24), - TotalEngagedUsers: Ptr(20), + TotalActiveUsers: new(24), + TotalEngagedUsers: new(20), CopilotIDECodeCompletions: &CopilotIDECodeCompletions{ TotalEngagedUsers: 20, Languages: []*CopilotIDECodeCompletionsLanguage{ @@ -2068,7 +2068,7 @@ func TestCopilotService_GetOrganizationMetrics(t *testing.T) { { Name: "a-custom-model", IsCustomModel: true, - CustomModelTrainingDate: Ptr("2024-02-01"), + CustomModelTrainingDate: new("2024-02-01"), Languages: []*CopilotIDECodeCompletionsModelLanguage{ { Name: "typescript", @@ -2111,7 +2111,7 @@ func TestCopilotService_GetOrganizationMetrics(t *testing.T) { { Name: "a-custom-model", IsCustomModel: true, - CustomModelTrainingDate: Ptr("2024-02-01"), + CustomModelTrainingDate: new("2024-02-01"), TotalEngagedUsers: 1, TotalChats: 10, TotalChatInsertionEvents: 11, @@ -2156,7 +2156,7 @@ func TestCopilotService_GetOrganizationMetrics(t *testing.T) { { Name: "a-custom-model", IsCustomModel: true, - CustomModelTrainingDate: Ptr("2024-02-01"), + CustomModelTrainingDate: new("2024-02-01"), TotalPRSummariesCreated: 10, TotalEngagedUsers: 4, }, @@ -2357,8 +2357,8 @@ func TestCopilotService_GetOrganizationTeamMetrics(t *testing.T) { want := []*CopilotMetrics{ { Date: "2024-06-24", - TotalActiveUsers: Ptr(24), - TotalEngagedUsers: Ptr(20), + TotalActiveUsers: new(24), + TotalEngagedUsers: new(20), CopilotIDECodeCompletions: &CopilotIDECodeCompletions{ TotalEngagedUsers: 20, Languages: []*CopilotIDECodeCompletionsLanguage{ @@ -2409,7 +2409,7 @@ func TestCopilotService_GetOrganizationTeamMetrics(t *testing.T) { { Name: "a-custom-model", IsCustomModel: true, - CustomModelTrainingDate: Ptr("2024-02-01"), + CustomModelTrainingDate: new("2024-02-01"), Languages: []*CopilotIDECodeCompletionsModelLanguage{ { Name: "typescript", @@ -2452,7 +2452,7 @@ func TestCopilotService_GetOrganizationTeamMetrics(t *testing.T) { { Name: "a-custom-model", IsCustomModel: true, - CustomModelTrainingDate: Ptr("2024-02-01"), + CustomModelTrainingDate: new("2024-02-01"), TotalEngagedUsers: 1, TotalChats: 10, TotalChatInsertionEvents: 11, @@ -2497,7 +2497,7 @@ func TestCopilotService_GetOrganizationTeamMetrics(t *testing.T) { { Name: "a-custom-model", IsCustomModel: true, - CustomModelTrainingDate: Ptr("2024-02-01"), + CustomModelTrainingDate: new("2024-02-01"), TotalPRSummariesCreated: 10, TotalEngagedUsers: 4, }, @@ -2947,8 +2947,8 @@ func TestCopilotService_DownloadCopilotMetrics(t *testing.T) { want := []*CopilotMetrics{ { Date: "2023-01-01", - TotalActiveUsers: Ptr(100), - TotalEngagedUsers: Ptr(50), + TotalActiveUsers: new(100), + TotalEngagedUsers: new(50), CopilotIDECodeCompletions: &CopilotIDECodeCompletions{ TotalEngagedUsers: 50, Languages: []*CopilotIDECodeCompletionsLanguage{ @@ -3095,55 +3095,55 @@ func TestCopilotService_DownloadDailyMetrics(t *testing.T) { want := &CopilotDailyMetrics{ Day: "2026-04-01", - OrganizationID: Ptr("123"), - DailyActiveCLIUsers: Ptr(2), - DailyActiveUsers: Ptr(10), - WeeklyActiveUsers: Ptr(20), - MonthlyActiveUsers: Ptr(30), + OrganizationID: new("123"), + DailyActiveCLIUsers: new(2), + DailyActiveUsers: new(10), + WeeklyActiveUsers: new(20), + MonthlyActiveUsers: new(30), CopilotMetricsChatPanel: CopilotMetricsChatPanel{ - ChatPanelAskMode: Ptr(4), + ChatPanelAskMode: new(4), }, TotalsByIDE: []*CopilotMetricsIDE{ - {IDE: "vscode", UserInitiatedInteractionCount: Ptr(5), CopilotMetricsCodeActivity: CopilotMetricsCodeActivity{LOCAddedSum: Ptr(100)}}, + {IDE: "vscode", UserInitiatedInteractionCount: new(5), CopilotMetricsCodeActivity: CopilotMetricsCodeActivity{LOCAddedSum: new(100)}}, }, TotalsByFeature: []*CopilotMetricsFeature{ - {Feature: "completion", UserInitiatedInteractionCount: Ptr(5)}, - {Feature: "agent_edit", CopilotMetricsCodeActivity: CopilotMetricsCodeActivity{LOCAddedSum: Ptr(7), LOCDeletedSum: Ptr(2)}}, + {Feature: "completion", UserInitiatedInteractionCount: new(5)}, + {Feature: "agent_edit", CopilotMetricsCodeActivity: CopilotMetricsCodeActivity{LOCAddedSum: new(7), LOCDeletedSum: new(2)}}, }, TotalsByLanguageFeature: []*CopilotMetricsLanguageFeature{ - {Language: "go", Feature: "completion", CopilotMetricsCodeActivity: CopilotMetricsCodeActivity{CodeGenerationActivityCount: Ptr(3)}}, + {Language: "go", Feature: "completion", CopilotMetricsCodeActivity: CopilotMetricsCodeActivity{CodeGenerationActivityCount: new(3)}}, }, TotalsByLanguageModel: []*CopilotMetricsLanguageModel{ - {Language: "go", Model: "m1", CopilotMetricsCodeActivity: CopilotMetricsCodeActivity{CodeGenerationActivityCount: Ptr(3)}}, + {Language: "go", Model: "m1", CopilotMetricsCodeActivity: CopilotMetricsCodeActivity{CodeGenerationActivityCount: new(3)}}, }, TotalsByModelFeature: []*CopilotMetricsModelFeature{ - {Model: "m1", Feature: "completion", UserInitiatedInteractionCount: Ptr(5)}, + {Model: "m1", Feature: "completion", UserInitiatedInteractionCount: new(5)}, }, TotalsByCLI: &CopilotMetricsCLI{ - SessionCount: Ptr(3), - RequestCount: Ptr(4), - PromptCount: Ptr(2), + SessionCount: new(3), + RequestCount: new(4), + PromptCount: new(2), TokenUsage: &CopilotMetricsCLITokenUsage{ - AvgTokensPerRequest: Ptr(4123.5), - OutputTokensSum: Ptr(7000), - PromptTokensSum: Ptr(9494), + AvgTokensPerRequest: new(4123.5), + OutputTokensSum: new(7000), + PromptTokensSum: new(9494), }, }, TotalsBy3rdPartyAgent: []*CopilotMetricsThirdPartyAgent{ { AgentName: "Claude", AgentID: "claude", - UserInitiatedInteractionCount: Ptr(8), - SessionCount: Ptr(3), + UserInitiatedInteractionCount: new(8), + SessionCount: new(3), }, }, - LOCAddedSum: Ptr(100), + LOCAddedSum: new(100), PullRequests: &CopilotMetricsPullRequests{ - TotalReviewed: Ptr(1), - TotalCreated: Ptr(2), - MedianMinutesToMerge: Ptr(12.5), - MedianMinutesToMergeCopilotAuthored: Ptr(4.5), - MedianMinutesToMergeCopilotReviewed: Ptr(6.5), + TotalReviewed: new(1), + TotalCreated: new(2), + MedianMinutesToMerge: new(12.5), + MedianMinutesToMergeCopilotAuthored: new(4.5), + MedianMinutesToMergeCopilotReviewed: new(6.5), }, } @@ -3224,30 +3224,30 @@ func TestCopilotService_DownloadPeriodicMetrics(t *testing.T) { want := &CopilotPeriodicMetrics{ ReportStartDay: "2026-03-05", ReportEndDay: "2026-04-01", - OrganizationID: Ptr("123"), + OrganizationID: new("123"), CreatedAt: refTimestamp(1136178000), DayTotals: []*CopilotDailyMetrics{ { Day: "2026-03-05", - DailyActiveCLIUsers: Ptr(2), - DailyActiveUsers: Ptr(5), + DailyActiveCLIUsers: new(2), + DailyActiveUsers: new(5), TotalsByCLI: &CopilotMetricsCLI{ - SessionCount: Ptr(1), - RequestCount: Ptr(2), - PromptCount: Ptr(1), + SessionCount: new(1), + RequestCount: new(2), + PromptCount: new(1), TokenUsage: &CopilotMetricsCLITokenUsage{ - AvgTokensPerRequest: Ptr(4000.0), - OutputTokensSum: Ptr(5000), - PromptTokensSum: Ptr(3000), + AvgTokensPerRequest: new(4000.0), + OutputTokensSum: new(5000), + PromptTokensSum: new(3000), }, }, PullRequests: &CopilotMetricsPullRequests{ - MedianMinutesToMerge: Ptr(8.5), - MedianMinutesToMergeCopilotAuthored: Ptr(5.0), - MedianMinutesToMergeCopilotReviewed: Ptr(7.0), + MedianMinutesToMerge: new(8.5), + MedianMinutesToMergeCopilotAuthored: new(5.0), + MedianMinutesToMergeCopilotReviewed: new(7.0), }, }, - {Day: "2026-03-06", DailyActiveUsers: Ptr(7)}, + {Day: "2026-03-06", DailyActiveUsers: new(7)}, }, } @@ -3304,17 +3304,17 @@ func TestCopilotService_DownloadUserDailyMetrics(t *testing.T) { UserID: 1, UserLogin: "alice", Day: "2026-04-01", - UserInitiatedInteractionCount: Ptr(5), + UserInitiatedInteractionCount: new(5), CopilotMetricsChatPanel: CopilotMetricsChatPanel{ - ChatPanelEditMode: Ptr(2), + ChatPanelEditMode: new(2), }, - UsedChat: Ptr(true), - UsedCLI: Ptr(true), - UsedCopilotCodeReviewActive: Ptr(true), + UsedChat: new(true), + UsedCLI: new(true), + UsedCopilotCodeReviewActive: new(true), TotalsByCLI: &CopilotMetricsCLI{ - SessionCount: Ptr(2), - RequestCount: Ptr(2), - PromptCount: Ptr(1), + SessionCount: new(2), + RequestCount: new(2), + PromptCount: new(1), LastKnownCLIVersion: &CopilotMetricsCLIVersion{ SampledAt: refTimestamp(1136178000), CLIVersion: "1.0.8", @@ -3323,7 +3323,7 @@ func TestCopilotService_DownloadUserDailyMetrics(t *testing.T) { TotalsByIDE: []*CopilotUserMetricsIDE{ { IDE: "vscode", - UserInitiatedInteractionCount: Ptr(5), + UserInitiatedInteractionCount: new(5), LastKnownPluginVersion: &CopilotUserMetricsPluginVersion{ SampledAt: refTimestamp(1136178001), Plugin: "copilot", @@ -3339,7 +3339,7 @@ func TestCopilotService_DownloadUserDailyMetrics(t *testing.T) { { AgentName: "Claude", AgentID: "claude", - UserInitiatedInteractionCount: Ptr(2), + UserInitiatedInteractionCount: new(2), }, }, }, @@ -3347,8 +3347,8 @@ func TestCopilotService_DownloadUserDailyMetrics(t *testing.T) { UserID: 2, UserLogin: "bob", Day: "2026-04-01", - UsedAgent: Ptr(true), - UsedCopilotCodeReviewPassive: Ptr(true), + UsedAgent: new(true), + UsedCopilotCodeReviewPassive: new(true), }, } @@ -3420,8 +3420,8 @@ func TestCopilotService_DownloadUserPeriodicMetrics(t *testing.T) { Day: "2026-03-05", UserID: 1, UserLogin: "alice", - UserInitiatedInteractionCount: Ptr(3), - UsedCopilotCodeReviewActive: Ptr(true), + UserInitiatedInteractionCount: new(3), + UsedCopilotCodeReviewActive: new(true), }, { ReportStartDay: "2026-03-05", @@ -3429,17 +3429,17 @@ func TestCopilotService_DownloadUserPeriodicMetrics(t *testing.T) { Day: "2026-03-06", UserID: 1, UserLogin: "alice", - UsedCLI: Ptr(true), - UsedCopilotCodeReviewPassive: Ptr(true), - UsedCopilotCodingAgent: Ptr(true), + UsedCLI: new(true), + UsedCopilotCodeReviewPassive: new(true), + UsedCopilotCodingAgent: new(true), TotalsByCLI: &CopilotMetricsCLI{ - SessionCount: Ptr(1), - RequestCount: Ptr(3), - PromptCount: Ptr(2), + SessionCount: new(1), + RequestCount: new(3), + PromptCount: new(2), TokenUsage: &CopilotMetricsCLITokenUsage{ - AvgTokensPerRequest: Ptr(1200.5), - OutputTokensSum: Ptr(2400), - PromptTokensSum: Ptr(1201), + AvgTokensPerRequest: new(1200.5), + OutputTokensSum: new(2400), + PromptTokensSum: new(1201), }, }, }, diff --git a/github/dependabot_alerts_test.go b/github/dependabot_alerts_test.go index d5f09ec8e88..7406e9217f6 100644 --- a/github/dependabot_alerts_test.go +++ b/github/dependabot_alerts_test.go @@ -23,7 +23,7 @@ func TestDependabotService_ListRepoAlerts(t *testing.T) { fmt.Fprint(w, `[{"number":1,"state":"open"},{"number":42,"state":"fixed"}]`) }) - opts := &ListAlertsOptions{State: Ptr("open")} + opts := &ListAlertsOptions{State: new("open")} ctx := t.Context() alerts, _, err := client.Dependabot.ListRepoAlerts(ctx, "o", "r", opts) if err != nil { @@ -31,8 +31,8 @@ func TestDependabotService_ListRepoAlerts(t *testing.T) { } want := []*DependabotAlert{ - {Number: Ptr(1), State: Ptr("open")}, - {Number: Ptr(42), State: Ptr("fixed")}, + {Number: new(1), State: new("open")}, + {Number: new(42), State: new("fixed")}, } if !cmp.Equal(alerts, want) { t.Errorf("Dependabot.ListRepoAlerts returned %+v, want %+v", alerts, want) @@ -69,8 +69,8 @@ func TestDependabotService_GetRepoAlert(t *testing.T) { } want := &DependabotAlert{ - Number: Ptr(42), - State: Ptr("fixed"), + Number: new(42), + State: new("fixed"), } if !cmp.Equal(alert, want) { t.Errorf("Dependabot.GetRepoAlert returned %+v, want %+v", alert, want) @@ -101,7 +101,7 @@ func TestDependabotService_ListOrgAlerts(t *testing.T) { fmt.Fprint(w, `[{"number":1,"state":"open"},{"number":42,"state":"fixed"}]`) }) - opts := &ListAlertsOptions{State: Ptr("open")} + opts := &ListAlertsOptions{State: new("open")} ctx := t.Context() alerts, _, err := client.Dependabot.ListOrgAlerts(ctx, "o", opts) if err != nil { @@ -109,8 +109,8 @@ func TestDependabotService_ListOrgAlerts(t *testing.T) { } want := []*DependabotAlert{ - {Number: Ptr(1), State: Ptr("open")}, - {Number: Ptr(42), State: Ptr("fixed")}, + {Number: new(1), State: new("open")}, + {Number: new(42), State: new("fixed")}, } if !cmp.Equal(alerts, want) { t.Errorf("Dependabot.ListOrgAlerts returned %+v, want %+v", alerts, want) @@ -135,9 +135,9 @@ func TestDependabotService_UpdateAlert(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - state := Ptr("dismissed") - dismissedReason := Ptr("no_bandwidth") - dismissedComment := Ptr("no time to fix this") + state := new("dismissed") + dismissedReason := new("no_bandwidth") + dismissedComment := new("no time to fix this") alertState := &DependabotAlertState{State: *state, DismissedReason: dismissedReason, DismissedComment: dismissedComment} @@ -153,10 +153,10 @@ func TestDependabotService_UpdateAlert(t *testing.T) { } want := &DependabotAlert{ - Number: Ptr(42), - State: Ptr("dismissed"), - DismissedReason: Ptr("no_bandwidth"), - DismissedComment: Ptr("no time to fix this"), + Number: new(42), + State: new("dismissed"), + DismissedReason: new("no_bandwidth"), + DismissedComment: new("no time to fix this"), } if !cmp.Equal(alert, want) { t.Errorf("Dependabot.UpdateAlert returned %+v, want %+v", alert, want) diff --git a/github/dependabot_secrets_test.go b/github/dependabot_secrets_test.go index 66ecb474adc..7d6f03e4693 100644 --- a/github/dependabot_secrets_test.go +++ b/github/dependabot_secrets_test.go @@ -28,7 +28,7 @@ func TestDependabotService_GetRepoPublicKey(t *testing.T) { t.Errorf("Dependabot.GetRepoPublicKey returned error: %v", err) } - want := &PublicKey{KeyID: Ptr("1234"), Key: Ptr("2Sg8iYjAxxmI2LvUXpJjkYrMxURPc8r+dB7TJyvv1234")} + want := &PublicKey{KeyID: new("1234"), Key: new("2Sg8iYjAxxmI2LvUXpJjkYrMxURPc8r+dB7TJyvv1234")} if !cmp.Equal(key, want) { t.Errorf("Dependabot.GetRepoPublicKey returned %+v, want %+v", key, want) } @@ -63,7 +63,7 @@ func TestDependabotService_GetRepoPublicKeyNumeric(t *testing.T) { t.Errorf("Dependabot.GetRepoPublicKey returned error: %v", err) } - want := &PublicKey{KeyID: Ptr("1234"), Key: Ptr("2Sg8iYjAxxmI2LvUXpJjkYrMxURPc8r+dB7TJyvv1234")} + want := &PublicKey{KeyID: new("1234"), Key: new("2Sg8iYjAxxmI2LvUXpJjkYrMxURPc8r+dB7TJyvv1234")} if !cmp.Equal(key, want) { t.Errorf("Dependabot.GetRepoPublicKey returned %+v, want %+v", key, want) } @@ -242,7 +242,7 @@ func TestDependabotService_GetOrgPublicKey(t *testing.T) { t.Errorf("Dependabot.GetOrgPublicKey returned error: %v", err) } - want := &PublicKey{KeyID: Ptr("012345678"), Key: Ptr("2Sg8iYjAxxmI2LvUXpJjkYrMxURPc8r+dB7TJyvv1234")} + want := &PublicKey{KeyID: new("012345678"), Key: new("2Sg8iYjAxxmI2LvUXpJjkYrMxURPc8r+dB7TJyvv1234")} if !cmp.Equal(key, want) { t.Errorf("Dependabot.GetOrgPublicKey returned %+v, want %+v", key, want) } @@ -410,9 +410,9 @@ func TestDependabotService_ListSelectedReposForOrgSecret(t *testing.T) { } want := &SelectedReposList{ - TotalCount: Ptr(1), + TotalCount: new(1), Repositories: []*Repository{ - {ID: Ptr(int64(1))}, + {ID: new(int64(1))}, }, } if !cmp.Equal(repos, want) { diff --git a/github/dependency_graph_snapshots_test.go b/github/dependency_graph_snapshots_test.go index ef8f360bada..b0a40eeafe2 100644 --- a/github/dependency_graph_snapshots_test.go +++ b/github/dependency_graph_snapshots_test.go @@ -19,17 +19,17 @@ func TestDependencyGraphService_CreateSnapshot(t *testing.T) { snapshot := &DependencyGraphSnapshot{ Version: 0, - Sha: Ptr("ce587453ced02b1526dfb4cb910479d431683101"), - Ref: Ptr("refs/heads/main"), + Sha: new("ce587453ced02b1526dfb4cb910479d431683101"), + Ref: new("refs/heads/main"), Job: &DependencyGraphSnapshotJob{ - Correlator: Ptr("yourworkflowname_youractionname"), - ID: Ptr("yourrunid"), - HTMLURL: Ptr("https://example.com"), + Correlator: new("yourworkflowname_youractionname"), + ID: new("yourrunid"), + HTMLURL: new("https://example.com"), }, Detector: &DependencyGraphSnapshotDetector{ - Name: Ptr("octo-detector"), - Version: Ptr("0.0.1"), - URL: Ptr("https://github.com/octo-org/octo-repo"), + Name: new("octo-detector"), + Version: new("0.0.1"), + URL: new("https://github.com/octo-org/octo-repo"), }, Scanned: &referenceTimestamp, Metadata: map[string]any{ @@ -38,32 +38,32 @@ func TestDependencyGraphService_CreateSnapshot(t *testing.T) { }, Manifests: map[string]*DependencyGraphSnapshotManifest{ "package-lock.json": { - Name: Ptr("package-lock.json"), - File: &DependencyGraphSnapshotManifestFile{SourceLocation: Ptr("src/package-lock.json")}, + Name: new("package-lock.json"), + File: &DependencyGraphSnapshotManifestFile{SourceLocation: new("src/package-lock.json")}, Metadata: map[string]any{ "key1": "value1", "key2": "value2", }, Resolved: map[string]*DependencyGraphSnapshotResolvedDependency{ "@actions/core": { - PackageURL: Ptr("pkg:/npm/%40actions/core@1.1.9"), - Relationship: Ptr("direct"), - Scope: Ptr("runtime"), + PackageURL: new("pkg:/npm/%40actions/core@1.1.9"), + Relationship: new("direct"), + Scope: new("runtime"), Metadata: map[string]any{ "licenses": "MIT", }, Dependencies: []string{"@actions/http-client"}, }, "@actions/http-client": { - PackageURL: Ptr("pkg:/npm/%40actions/http-client@1.0.7"), - Relationship: Ptr("indirect"), - Scope: Ptr("runtime"), + PackageURL: new("pkg:/npm/%40actions/http-client@1.0.7"), + Relationship: new("indirect"), + Scope: new("runtime"), Dependencies: []string{"tunnel"}, }, "tunnel": { - PackageURL: Ptr("pkg:/npm/tunnel@0.0.6"), - Relationship: Ptr("indirect"), - Scope: Ptr("runtime"), + PackageURL: new("pkg:/npm/tunnel@0.0.6"), + Relationship: new("indirect"), + Scope: new("runtime"), }, }, }, @@ -85,8 +85,8 @@ func TestDependencyGraphService_CreateSnapshot(t *testing.T) { want := &DependencyGraphSnapshotCreationData{ ID: 12345, CreatedAt: &referenceTimestamp, - Message: Ptr("Dependency results for the repo have been successfully updated."), - Result: Ptr("SUCCESS"), + Message: new("Dependency results for the repo have been successfully updated."), + Result: new("SUCCESS"), } if !cmp.Equal(snapshotCreationData, want) { t.Errorf("DependencyGraph.CreateSnapshot returned %+v, want %+v", snapshotCreationData, want) diff --git a/github/dependency_graph_test.go b/github/dependency_graph_test.go index 994c87fa18a..5281c570672 100644 --- a/github/dependency_graph_test.go +++ b/github/dependency_graph_test.go @@ -46,11 +46,11 @@ func TestDependencyGraphService_GetSBOM(t *testing.T) { CreationInfo: &CreationInfo{ Created: &referenceTimestamp, }, - Name: Ptr("owner/repo"), + Name: new("owner/repo"), Packages: []*RepoDependencies{ { - Name: Ptr("rubygems:rails"), - VersionInfo: Ptr("1.0.0"), + Name: new("rubygems:rails"), + VersionInfo: new("1.0.0"), }, }, }, diff --git a/github/enterprise_actions_hosted_runners_test.go b/github/enterprise_actions_hosted_runners_test.go index abb6df8db6b..889aba29662 100644 --- a/github/enterprise_actions_hosted_runners_test.go +++ b/github/enterprise_actions_hosted_runners_test.go @@ -84,13 +84,13 @@ func TestEnterpriseService_ListHostedRunners(t *testing.T) { TotalCount: 2, Runners: []*HostedRunner{ { - ID: Ptr(int64(5)), - Name: Ptr("My hosted ubuntu runner"), - RunnerGroupID: Ptr(int64(2)), - Platform: Ptr("linux-x64"), + ID: new(int64(5)), + Name: new("My hosted ubuntu runner"), + RunnerGroupID: new(int64(2)), + Platform: new("linux-x64"), ImageDetails: &HostedRunnerImageDetail{ - ID: Ptr("ubuntu-20.04"), - SizeGB: Ptr(int64(86)), + ID: new("ubuntu-20.04"), + SizeGB: new(int64(86)), }, MachineSizeDetails: &HostedRunnerMachineSpec{ ID: "4-core", @@ -98,9 +98,9 @@ func TestEnterpriseService_ListHostedRunners(t *testing.T) { MemoryGB: 16, StorageGB: 150, }, - Status: Ptr("Ready"), - MaximumRunners: Ptr(int64(10)), - PublicIPEnabled: Ptr(true), + Status: new("Ready"), + MaximumRunners: new(int64(10)), + PublicIPEnabled: new(true), PublicIPs: []*HostedRunnerPublicIP{ { Enabled: true, @@ -111,13 +111,13 @@ func TestEnterpriseService_ListHostedRunners(t *testing.T) { LastActiveOn: &referenceTimestamp, }, { - ID: Ptr(int64(7)), - Name: Ptr("My hosted Windows runner"), - RunnerGroupID: Ptr(int64(2)), - Platform: Ptr("win-x64"), + ID: new(int64(7)), + Name: new("My hosted Windows runner"), + RunnerGroupID: new(int64(2)), + Platform: new("win-x64"), ImageDetails: &HostedRunnerImageDetail{ - ID: Ptr("windows-latest"), - SizeGB: Ptr(int64(256)), + ID: new("windows-latest"), + SizeGB: new(int64(256)), }, MachineSizeDetails: &HostedRunnerMachineSpec{ ID: "8-core", @@ -125,9 +125,9 @@ func TestEnterpriseService_ListHostedRunners(t *testing.T) { MemoryGB: 32, StorageGB: 300, }, - Status: Ptr("Ready"), - MaximumRunners: Ptr(int64(20)), - PublicIPEnabled: Ptr(false), + Status: new("Ready"), + MaximumRunners: new(int64(20)), + PublicIPEnabled: new(false), PublicIPs: []*HostedRunnerPublicIP{}, LastActiveOn: &referenceTimestamp, }, @@ -193,13 +193,13 @@ func TestEnterpriseService_CreateHostedRunner(t *testing.T) { Image: HostedRunnerImage{ ID: "ubuntu-latest", Source: "github", - Version: Ptr("latest"), + Version: new("latest"), }, RunnerGroupID: 1, Size: "4-core", - MaximumRunners: Ptr(int64(50)), - EnableStaticIP: Ptr(false), - ImageGen: Ptr(true), + MaximumRunners: new(int64(50)), + EnableStaticIP: new(false), + ImageGen: new(true), } hostedRunner, _, err := client.Enterprise.CreateHostedRunner(ctx, "o", req) if err != nil { @@ -207,13 +207,13 @@ func TestEnterpriseService_CreateHostedRunner(t *testing.T) { } want := &HostedRunner{ - ID: Ptr(int64(5)), - Name: Ptr("My hosted ubuntu runner"), - RunnerGroupID: Ptr(int64(2)), - Platform: Ptr("linux-x64"), + ID: new(int64(5)), + Name: new("My hosted ubuntu runner"), + RunnerGroupID: new(int64(2)), + Platform: new("linux-x64"), ImageDetails: &HostedRunnerImageDetail{ - ID: Ptr("ubuntu-20.04"), - SizeGB: Ptr(int64(86)), + ID: new("ubuntu-20.04"), + SizeGB: new(int64(86)), }, MachineSizeDetails: &HostedRunnerMachineSpec{ ID: "4-core", @@ -221,9 +221,9 @@ func TestEnterpriseService_CreateHostedRunner(t *testing.T) { MemoryGB: 16, StorageGB: 150, }, - Status: Ptr("Ready"), - MaximumRunners: Ptr(int64(10)), - PublicIPEnabled: Ptr(true), + Status: new("Ready"), + MaximumRunners: new(int64(10)), + PublicIPEnabled: new(true), PublicIPs: []*HostedRunnerPublicIP{ { Enabled: true, @@ -251,7 +251,7 @@ func TestEnterpriseService_CreateHostedRunner(t *testing.T) { Image: HostedRunnerImage{ ID: "ubuntu-latest", Source: "github", - Version: Ptr("latest"), + Version: new("latest"), }, RunnerGroupID: 1, }, @@ -272,7 +272,7 @@ func TestEnterpriseService_CreateHostedRunner(t *testing.T) { Image: HostedRunnerImage{ ID: "ubuntu-latest", Source: "github", - Version: Ptr("latest"), + Version: new("latest"), }, RunnerGroupID: 1, Size: "4-core", @@ -286,7 +286,7 @@ func TestEnterpriseService_CreateHostedRunner(t *testing.T) { Image: HostedRunnerImage{ ID: "ubuntu-latest", Source: "github", - Version: Ptr("latest"), + Version: new("latest"), }, Size: "4-core", }, @@ -621,13 +621,13 @@ func TestEnterpriseService_GetHostedRunner(t *testing.T) { } want := &HostedRunner{ - ID: Ptr(int64(5)), - Name: Ptr("My hosted ubuntu runner"), - RunnerGroupID: Ptr(int64(2)), - Platform: Ptr("linux-x64"), + ID: new(int64(5)), + Name: new("My hosted ubuntu runner"), + RunnerGroupID: new(int64(2)), + Platform: new("linux-x64"), ImageDetails: &HostedRunnerImageDetail{ - ID: Ptr("ubuntu-20.04"), - SizeGB: Ptr(int64(86)), + ID: new("ubuntu-20.04"), + SizeGB: new(int64(86)), }, MachineSizeDetails: &HostedRunnerMachineSpec{ ID: "4-core", @@ -635,9 +635,9 @@ func TestEnterpriseService_GetHostedRunner(t *testing.T) { MemoryGB: 16, StorageGB: 150, }, - Status: Ptr("Ready"), - MaximumRunners: Ptr(int64(10)), - PublicIPEnabled: Ptr(true), + Status: new("Ready"), + MaximumRunners: new(int64(10)), + PublicIPEnabled: new(true), PublicIPs: []*HostedRunnerPublicIP{ { Enabled: true, @@ -705,11 +705,11 @@ func TestEnterpriseService_UpdateHostedRunner(t *testing.T) { // Test for a valid update without `Size` ctx := t.Context() validReq := UpdateHostedRunnerRequest{ - Name: Ptr("My larger runner"), - RunnerGroupID: Ptr(int64(1)), - MaximumRunners: Ptr(int64(50)), - EnableStaticIP: Ptr(false), - ImageVersion: Ptr("1.0.0"), + Name: new("My larger runner"), + RunnerGroupID: new(int64(1)), + MaximumRunners: new(int64(50)), + EnableStaticIP: new(false), + ImageVersion: new("1.0.0"), } hostedRunner, _, err := client.Enterprise.UpdateHostedRunner(ctx, "o", 23, validReq) if err != nil { @@ -717,13 +717,13 @@ func TestEnterpriseService_UpdateHostedRunner(t *testing.T) { } want := &HostedRunner{ - ID: Ptr(int64(5)), - Name: Ptr("My hosted ubuntu runner"), - RunnerGroupID: Ptr(int64(2)), - Platform: Ptr("linux-x64"), + ID: new(int64(5)), + Name: new("My hosted ubuntu runner"), + RunnerGroupID: new(int64(2)), + Platform: new("linux-x64"), ImageDetails: &HostedRunnerImageDetail{ - ID: Ptr("ubuntu-20.04"), - SizeGB: Ptr(int64(86)), + ID: new("ubuntu-20.04"), + SizeGB: new(int64(86)), }, MachineSizeDetails: &HostedRunnerMachineSpec{ ID: "4-core", @@ -731,9 +731,9 @@ func TestEnterpriseService_UpdateHostedRunner(t *testing.T) { MemoryGB: 16, StorageGB: 150, }, - Status: Ptr("Ready"), - MaximumRunners: Ptr(int64(10)), - PublicIPEnabled: Ptr(true), + Status: new("Ready"), + MaximumRunners: new(int64(10)), + PublicIPEnabled: new(true), PublicIPs: []*HostedRunnerPublicIP{ { Enabled: true, @@ -805,13 +805,13 @@ func TestEnterpriseService_DeleteHostedRunner(t *testing.T) { } want := &HostedRunner{ - ID: Ptr(int64(5)), - Name: Ptr("My hosted ubuntu runner"), - RunnerGroupID: Ptr(int64(2)), - Platform: Ptr("linux-x64"), + ID: new(int64(5)), + Name: new("My hosted ubuntu runner"), + RunnerGroupID: new(int64(2)), + Platform: new("linux-x64"), ImageDetails: &HostedRunnerImageDetail{ - ID: Ptr("ubuntu-20.04"), - SizeGB: Ptr(int64(86)), + ID: new("ubuntu-20.04"), + SizeGB: new(int64(86)), }, MachineSizeDetails: &HostedRunnerMachineSpec{ ID: "4-core", @@ -819,9 +819,9 @@ func TestEnterpriseService_DeleteHostedRunner(t *testing.T) { MemoryGB: 16, StorageGB: 150, }, - Status: Ptr("Ready"), - MaximumRunners: Ptr(int64(10)), - PublicIPEnabled: Ptr(true), + Status: new("Ready"), + MaximumRunners: new(int64(10)), + PublicIPEnabled: new(true), PublicIPs: []*HostedRunnerPublicIP{ { Enabled: true, diff --git a/github/enterprise_actions_runner_groups_test.go b/github/enterprise_actions_runner_groups_test.go index f77a4ff0450..92b8bfef510 100644 --- a/github/enterprise_actions_runner_groups_test.go +++ b/github/enterprise_actions_runner_groups_test.go @@ -31,11 +31,11 @@ func TestEnterpriseService_ListRunnerGroups(t *testing.T) { } want := &EnterpriseRunnerGroups{ - TotalCount: Ptr(3), + TotalCount: new(3), RunnerGroups: []*EnterpriseRunnerGroup{ - {ID: Ptr(int64(1)), Name: Ptr("Default"), Visibility: Ptr("all"), Default: Ptr(true), RunnersURL: Ptr("https://api.github.com/enterprises/octo-enterprise/actions/runner_groups/1/runners"), Inherited: Ptr(false), AllowsPublicRepositories: Ptr(true), RestrictedToWorkflows: Ptr(true), SelectedWorkflows: []string{"a", "b"}}, - {ID: Ptr(int64(2)), Name: Ptr("octo-runner-group"), Visibility: Ptr("selected"), Default: Ptr(false), SelectedOrganizationsURL: Ptr("https://api.github.com/enterprises/octo-enterprise/actions/runner_groups/2/organizations"), RunnersURL: Ptr("https://api.github.com/enterprises/octo-enterprise/actions/runner_groups/2/runners"), Inherited: Ptr(true), AllowsPublicRepositories: Ptr(true), RestrictedToWorkflows: Ptr(false), SelectedWorkflows: []string{}}, - {ID: Ptr(int64(3)), Name: Ptr("expensive-hardware"), Visibility: Ptr("private"), Default: Ptr(false), RunnersURL: Ptr("https://api.github.com/enterprises/octo-enterprise/actions/runner_groups/3/runners"), Inherited: Ptr(false), AllowsPublicRepositories: Ptr(true), RestrictedToWorkflows: Ptr(false), SelectedWorkflows: []string{}}, + {ID: new(int64(1)), Name: new("Default"), Visibility: new("all"), Default: new(true), RunnersURL: new("https://api.github.com/enterprises/octo-enterprise/actions/runner_groups/1/runners"), Inherited: new(false), AllowsPublicRepositories: new(true), RestrictedToWorkflows: new(true), SelectedWorkflows: []string{"a", "b"}}, + {ID: new(int64(2)), Name: new("octo-runner-group"), Visibility: new("selected"), Default: new(false), SelectedOrganizationsURL: new("https://api.github.com/enterprises/octo-enterprise/actions/runner_groups/2/organizations"), RunnersURL: new("https://api.github.com/enterprises/octo-enterprise/actions/runner_groups/2/runners"), Inherited: new(true), AllowsPublicRepositories: new(true), RestrictedToWorkflows: new(false), SelectedWorkflows: []string{}}, + {ID: new(int64(3)), Name: new("expensive-hardware"), Visibility: new("private"), Default: new(false), RunnersURL: new("https://api.github.com/enterprises/octo-enterprise/actions/runner_groups/3/runners"), Inherited: new(false), AllowsPublicRepositories: new(true), RestrictedToWorkflows: new(false), SelectedWorkflows: []string{}}, }, } if !cmp.Equal(groups, want) { @@ -75,11 +75,11 @@ func TestEnterpriseService_ListRunnerGroupsVisibleToOrganization(t *testing.T) { } want := &EnterpriseRunnerGroups{ - TotalCount: Ptr(3), + TotalCount: new(3), RunnerGroups: []*EnterpriseRunnerGroup{ - {ID: Ptr(int64(1)), Name: Ptr("Default"), Visibility: Ptr("all"), Default: Ptr(true), RunnersURL: Ptr("https://api.github.com/enterprises/octo-enterprise/actions/runner_groups/1/runners"), Inherited: Ptr(false), AllowsPublicRepositories: Ptr(true), RestrictedToWorkflows: Ptr(false), SelectedWorkflows: []string{}}, - {ID: Ptr(int64(2)), Name: Ptr("octo-runner-group"), Visibility: Ptr("selected"), Default: Ptr(false), SelectedOrganizationsURL: Ptr("https://api.github.com/enterprises/octo-enterprise/actions/runner_groups/2/organizations"), RunnersURL: Ptr("https://api.github.com/enterprises/octo-enterprise/actions/runner_groups/2/runners"), Inherited: Ptr(true), AllowsPublicRepositories: Ptr(true), RestrictedToWorkflows: Ptr(false), SelectedWorkflows: []string{}}, - {ID: Ptr(int64(3)), Name: Ptr("expensive-hardware"), Visibility: Ptr("private"), Default: Ptr(false), RunnersURL: Ptr("https://api.github.com/enterprises/octo-enterprise/actions/runner_groups/3/runners"), Inherited: Ptr(false), AllowsPublicRepositories: Ptr(true), RestrictedToWorkflows: Ptr(false), SelectedWorkflows: []string{}}, + {ID: new(int64(1)), Name: new("Default"), Visibility: new("all"), Default: new(true), RunnersURL: new("https://api.github.com/enterprises/octo-enterprise/actions/runner_groups/1/runners"), Inherited: new(false), AllowsPublicRepositories: new(true), RestrictedToWorkflows: new(false), SelectedWorkflows: []string{}}, + {ID: new(int64(2)), Name: new("octo-runner-group"), Visibility: new("selected"), Default: new(false), SelectedOrganizationsURL: new("https://api.github.com/enterprises/octo-enterprise/actions/runner_groups/2/organizations"), RunnersURL: new("https://api.github.com/enterprises/octo-enterprise/actions/runner_groups/2/runners"), Inherited: new(true), AllowsPublicRepositories: new(true), RestrictedToWorkflows: new(false), SelectedWorkflows: []string{}}, + {ID: new(int64(3)), Name: new("expensive-hardware"), Visibility: new("private"), Default: new(false), RunnersURL: new("https://api.github.com/enterprises/octo-enterprise/actions/runner_groups/3/runners"), Inherited: new(false), AllowsPublicRepositories: new(true), RestrictedToWorkflows: new(false), SelectedWorkflows: []string{}}, }, } if !cmp.Equal(groups, want) { @@ -117,15 +117,15 @@ func TestEnterpriseService_GetEnterpriseRunnerGroup(t *testing.T) { } want := &EnterpriseRunnerGroup{ - ID: Ptr(int64(2)), - Name: Ptr("octo-runner-group"), - Visibility: Ptr("selected"), - Default: Ptr(false), - SelectedOrganizationsURL: Ptr("https://api.github.com/enterprises/octo-enterprise/actions/runner_groups/2/organizations"), - RunnersURL: Ptr("https://api.github.com/enterprises/octo-enterprise/actions/runner_groups/2/runners"), - Inherited: Ptr(false), - AllowsPublicRepositories: Ptr(true), - RestrictedToWorkflows: Ptr(false), + ID: new(int64(2)), + Name: new("octo-runner-group"), + Visibility: new("selected"), + Default: new(false), + SelectedOrganizationsURL: new("https://api.github.com/enterprises/octo-enterprise/actions/runner_groups/2/organizations"), + RunnersURL: new("https://api.github.com/enterprises/octo-enterprise/actions/runner_groups/2/runners"), + Inherited: new(false), + AllowsPublicRepositories: new(true), + RestrictedToWorkflows: new(false), SelectedWorkflows: []string{}, } @@ -184,10 +184,10 @@ func TestEnterpriseService_CreateEnterpriseRunnerGroup(t *testing.T) { ctx := t.Context() req := CreateEnterpriseRunnerGroupRequest{ - Name: Ptr("octo-runner-group"), - Visibility: Ptr("selected"), - AllowsPublicRepositories: Ptr(true), - RestrictedToWorkflows: Ptr(false), + Name: new("octo-runner-group"), + Visibility: new("selected"), + AllowsPublicRepositories: new(true), + RestrictedToWorkflows: new(false), SelectedWorkflows: []string{}, } group, _, err := client.Enterprise.CreateEnterpriseRunnerGroup(ctx, "o", req) @@ -196,15 +196,15 @@ func TestEnterpriseService_CreateEnterpriseRunnerGroup(t *testing.T) { } want := &EnterpriseRunnerGroup{ - ID: Ptr(int64(2)), - Name: Ptr("octo-runner-group"), - Visibility: Ptr("selected"), - Default: Ptr(false), - SelectedOrganizationsURL: Ptr("https://api.github.com/enterprises/octo-enterprise/actions/runner_groups/2/organizations"), - RunnersURL: Ptr("https://api.github.com/enterprises/octo-enterprise/actions/runner_groups/2/runners"), - Inherited: Ptr(false), - AllowsPublicRepositories: Ptr(true), - RestrictedToWorkflows: Ptr(false), + ID: new(int64(2)), + Name: new("octo-runner-group"), + Visibility: new("selected"), + Default: new(false), + SelectedOrganizationsURL: new("https://api.github.com/enterprises/octo-enterprise/actions/runner_groups/2/organizations"), + RunnersURL: new("https://api.github.com/enterprises/octo-enterprise/actions/runner_groups/2/runners"), + Inherited: new(false), + AllowsPublicRepositories: new(true), + RestrictedToWorkflows: new(false), SelectedWorkflows: []string{}, } @@ -238,10 +238,10 @@ func TestEnterpriseService_UpdateEnterpriseRunnerGroup(t *testing.T) { ctx := t.Context() req := UpdateEnterpriseRunnerGroupRequest{ - Name: Ptr("octo-runner-group"), - Visibility: Ptr("selected"), - AllowsPublicRepositories: Ptr(true), - RestrictedToWorkflows: Ptr(false), + Name: new("octo-runner-group"), + Visibility: new("selected"), + AllowsPublicRepositories: new(true), + RestrictedToWorkflows: new(false), SelectedWorkflows: []string{}, } group, _, err := client.Enterprise.UpdateEnterpriseRunnerGroup(ctx, "o", 2, req) @@ -250,15 +250,15 @@ func TestEnterpriseService_UpdateEnterpriseRunnerGroup(t *testing.T) { } want := &EnterpriseRunnerGroup{ - ID: Ptr(int64(2)), - Name: Ptr("octo-runner-group"), - Visibility: Ptr("selected"), - Default: Ptr(false), - SelectedOrganizationsURL: Ptr("https://api.github.com/enterprises/octo-enterprise/actions/runner_groups/2/organizations"), - RunnersURL: Ptr("https://api.github.com/enterprises/octo-enterprise/actions/runner_groups/2/runners"), - Inherited: Ptr(false), - AllowsPublicRepositories: Ptr(true), - RestrictedToWorkflows: Ptr(false), + ID: new(int64(2)), + Name: new("octo-runner-group"), + Visibility: new("selected"), + Default: new(false), + SelectedOrganizationsURL: new("https://api.github.com/enterprises/octo-enterprise/actions/runner_groups/2/organizations"), + RunnersURL: new("https://api.github.com/enterprises/octo-enterprise/actions/runner_groups/2/runners"), + Inherited: new(false), + AllowsPublicRepositories: new(true), + RestrictedToWorkflows: new(false), SelectedWorkflows: []string{}, } @@ -299,9 +299,9 @@ func TestEnterpriseService_ListOrganizationAccessRunnerGroup(t *testing.T) { } want := &ListOrganizations{ - TotalCount: Ptr(1), + TotalCount: new(1), Organizations: []*Organization{ - {ID: Ptr(int64(43)), NodeID: Ptr("MDEwOlJlcG9zaXRvcnkxMjk2MjY5"), Name: Ptr("Hello-World"), Login: Ptr("octocat")}, + {ID: new(int64(43)), NodeID: new("MDEwOlJlcG9zaXRvcnkxMjk2MjY5"), Name: new("Hello-World"), Login: new("octocat")}, }, } if !cmp.Equal(groups, want) { @@ -425,8 +425,8 @@ func TestEnterpriseService_ListRunnerGroupRunners(t *testing.T) { want := &Runners{ TotalCount: 2, Runners: []*Runner{ - {ID: Ptr(int64(23)), Name: Ptr("MBP"), OS: Ptr("macos"), Status: Ptr("online")}, - {ID: Ptr(int64(24)), Name: Ptr("iMac"), OS: Ptr("macos"), Status: Ptr("offline")}, + {ID: new(int64(23)), Name: new("MBP"), OS: new("macos"), Status: new("online")}, + {ID: new(int64(24)), Name: new("iMac"), OS: new("macos"), Status: new("offline")}, }, } if !cmp.Equal(runners, want) { diff --git a/github/enterprise_actions_runners_test.go b/github/enterprise_actions_runners_test.go index 8edbc966e80..8a9a55f0d5c 100644 --- a/github/enterprise_actions_runners_test.go +++ b/github/enterprise_actions_runners_test.go @@ -31,7 +31,7 @@ func TestEnterpriseService_CreateJITConfig(t *testing.T) { t.Errorf("Enterprise.CreateJITConfig returned error: %v", err) } - want := &JITRunnerConfig{EncodedJITConfig: Ptr("foo")} + want := &JITRunnerConfig{EncodedJITConfig: new("foo")} if !cmp.Equal(jitConfig, want) { t.Errorf("Enterprise.CreateJITConfig returned %+v, want %+v", jitConfig, want) } @@ -67,7 +67,7 @@ func TestEnterpriseService_CreateRegistrationToken(t *testing.T) { } want := &RegistrationToken{ - Token: Ptr("LLBF3JGZDX3P5PMEXLND6TS6FCWO6"), + Token: new("LLBF3JGZDX3P5PMEXLND6TS6FCWO6"), ExpiresAt: &referenceTimestamp, } if !cmp.Equal(token, want) { @@ -100,7 +100,7 @@ func TestEnterpriseService_ListRunners(t *testing.T) { }) opts := &ListRunnersOptions{ - Name: Ptr("MBP"), + Name: new("MBP"), ListOptions: ListOptions{Page: 2, PerPage: 2}, } ctx := t.Context() @@ -112,7 +112,7 @@ func TestEnterpriseService_ListRunners(t *testing.T) { want := &Runners{ TotalCount: 1, Runners: []*Runner{ - {ID: Ptr(int64(23)), Name: Ptr("MBP"), OS: Ptr("macos"), Status: Ptr("online")}, + {ID: new(int64(23)), Name: new("MBP"), OS: new("macos"), Status: new("online")}, }, } if !cmp.Equal(runners, want) { @@ -150,10 +150,10 @@ func TestEnterpriseService_GetRunner(t *testing.T) { } want := &Runner{ - ID: Ptr(int64(23)), - Name: Ptr("MBP"), - OS: Ptr("macos"), - Status: Ptr("online"), + ID: new(int64(23)), + Name: new("MBP"), + OS: new("macos"), + Status: new("online"), } if !cmp.Equal(runner, want) { t.Errorf("Enterprise.GetRunner returned %+v, want %+v", runner, want) @@ -215,11 +215,11 @@ func TestEnterpriseService_ListRunnerApplicationDownloads(t *testing.T) { } want := []*RunnerApplicationDownload{ - {OS: Ptr("osx"), Architecture: Ptr("x64"), DownloadURL: Ptr("https://github.com/actions/runner/releases/download/v2.164.0/actions-runner-osx-x64-2.164.0.tar.gz"), Filename: Ptr("actions-runner-osx-x64-2.164.0.tar.gz")}, - {OS: Ptr("linux"), Architecture: Ptr("x64"), DownloadURL: Ptr("https://github.com/actions/runner/releases/download/v2.164.0/actions-runner-linux-x64-2.164.0.tar.gz"), Filename: Ptr("actions-runner-linux-x64-2.164.0.tar.gz")}, - {OS: Ptr("linux"), Architecture: Ptr("arm"), DownloadURL: Ptr("https://github.com/actions/runner/releases/download/v2.164.0/actions-runner-linux-arm-2.164.0.tar.gz"), Filename: Ptr("actions-runner-linux-arm-2.164.0.tar.gz")}, - {OS: Ptr("win"), Architecture: Ptr("x64"), DownloadURL: Ptr("https://github.com/actions/runner/releases/download/v2.164.0/actions-runner-win-x64-2.164.0.zip"), Filename: Ptr("actions-runner-win-x64-2.164.0.zip")}, - {OS: Ptr("linux"), Architecture: Ptr("arm64"), DownloadURL: Ptr("https://github.com/actions/runner/releases/download/v2.164.0/actions-runner-linux-arm64-2.164.0.tar.gz"), Filename: Ptr("actions-runner-linux-arm64-2.164.0.tar.gz")}, + {OS: new("osx"), Architecture: new("x64"), DownloadURL: new("https://github.com/actions/runner/releases/download/v2.164.0/actions-runner-osx-x64-2.164.0.tar.gz"), Filename: new("actions-runner-osx-x64-2.164.0.tar.gz")}, + {OS: new("linux"), Architecture: new("x64"), DownloadURL: new("https://github.com/actions/runner/releases/download/v2.164.0/actions-runner-linux-x64-2.164.0.tar.gz"), Filename: new("actions-runner-linux-x64-2.164.0.tar.gz")}, + {OS: new("linux"), Architecture: new("arm"), DownloadURL: new("https://github.com/actions/runner/releases/download/v2.164.0/actions-runner-linux-arm-2.164.0.tar.gz"), Filename: new("actions-runner-linux-arm-2.164.0.tar.gz")}, + {OS: new("win"), Architecture: new("x64"), DownloadURL: new("https://github.com/actions/runner/releases/download/v2.164.0/actions-runner-win-x64-2.164.0.zip"), Filename: new("actions-runner-win-x64-2.164.0.zip")}, + {OS: new("linux"), Architecture: new("arm64"), DownloadURL: new("https://github.com/actions/runner/releases/download/v2.164.0/actions-runner-linux-arm64-2.164.0.tar.gz"), Filename: new("actions-runner-linux-arm64-2.164.0.tar.gz")}, } if !cmp.Equal(downloads, want) { t.Errorf("Enterprise.ListRunnerApplicationDownloads returned %+v, want %+v", downloads, want) diff --git a/github/enterprise_app_installation_test.go b/github/enterprise_app_installation_test.go index b42318f70a7..e007b204cba 100644 --- a/github/enterprise_app_installation_test.go +++ b/github/enterprise_app_installation_test.go @@ -108,7 +108,7 @@ func TestEnterpriseService_ListAppInstallations(t *testing.T) { t.Errorf("ListAppInstallations returned error: %v", err) } want := []*Installation{ - {ID: Ptr(int64(99))}, + {ID: new(int64(99))}, } if !cmp.Equal(installations, want) { @@ -153,7 +153,7 @@ func TestEnterpriseService_InstallApp(t *testing.T) { t.Errorf("InstallApp returned error: %v", err) } - want := &Installation{ID: Ptr(int64(555))} + want := &Installation{ID: new(int64(555))} if !cmp.Equal(installation, want) { t.Errorf("InstallApp returned %+v, want %+v", installation, want) @@ -234,7 +234,7 @@ func TestEnterpriseService_UpdateAppInstallationRepositories(t *testing.T) { client, mux, _ := setup(t) input := UpdateAppInstallationRepositoriesRequest{ - RepositorySelection: Ptr("selected"), + RepositorySelection: new("selected"), Repositories: []string{"hello-world", "hello-world-2"}, } @@ -250,7 +250,7 @@ func TestEnterpriseService_UpdateAppInstallationRepositories(t *testing.T) { t.Errorf("Enterprise.UpdateAppInstallationRepositories returned error: %v", err) } - want := &Installation{ID: Ptr(int64(1)), RepositorySelection: Ptr("selected")} + want := &Installation{ID: new(int64(1)), RepositorySelection: new("selected")} if diff := cmp.Diff(inst, want); diff != "" { t.Errorf("Enterprise.UpdateAppInstallationRepositories returned diff (-want +got):\n%v", diff) } diff --git a/github/enterprise_audit_log_test.go b/github/enterprise_audit_log_test.go index b4cc8ee2fce..f9f5e6f4af0 100644 --- a/github/enterprise_audit_log_test.go +++ b/github/enterprise_audit_log_test.go @@ -42,9 +42,9 @@ func TestEnterpriseService_GetAuditLog(t *testing.T) { ]`) }) getOpts := GetAuditLogOptions{ - Include: Ptr("all"), - Phrase: Ptr("action:workflows"), - Order: Ptr("asc"), + Include: new("all"), + Phrase: new("action:workflows"), + Order: new("asc"), } ctx := t.Context() auditEntries, _, err := client.Enterprise.GetAuditLog(ctx, "e", &getOpts) @@ -55,11 +55,11 @@ func TestEnterpriseService_GetAuditLog(t *testing.T) { want := []*AuditEntry{ { Timestamp: &Timestamp{timestamp}, - DocumentID: Ptr("beeZYapIUe-wKg5-beadb33"), - Action: Ptr("workflows.completed_workflow_run"), - Actor: Ptr("testactor"), + DocumentID: new("beeZYapIUe-wKg5-beadb33"), + Action: new("workflows.completed_workflow_run"), + Actor: new("testactor"), CreatedAt: &Timestamp{timestamp}, - Org: Ptr("o"), + Org: new("o"), AdditionalFields: map[string]any{ "completed_at": "2021-03-07T00:35:08.000Z", "conclusion": "success", diff --git a/github/enterprise_billing_cost_centers_test.go b/github/enterprise_billing_cost_centers_test.go index 3994c06dae5..bdfbedb91dc 100644 --- a/github/enterprise_billing_cost_centers_test.go +++ b/github/enterprise_billing_cost_centers_test.go @@ -57,7 +57,7 @@ func TestEnterpriseService_ListCostCenters(t *testing.T) { ctx := t.Context() opts := &ListCostCenterOptions{ - State: Ptr("active"), + State: new("active"), } costCenters, _, err := client.Enterprise.ListCostCenters(ctx, "e", opts) if err != nil { @@ -69,8 +69,8 @@ func TestEnterpriseService_ListCostCenters(t *testing.T) { { ID: "2eeb8ffe-6903-11ee-8c99-0242ac120002", Name: "Cost Center Name", - State: Ptr("active"), - AzureSubscription: Ptr("aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"), + State: new("active"), + AzureSubscription: new("aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"), Resources: []*CostCenterResource{ { Type: "User", @@ -85,7 +85,7 @@ func TestEnterpriseService_ListCostCenters(t *testing.T) { { ID: "3ffb9ffe-6903-11ee-8c99-0242ac120003", Name: "Another Cost Center", - State: Ptr("active"), + State: new("active"), Resources: []*CostCenterResource{ { Type: "User", @@ -213,8 +213,8 @@ func TestEnterpriseService_GetCostCenter(t *testing.T) { want := &CostCenter{ ID: "2eeb8ffe-6903-11ee-8c99-0242ac120002", Name: "Cost Center Name", - State: Ptr("active"), - AzureSubscription: Ptr("aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"), + State: new("active"), + AzureSubscription: new("aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"), Resources: []*CostCenterResource{ { Type: "User", @@ -292,8 +292,8 @@ func TestEnterpriseService_UpdateCostCenter(t *testing.T) { want := &CostCenter{ ID: "2eeb8ffe-6903-11ee-8c99-0242ac120002", Name: "Updated Cost Center Name", - State: Ptr("active"), - AzureSubscription: Ptr("aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"), + State: new("active"), + AzureSubscription: new("aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"), Resources: []*CostCenterResource{ { Type: "User", @@ -427,22 +427,22 @@ func TestEnterpriseService_AddResourcesToCostCenter(t *testing.T) { } want := &AddResourcesToCostCenterResponse{ - Message: Ptr("Resources successfully added to the cost center."), + Message: new("Resources successfully added to the cost center."), ReassignedResources: []*ReassignedResource{ { - ResourceType: Ptr("user"), - Name: Ptr("monalisa"), - PreviousCostCenter: Ptr("old-cost-center"), + ResourceType: new("user"), + Name: new("monalisa"), + PreviousCostCenter: new("old-cost-center"), }, { - ResourceType: Ptr("organization"), - Name: Ptr("octo-org"), - PreviousCostCenter: Ptr("another-cost-center"), + ResourceType: new("organization"), + Name: new("octo-org"), + PreviousCostCenter: new("another-cost-center"), }, { - ResourceType: Ptr("repository"), - Name: Ptr("octo-repo"), - PreviousCostCenter: Ptr("yet-another-cost-center"), + ResourceType: new("repository"), + Name: new("octo-repo"), + PreviousCostCenter: new("yet-another-cost-center"), }, }, } @@ -497,7 +497,7 @@ func TestEnterpriseService_RemoveResourcesFromCostCenter(t *testing.T) { } want := &RemoveResourcesFromCostCenterResponse{ - Message: Ptr("Resources successfully removed from the cost center."), + Message: new("Resources successfully removed from the cost center."), } if !cmp.Equal(result, want) { t.Errorf("Enterprise.RemoveResourcesFromCostCenter returned %+v, want %+v", result, want) diff --git a/github/enterprise_billing_test.go b/github/enterprise_billing_test.go index f180d90e7f9..9f233dd7158 100644 --- a/github/enterprise_billing_test.go +++ b/github/enterprise_billing_test.go @@ -71,7 +71,7 @@ func TestEnterpriseService_GetUsageReport(t *testing.T) { DiscountAmount: 0.0, NetAmount: 0.8, OrganizationName: "GitHub", - RepositoryName: Ptr("github/example"), + RepositoryName: new("github/example"), }, }, } @@ -293,13 +293,13 @@ func TestEnterpriseService_GetPremiumRequestUsageReport(t *testing.T) { want := &EnterpriseAggregatedUsageReport{ TimePeriod: EnterpriseUsageTimePeriod{ Year: 2025, - Month: Ptr(10), + Month: new(10), }, Enterprise: "GitHub", - Organization: Ptr("GitHub"), - User: Ptr("testuser"), - Product: Ptr("Copilot"), - Model: Ptr("GPT-5"), + Organization: new("GitHub"), + User: new("testuser"), + Product: new("Copilot"), + Model: new("GPT-5"), UsageItems: []*EnterpriseAggregatedUsageItem{ { Product: "Copilot", @@ -420,13 +420,13 @@ func TestEnterpriseService_GetAICreditUsage(t *testing.T) { want := &EnterpriseAggregatedUsageReport{ TimePeriod: EnterpriseUsageTimePeriod{ Year: 2025, - Month: Ptr(6), + Month: new(6), }, Enterprise: "GitHub", - Organization: Ptr("GitHub"), - User: Ptr("testuser"), - Product: Ptr("Copilot"), - Model: Ptr("GPT-5"), + Organization: new("GitHub"), + User: new("testuser"), + Product: new("Copilot"), + Model: new("GPT-5"), UsageItems: []*EnterpriseAggregatedUsageItem{ { Product: "Copilot", diff --git a/github/enterprise_budgets_test.go b/github/enterprise_budgets_test.go index d8a5d7af704..28b950b317b 100644 --- a/github/enterprise_budgets_test.go +++ b/github/enterprise_budgets_test.go @@ -48,20 +48,20 @@ func TestEnterpriseService_ListBudgets(t *testing.T) { want := &EnterpriseListBudgets{ Budgets: []*EnterpriseBudget{ { - ID: Ptr("2066deda-923f-43f9-88d2-62395a28c0cdd"), - BudgetType: Ptr(BudgetTypeProductPricing), - BudgetProductSKU: Ptr("actions"), - BudgetScope: Ptr(BudgetScopeEnterprise), - BudgetAmount: Ptr(1000), - PreventFurtherUsage: Ptr(true), + ID: new("2066deda-923f-43f9-88d2-62395a28c0cdd"), + BudgetType: new(BudgetTypeProductPricing), + BudgetProductSKU: new("actions"), + BudgetScope: new(BudgetScopeEnterprise), + BudgetAmount: new(1000), + PreventFurtherUsage: new(true), BudgetAlerting: &EnterpriseBudgetAlerting{ - WillAlert: Ptr(true), + WillAlert: new(true), AlertRecipients: []string{"enterprise-admin"}, }, }, }, - HasNextPage: Ptr(true), - TotalCount: Ptr(1), + HasNextPage: new(true), + TotalCount: new(1), } if !cmp.Equal(budgets, want) { t.Errorf("Enterprise.ListBudgets returned %+v, want %+v", budgets, want) @@ -100,7 +100,7 @@ func TestEnterpriseService_CreateBudget(t *testing.T) { PreventFurtherUsage: true, BudgetScope: BudgetScopeEnterprise, BudgetType: BudgetTypeProductPricing, - BudgetProductSKU: Ptr("actions"), + BudgetProductSKU: new("actions"), BudgetAlerting: &EnterpriseBudgetAlerting{}, } @@ -126,9 +126,9 @@ func TestEnterpriseService_CreateBudget(t *testing.T) { want := &EnterpriseCreateOrUpdateBudgetResponse{ Message: "Budget successfully created.", Budget: &EnterpriseBudget{ - ID: Ptr("b-123"), - BudgetAmount: Ptr(200), - PreventFurtherUsage: Ptr(true), + ID: new("b-123"), + BudgetAmount: new(200), + PreventFurtherUsage: new(true), }, } if !cmp.Equal(resp, want) { @@ -182,12 +182,12 @@ func TestEnterpriseService_GetBudget(t *testing.T) { } want := &EnterpriseBudget{ - ID: Ptr("2066deda-923f-43f9-88d2-62395a28c0cdd"), - BudgetType: Ptr(BudgetTypeProductPricing), - BudgetProductSKU: Ptr("actions_linux"), - BudgetScope: Ptr(BudgetScopeRepository), - BudgetAmount: Ptr(0), - PreventFurtherUsage: Ptr(true), + ID: new("2066deda-923f-43f9-88d2-62395a28c0cdd"), + BudgetType: new(BudgetTypeProductPricing), + BudgetProductSKU: new("actions_linux"), + BudgetScope: new(BudgetScopeRepository), + BudgetAmount: new(0), + PreventFurtherUsage: new(true), } if !cmp.Equal(budget, want) { t.Errorf("Enterprise.GetBudget returned %+v, want %+v", budget, want) @@ -222,8 +222,8 @@ func TestEnterpriseService_UpdateBudget(t *testing.T) { client, mux, _ := setup(t) req := EnterpriseUpdateBudget{ - BudgetAmount: Ptr(10), - PreventFurtherUsage: Ptr(false), + BudgetAmount: new(10), + PreventFurtherUsage: new(false), } mux.HandleFunc("/enterprises/e/settings/billing/budgets/b-123", func(w http.ResponseWriter, r *http.Request) { @@ -248,9 +248,9 @@ func TestEnterpriseService_UpdateBudget(t *testing.T) { want := &EnterpriseCreateOrUpdateBudgetResponse{ Message: "Budget successfully updated.", Budget: &EnterpriseBudget{ - ID: Ptr("b-123"), - BudgetAmount: Ptr(10), - PreventFurtherUsage: Ptr(false), + ID: new("b-123"), + BudgetAmount: new(10), + PreventFurtherUsage: new(false), }, } if !cmp.Equal(resp, want) { diff --git a/github/enterprise_code_security_and_analysis_test.go b/github/enterprise_code_security_and_analysis_test.go index 603ce809929..bbd9e9aa35d 100644 --- a/github/enterprise_code_security_and_analysis_test.go +++ b/github/enterprise_code_security_and_analysis_test.go @@ -39,11 +39,11 @@ func TestEnterpriseService_GetCodeSecurityAndAnalysis(t *testing.T) { t.Errorf("Enterprise.%v returned error: %v", methodName, err) } want := &EnterpriseSecurityAnalysisSettings{ - AdvancedSecurityEnabledForNewRepositories: Ptr(true), - SecretScanningEnabledForNewRepositories: Ptr(true), - SecretScanningPushProtectionEnabledForNewRepositories: Ptr(true), - SecretScanningPushProtectionCustomLink: Ptr("https://github.com/test-org/test-repo/blob/main/README.md"), - SecretScanningValidityChecksEnabled: Ptr(true), + AdvancedSecurityEnabledForNewRepositories: new(true), + SecretScanningEnabledForNewRepositories: new(true), + SecretScanningPushProtectionEnabledForNewRepositories: new(true), + SecretScanningPushProtectionCustomLink: new("https://github.com/test-org/test-repo/blob/main/README.md"), + SecretScanningValidityChecksEnabled: new(true), } if !cmp.Equal(settings, want) { @@ -69,11 +69,11 @@ func TestEnterpriseService_UpdateCodeSecurityAndAnalysis(t *testing.T) { client, mux, _ := setup(t) input := &EnterpriseSecurityAnalysisSettings{ - AdvancedSecurityEnabledForNewRepositories: Ptr(true), - SecretScanningEnabledForNewRepositories: Ptr(true), - SecretScanningPushProtectionEnabledForNewRepositories: Ptr(true), - SecretScanningPushProtectionCustomLink: Ptr("https://github.com/test-org/test-repo/blob/main/README.md"), - SecretScanningValidityChecksEnabled: Ptr(true), + AdvancedSecurityEnabledForNewRepositories: new(true), + SecretScanningEnabledForNewRepositories: new(true), + SecretScanningPushProtectionEnabledForNewRepositories: new(true), + SecretScanningPushProtectionCustomLink: new("https://github.com/test-org/test-repo/blob/main/README.md"), + SecretScanningValidityChecksEnabled: new(true), } mux.HandleFunc("/enterprises/e/code_security_and_analysis", func(_ http.ResponseWriter, r *http.Request) { diff --git a/github/enterprise_codesecurity_configurations_test.go b/github/enterprise_codesecurity_configurations_test.go index 2d53cf5a195..98d07417c71 100644 --- a/github/enterprise_codesecurity_configurations_test.go +++ b/github/enterprise_codesecurity_configurations_test.go @@ -43,8 +43,8 @@ func TestEnterpriseService_ListCodeSecurityConfigurations(t *testing.T) { } want := []*CodeSecurityConfiguration{ - {ID: Ptr(int64(1)), Name: "config1", Description: "desc1", CodeScanningDefaultSetup: Ptr("enabled")}, - {ID: Ptr(int64(2)), Name: "config2", Description: "desc2", PrivateVulnerabilityReporting: Ptr("enabled")}, + {ID: new(int64(1)), Name: "config1", Description: "desc1", CodeScanningDefaultSetup: new("enabled")}, + {ID: new(int64(2)), Name: "config2", Description: "desc2", PrivateVulnerabilityReporting: new("enabled")}, } if !cmp.Equal(configurations, want) { t.Errorf("Enterprise.ListCodeSecurityConfigurations returned %+v, want %+v", configurations, want) @@ -83,7 +83,7 @@ func TestEnterpriseService_GetCodeSecurityConfiguration(t *testing.T) { t.Errorf("Enterprise.GetCodeSecurityConfiguration returned error: %v", err) } - want := &CodeSecurityConfiguration{ID: Ptr(int64(1)), Name: "config1", Description: "desc1", CodeScanningDefaultSetup: Ptr("enabled")} + want := &CodeSecurityConfiguration{ID: new(int64(1)), Name: "config1", Description: "desc1", CodeScanningDefaultSetup: new("enabled")} if !cmp.Equal(configuration, want) { t.Errorf("Enterprise.GetCodeSecurityConfiguration returned %+v, want %+v", configuration, want) } @@ -111,7 +111,7 @@ func TestEnterpriseService_CreateCodeSecurityConfiguration(t *testing.T) { input := CodeSecurityConfiguration{ Name: "config1", Description: "desc1", - CodeScanningDefaultSetup: Ptr("enabled"), + CodeScanningDefaultSetup: new("enabled"), } mux.HandleFunc("/enterprises/e/code-security/configurations", func(w http.ResponseWriter, r *http.Request) { @@ -130,7 +130,7 @@ func TestEnterpriseService_CreateCodeSecurityConfiguration(t *testing.T) { t.Errorf("Enterprise.CreateCodeSecurityConfiguration returned error: %v", err) } - want := &CodeSecurityConfiguration{ID: Ptr(int64(1)), Name: "config1", Description: "desc1", CodeScanningDefaultSetup: Ptr("enabled")} + want := &CodeSecurityConfiguration{ID: new(int64(1)), Name: "config1", Description: "desc1", CodeScanningDefaultSetup: new("enabled")} if !cmp.Equal(configuration, want) { t.Errorf("Enterprise.CreateCodeSecurityConfiguration returned %+v, want %+v", configuration, want) } @@ -185,8 +185,8 @@ func TestEnterpriseService_ListDefaultCodeSecurityConfigurations(t *testing.T) { } want := []*CodeSecurityConfigurationWithDefaultForNewRepos{ - {DefaultForNewRepos: Ptr("public"), Configuration: &CodeSecurityConfiguration{ID: Ptr(int64(1)), Name: "config1", Description: "desc1", CodeScanningDefaultSetup: Ptr("enabled")}}, - {DefaultForNewRepos: Ptr("private_and_internal"), Configuration: &CodeSecurityConfiguration{ID: Ptr(int64(2)), Name: "config2", Description: "desc2", PrivateVulnerabilityReporting: Ptr("enabled")}}, + {DefaultForNewRepos: new("public"), Configuration: &CodeSecurityConfiguration{ID: new(int64(1)), Name: "config1", Description: "desc1", CodeScanningDefaultSetup: new("enabled")}}, + {DefaultForNewRepos: new("private_and_internal"), Configuration: &CodeSecurityConfiguration{ID: new(int64(2)), Name: "config2", Description: "desc2", PrivateVulnerabilityReporting: new("enabled")}}, } if !cmp.Equal(configurations, want) { t.Errorf("Enterprise.ListDefaultCodeSecurityConfigurations returned %+v, want %+v", configurations, want) @@ -215,7 +215,7 @@ func TestEnterpriseService_UpdateCodeSecurityConfiguration(t *testing.T) { input := CodeSecurityConfiguration{ Name: "config1", Description: "desc1", - CodeScanningDefaultSetup: Ptr("enabled"), + CodeScanningDefaultSetup: new("enabled"), } mux.HandleFunc("/enterprises/e/code-security/configurations/1", func(w http.ResponseWriter, r *http.Request) { @@ -234,7 +234,7 @@ func TestEnterpriseService_UpdateCodeSecurityConfiguration(t *testing.T) { t.Errorf("Enterprise.UpdateCodeSecurityConfiguration returned error: %v", err) } - want := &CodeSecurityConfiguration{ID: Ptr(int64(1)), Name: "config1", Description: "desc1", CodeScanningDefaultSetup: Ptr("enabled")} + want := &CodeSecurityConfiguration{ID: new(int64(1)), Name: "config1", Description: "desc1", CodeScanningDefaultSetup: new("enabled")} if !cmp.Equal(configuration, want) { t.Errorf("Enterprise.UpdateCodeSecurityConfiguration returned %+v, want %+v", configuration, want) } @@ -351,9 +351,9 @@ func TestEnterpriseService_SetDefaultCodeSecurityConfiguration(t *testing.T) { t.Errorf("Enterprise.SetDefaultCodeSecurityConfiguration returned status %v, want %v", resp.StatusCode, wantStatus) } want := &CodeSecurityConfigurationWithDefaultForNewRepos{ - DefaultForNewRepos: Ptr("all"), + DefaultForNewRepos: new("all"), Configuration: &CodeSecurityConfiguration{ - ID: Ptr(int64(1)), Name: "config1", Description: "desc1", CodeScanningDefaultSetup: Ptr("enabled"), + ID: new(int64(1)), Name: "config1", Description: "desc1", CodeScanningDefaultSetup: new("enabled"), }, } if !cmp.Equal(got, want) { @@ -407,8 +407,8 @@ func TestEnterpriseService_ListCodeSecurityConfigurationRepositories(t *testing. t.Errorf("Enterprise.ListCodeSecurityConfigurationRepositories returned error: %v", err) } want := []*RepositoryAttachment{ - {Status: Ptr("attached"), Repository: &Repository{ID: Ptr(int64(8)), Name: Ptr("repo8")}}, - {Status: Ptr("attached"), Repository: &Repository{ID: Ptr(int64(42)), Name: Ptr("repo42")}}, + {Status: new("attached"), Repository: &Repository{ID: new(int64(8)), Name: new("repo8")}}, + {Status: new("attached"), Repository: &Repository{ID: new(int64(42)), Name: new("repo42")}}, } if !cmp.Equal(attachments, want) { t.Errorf("Enterprise.ListCodeSecurityConfigurationRepositories returned %+v, want %+v", attachments, want) diff --git a/github/enterprise_licenses_test.go b/github/enterprise_licenses_test.go index 288e8572e88..6a8bbf39717 100644 --- a/github/enterprise_licenses_test.go +++ b/github/enterprise_licenses_test.go @@ -59,22 +59,22 @@ func TestEnterpriseService_ListConsumedLicenses(t *testing.T) { Users: []*EnterpriseLicensedUsers{ { GithubComLogin: "user1", - GithubComName: Ptr("User One"), + GithubComName: new("User One"), EnterpriseServerUserIDs: []string{"123", "456"}, GithubComUser: true, - EnterpriseServerUser: Ptr(false), + EnterpriseServerUser: new(false), VisualStudioSubscriptionUser: false, LicenseType: "Enterprise", - GithubComProfile: Ptr("https://github.com/user1"), + GithubComProfile: new("https://github.com/user1"), GithubComMemberRoles: []string{"member"}, GithubComEnterpriseRoles: []string{"member"}, GithubComVerifiedDomainEmails: []string{"user1@example.com"}, - GithubComSamlNameID: Ptr("saml123"), + GithubComSamlNameID: new("saml123"), GithubComOrgsWithPendingInvites: []string{}, - GithubComTwoFactorAuth: Ptr(true), + GithubComTwoFactorAuth: new(true), EnterpriseServerEmails: []string{"user1@example.com"}, - VisualStudioLicenseStatus: Ptr("active"), - VisualStudioSubscriptionEmail: Ptr("user1@example.com"), + VisualStudioLicenseStatus: new("active"), + VisualStudioSubscriptionEmail: new("user1@example.com"), TotalUserAccounts: 1, }, }, diff --git a/github/enterprise_manage_ghes_config_test.go b/github/enterprise_manage_ghes_config_test.go index cc43ead90b9..24d3faef18c 100644 --- a/github/enterprise_manage_ghes_config_test.go +++ b/github/enterprise_manage_ghes_config_test.go @@ -163,69 +163,69 @@ func TestEnterpriseService_Settings(t *testing.T) { } want := &ConfigSettings{ - PrivateMode: Ptr(false), - PublicPages: Ptr(false), - SubdomainIsolation: Ptr(true), - SignupEnabled: Ptr(false), - GithubHostname: Ptr("ghe.local"), - IdenticonsHost: Ptr("dotcom"), + PrivateMode: new(false), + PublicPages: new(false), + SubdomainIsolation: new(true), + SignupEnabled: new(false), + GithubHostname: new("ghe.local"), + IdenticonsHost: new("dotcom"), HTTPProxy: nil, - AuthMode: Ptr("default"), - ExpireSessions: Ptr(false), + AuthMode: new("default"), + ExpireSessions: new(false), AdminPassword: nil, - ConfigurationID: Ptr(int64(1401777404)), - ConfigurationRunCount: Ptr(4), + ConfigurationID: new(int64(1401777404)), + ConfigurationRunCount: new(4), Avatar: &ConfigSettingsAvatar{ - Enabled: Ptr(false), - URI: Ptr(""), + Enabled: new(false), + URI: new(""), }, Customer: &ConfigSettingsCustomer{ - Name: Ptr("GitHub"), - Email: Ptr("stannis"), - UUID: Ptr("af6cac80-e4e1-012e-d822-1231380e52e9"), + Name: new("GitHub"), + Email: new("stannis"), + UUID: new("af6cac80-e4e1-012e-d822-1231380e52e9"), Secret: nil, - PublicKeyData: Ptr("-"), + PublicKeyData: new("-"), }, License: &ConfigSettingsLicenseSettings{ - Seats: Ptr(0), - Evaluation: Ptr(false), - Perpetual: Ptr(false), - UnlimitedSeating: Ptr(true), - SupportKey: Ptr("ssh-rsa AAAAB3N...."), - SSHAllowed: Ptr(true), - ClusterSupport: Ptr(false), + Seats: new(0), + Evaluation: new(false), + Perpetual: new(false), + UnlimitedSeating: new(true), + SupportKey: new("ssh-rsa AAAAB3N...."), + SSHAllowed: new(true), + ClusterSupport: new(false), ExpireAt: &referenceTimestamp, }, GithubSSL: &ConfigSettingsGithubSSL{ - Enabled: Ptr(false), + Enabled: new(false), Cert: nil, Key: nil, }, LDAP: &ConfigSettingsLDAP{ Host: nil, - Port: Ptr(0), + Port: new(0), Base: []string{}, UID: nil, BindDN: nil, Password: nil, - Method: Ptr("Plain"), - SearchStrategy: Ptr("detect"), + Method: new("Plain"), + SearchStrategy: new("detect"), UserGroups: []string{}, AdminGroup: nil, - VirtualAttributeEnabled: Ptr(false), - RecursiveGroupSearch: Ptr(false), - PosixSupport: Ptr(true), - UserSyncEmails: Ptr(false), - UserSyncKeys: Ptr(false), - UserSyncInterval: Ptr(4), - TeamSyncInterval: Ptr(4), - SyncEnabled: Ptr(false), + VirtualAttributeEnabled: new(false), + RecursiveGroupSearch: new(false), + PosixSupport: new(true), + UserSyncEmails: new(false), + UserSyncKeys: new(false), + UserSyncInterval: new(4), + TeamSyncInterval: new(4), + SyncEnabled: new(false), Reconciliation: &ConfigSettingsLDAPReconciliation{ User: nil, Org: nil, }, Profile: &ConfigSettingsLDAPProfile{ - UID: Ptr("uid"), + UID: new("uid"), Name: nil, Mail: nil, Key: nil, @@ -239,60 +239,60 @@ func TestEnterpriseService_Settings(t *testing.T) { Certificate: nil, CertificatePath: nil, Issuer: nil, - IDPInitiatedSSO: Ptr(false), - DisableAdminDemote: Ptr(false), + IDPInitiatedSSO: new(false), + DisableAdminDemote: new(false), }, GithubOAuth: &ConfigSettingsGithubOAuth{ - ClientID: Ptr("12313412"), - ClientSecret: Ptr("kj123131132"), - OrganizationName: Ptr("Homestar Runners"), - OrganizationTeam: Ptr("homestarrunners/characters"), + ClientID: new("12313412"), + ClientSecret: new("kj123131132"), + OrganizationName: new("Homestar Runners"), + OrganizationTeam: new("homestarrunners/characters"), }, SMTP: &ConfigSettingsSMTP{ - Enabled: Ptr(true), - Address: Ptr("smtp.example.com"), - Authentication: Ptr("plain"), - Port: Ptr("1234"), - Domain: Ptr("blah"), - Username: Ptr("foo"), - UserName: Ptr("mr_foo"), - Password: Ptr("bar"), - DiscardToNoreplyAddress: Ptr(true), - SupportAddress: Ptr("enterprise@github.com"), - SupportAddressType: Ptr("email"), - NoreplyAddress: Ptr("noreply@github.com"), - EnableStarttlsAuto: Ptr(true), + Enabled: new(true), + Address: new("smtp.example.com"), + Authentication: new("plain"), + Port: new("1234"), + Domain: new("blah"), + Username: new("foo"), + UserName: new("mr_foo"), + Password: new("bar"), + DiscardToNoreplyAddress: new(true), + SupportAddress: new("enterprise@github.com"), + SupportAddressType: new("email"), + NoreplyAddress: new("noreply@github.com"), + EnableStarttlsAuto: new(true), }, NTP: &ConfigSettingsNTP{ - PrimaryServer: Ptr("example.com/primary"), - SecondaryServer: Ptr("example.com/secondary"), + PrimaryServer: new("example.com/primary"), + SecondaryServer: new("example.com/secondary"), }, Timezone: nil, SNMP: &ConfigSettingsSNMP{ - Enabled: Ptr(false), - Community: Ptr(""), + Enabled: new(false), + Community: new(""), }, Syslog: &ConfigSettingsSyslog{ - Enabled: Ptr(false), + Enabled: new(false), Server: nil, - ProtocolName: Ptr("udp"), + ProtocolName: new("udp"), }, Assets: nil, Pages: &ConfigSettingsPagesSettings{ - Enabled: Ptr(true), + Enabled: new(true), }, Collectd: &ConfigSettingsCollectd{ - Enabled: Ptr(false), + Enabled: new(false), Server: nil, - Port: Ptr(0), + Port: new(0), Encryption: nil, Username: nil, Password: nil, }, Mapping: &ConfigSettingsMapping{ - Enabled: Ptr(true), + Enabled: new(true), Tileserver: nil, - Basemap: Ptr("company.map-qsz2zrvs"), + Basemap: new("company.map-qsz2zrvs"), Token: nil, }, LoadBalancer: nil, @@ -334,7 +334,7 @@ func TestEnterpriseService_NodeMetadata(t *testing.T) { }) opt := &NodeQueryOptions{ - UUID: Ptr("1234-1234"), ClusterRoles: Ptr("primary"), + UUID: new("1234-1234"), ClusterRoles: new("primary"), } ctx := t.Context() configNodes, _, err := client.Enterprise.NodeMetadata(ctx, opt) @@ -343,10 +343,10 @@ func TestEnterpriseService_NodeMetadata(t *testing.T) { } want := &NodeMetadataStatus{ - Topology: Ptr("Cluster"), + Topology: new("Cluster"), Nodes: []*NodeDetails{{ - Hostname: Ptr("data1"), - UUID: Ptr("1b6cf518-f97c-11ed-8544-061d81f7eedb"), + Hostname: new("data1"), + UUID: new("1b6cf518-f97c-11ed-8544-061d81f7eedb"), ClusterRoles: []string{ "ConsulServer", }, @@ -384,7 +384,7 @@ func TestEnterpriseService_LicenseStatus(t *testing.T) { } want := []*LicenseCheck{{ - Status: Ptr("valid"), + Status: new("valid"), }} if !cmp.Equal(licenseCheck, want) { t.Errorf("Enterprise.LicenseStatus returned %+v, want %+v", licenseCheck, want) @@ -435,24 +435,24 @@ func TestEnterpriseService_License(t *testing.T) { } want := &LicenseStatus{ - AdvancedSecurityEnabled: Ptr(true), - AdvancedSecuritySeats: Ptr(0), - ClusterSupport: Ptr(false), - Company: Ptr("GitHub"), - CroquetSupport: Ptr(true), - CustomTerms: Ptr(true), - Evaluation: Ptr(false), + AdvancedSecurityEnabled: new(true), + AdvancedSecuritySeats: new(0), + ClusterSupport: new(false), + Company: new("GitHub"), + CroquetSupport: new(true), + CustomTerms: new(true), + Evaluation: new(false), ExpireAt: refTimestamp(1136178000), - InsightsEnabled: Ptr(true), + InsightsEnabled: new(true), InsightsExpireAt: refTimestamp(1136178001), LearningLabEvaluationExpires: refTimestamp(1136178002), - LearningLabSeats: Ptr(100), - Perpetual: Ptr(false), - ReferenceNumber: Ptr("32a145"), - Seats: Ptr(0), - SSHAllowed: Ptr(true), - SupportKey: Ptr(true), - UnlimitedSeating: Ptr(true), + LearningLabSeats: new(100), + Perpetual: new(false), + ReferenceNumber: new("32a145"), + Seats: new(0), + SSHAllowed: new(true), + SupportKey: new(true), + UnlimitedSeating: new(true), } if diff := cmp.Diff(want, license); diff != "" { t.Errorf("diff mismatch (-want +got):\n%v", diff) @@ -495,7 +495,7 @@ func TestEnterpriseService_ConfigApplyEvents(t *testing.T) { }) input := &ConfigApplyEventsOptions{ - LastRequestID: Ptr("387cd628c06d606700e79be368e5e574:0cde553750689"), + LastRequestID: new("387cd628c06d606700e79be368e5e574:0cde553750689"), } ctx := t.Context() @@ -506,20 +506,20 @@ func TestEnterpriseService_ConfigApplyEvents(t *testing.T) { want := &ConfigApplyEvents{ Nodes: []*ConfigApplyEventsNode{{ - Node: Ptr("ghes-01.lan"), - LastRequestID: Ptr("387cd628c06d606700e79be368e5e574:0cde553750689c76:0000000000000000"), + Node: new("ghes-01.lan"), + LastRequestID: new("387cd628c06d606700e79be368e5e574:0cde553750689c76:0000000000000000"), Events: []*ConfigApplyEventsNodeEvent{{ Timestamp: &referenceTimestamp, - SeverityText: Ptr("INFO"), - Body: Ptr("Validating services"), - EventName: Ptr("Enterprise::ConfigApply::PhaseValidation#config_phase_validation"), - Topology: Ptr("multinode"), - Hostname: Ptr("ghes-01.lan"), - ConfigRunID: Ptr("d34db33f"), - TraceID: Ptr("387cd628c06d606700e79be368e5e574"), - SpanID: Ptr("0cde553750689c76"), - SpanParentID: Ptr(int64(0)), - SpanDepth: Ptr(0), + SeverityText: new("INFO"), + Body: new("Validating services"), + EventName: new("Enterprise::ConfigApply::PhaseValidation#config_phase_validation"), + Topology: new("multinode"), + Hostname: new("ghes-01.lan"), + ConfigRunID: new("d34db33f"), + TraceID: new("387cd628c06d606700e79be368e5e574"), + SpanID: new("0cde553750689c76"), + SpanParentID: new(int64(0)), + SpanDepth: new(0), }}, }}, } @@ -551,7 +551,7 @@ func TestEnterpriseService_UpdateSettings(t *testing.T) { }) input := &ConfigSettings{ - PrivateMode: Ptr(false), + PrivateMode: new(false), } ctx := t.Context() @@ -621,7 +621,7 @@ func TestEnterpriseService_ConfigApply(t *testing.T) { client, mux, _ := setup(t) input := &ConfigApplyOptions{ - RunID: Ptr("1234"), + RunID: new("1234"), } mux.HandleFunc("/manage/v1/config/apply", func(w http.ResponseWriter, r *http.Request) { @@ -636,7 +636,7 @@ func TestEnterpriseService_ConfigApply(t *testing.T) { t.Errorf("Enterprise.ConfigApply returned error: %v", err) } want := &ConfigApplyOptions{ - RunID: Ptr("1234"), + RunID: new("1234"), } if !cmp.Equal(configApply, want) { t.Errorf("Enterprise.ConfigApply returned %+v, want %+v", configApply, want) @@ -657,7 +657,7 @@ func TestEnterpriseService_ConfigApplyStatus(t *testing.T) { client, mux, _ := setup(t) input := &ConfigApplyOptions{ - RunID: Ptr("1234"), + RunID: new("1234"), } mux.HandleFunc("/manage/v1/config/apply", func(w http.ResponseWriter, r *http.Request) { @@ -683,13 +683,13 @@ func TestEnterpriseService_ConfigApplyStatus(t *testing.T) { t.Errorf("Enterprise.ConfigApplyStatus returned error: %v", err) } want := &ConfigApplyStatus{ - Running: Ptr(true), - Successful: Ptr(false), + Running: new(true), + Successful: new(false), Nodes: []*ConfigApplyStatusNode{{ - RunID: Ptr("d34db33f"), - Hostname: Ptr("ghes-01.lan"), - Running: Ptr(true), - Successful: Ptr(false), + RunID: new("d34db33f"), + Hostname: new("ghes-01.lan"), + Running: new(true), + Successful: new(false), }}, } if !cmp.Equal(configApplyStatus, want) { diff --git a/github/enterprise_manage_ghes_maintenance_test.go b/github/enterprise_manage_ghes_maintenance_test.go index 0a3f3cf559d..8c124bd8045 100644 --- a/github/enterprise_manage_ghes_maintenance_test.go +++ b/github/enterprise_manage_ghes_maintenance_test.go @@ -43,7 +43,7 @@ func TestEnterpriseService_GetMaintenanceStatus(t *testing.T) { }) opt := &NodeQueryOptions{ - UUID: Ptr("1234-1234"), ClusterRoles: Ptr("primary"), + UUID: new("1234-1234"), ClusterRoles: new("primary"), } ctx := t.Context() maintenanceStatus, _, err := client.Enterprise.GetMaintenanceStatus(ctx, opt) @@ -52,17 +52,17 @@ func TestEnterpriseService_GetMaintenanceStatus(t *testing.T) { } want := []*MaintenanceStatus{{ - Hostname: Ptr("primary"), - UUID: Ptr("1b6cf518-f97c-11ed-8544-061d81f7eedb"), - Status: Ptr("scheduled"), + Hostname: new("primary"), + UUID: new("1b6cf518-f97c-11ed-8544-061d81f7eedb"), + Status: new("scheduled"), ScheduledTime: &referenceTimestamp, ConnectionServices: []*ConnectionServiceItem{{ - Name: Ptr("git operations"), - Number: Ptr(15), + Name: new("git operations"), + Number: new(15), }}, - CanUnsetMaintenance: Ptr(true), + CanUnsetMaintenance: new(true), IPExceptionList: []string{"1.1.1.1"}, - MaintenanceModeMessage: Ptr("Scheduled maintenance for upgrading."), + MaintenanceModeMessage: new("Scheduled maintenance for upgrading."), }} if !cmp.Equal(maintenanceStatus, want) { t.Errorf("Enterprise.GetMaintenanceStatus returned %+v, want %+v", maintenanceStatus, want) @@ -84,12 +84,12 @@ func TestEnterpriseService_CreateMaintenance(t *testing.T) { input := &MaintenanceOptions{ Enabled: true, - UUID: Ptr("1234-1234"), - When: Ptr("now"), + UUID: new("1234-1234"), + When: new("now"), IPExceptionList: []string{ "1.1.1.1", }, - MaintenanceModeMessage: Ptr("Scheduled maintenance for upgrading."), + MaintenanceModeMessage: new("Scheduled maintenance for upgrading."), } mux.HandleFunc("/manage/v1/maintenance", func(w http.ResponseWriter, r *http.Request) { @@ -104,7 +104,7 @@ func TestEnterpriseService_CreateMaintenance(t *testing.T) { t.Errorf("Enterprise.CreateMaintenance returned error: %v", err) } - want := []*MaintenanceOperationStatus{{Hostname: Ptr("primary"), UUID: Ptr("1b6cf518-f97c-11ed-8544-061d81f7eedb"), Message: Ptr("Scheduled maintenance for upgrading.")}} + want := []*MaintenanceOperationStatus{{Hostname: new("primary"), UUID: new("1b6cf518-f97c-11ed-8544-061d81f7eedb"), Message: new("Scheduled maintenance for upgrading.")}} if diff := cmp.Diff(want, maintenanceStatus); diff != "" { t.Errorf("diff mismatch (-want +got):\n%v", diff) } diff --git a/github/enterprise_manage_ghes_ssh_test.go b/github/enterprise_manage_ghes_ssh_test.go index 30cfdc23bf3..f319a5d132b 100644 --- a/github/enterprise_manage_ghes_ssh_test.go +++ b/github/enterprise_manage_ghes_ssh_test.go @@ -32,8 +32,8 @@ func TestEnterpriseService_GetSSHKey(t *testing.T) { } want := []*ClusterSSHKey{{ - Key: Ptr("ssh-rsa 1234"), - Fingerprint: Ptr("bd"), + Key: new("ssh-rsa 1234"), + Fingerprint: new("bd"), }} if !cmp.Equal(accessSSH, want) { t.Errorf("Enterprise.GetSSHKey returned %+v, want %+v", accessSSH, want) @@ -69,7 +69,7 @@ func TestEnterpriseService_DeleteSSHKey(t *testing.T) { t.Errorf("Enterprise.DeleteSSHKey returned error: %v", err) } - want := []*SSHKeyStatus{{Hostname: Ptr("primary"), UUID: Ptr("1b6cf518-f97c-11ed-8544-061d81f7eedb"), Message: Ptr("SSH key removed successfully")}} + want := []*SSHKeyStatus{{Hostname: new("primary"), UUID: new("1b6cf518-f97c-11ed-8544-061d81f7eedb"), Message: new("SSH key removed successfully")}} if diff := cmp.Diff(want, sshStatus); diff != "" { t.Errorf("diff mismatch (-want +got):\n%v", diff) } @@ -104,7 +104,7 @@ func TestEnterpriseService_CreateSSHKey(t *testing.T) { t.Errorf("Enterprise.CreateSSHKey returned error: %v", err) } - want := []*SSHKeyStatus{{Hostname: Ptr("primary"), UUID: Ptr("1b6cf518-f97c-11ed-8544-061d81f7eedb"), Message: Ptr("SSH key added successfully"), Modified: Ptr(true)}} + want := []*SSHKeyStatus{{Hostname: new("primary"), UUID: new("1b6cf518-f97c-11ed-8544-061d81f7eedb"), Message: new("SSH key added successfully"), Modified: new(true)}} if diff := cmp.Diff(want, sshStatus); diff != "" { t.Errorf("diff mismatch (-want +got):\n%v", diff) } diff --git a/github/enterprise_manage_ghes_test.go b/github/enterprise_manage_ghes_test.go index 1240b0cc5a6..fee760495ac 100644 --- a/github/enterprise_manage_ghes_test.go +++ b/github/enterprise_manage_ghes_test.go @@ -39,13 +39,13 @@ func TestEnterpriseService_CheckSystemRequirements(t *testing.T) { } want := &SystemRequirements{ - Status: Ptr("OK"), + Status: new("OK"), Nodes: []*SystemRequirementsNode{{ - Hostname: Ptr("primary"), - Status: Ptr("OK"), + Hostname: new("primary"), + Status: new("OK"), RolesStatus: []*SystemRequirementsNodeRoleStatus{{ - Status: Ptr("OK"), - Role: Ptr("ConsulServer"), + Status: new("OK"), + Role: new("ConsulServer"), }}, }}, } @@ -86,10 +86,10 @@ func TestEnterpriseService_ClusterStatus(t *testing.T) { } want := &ClusterStatus{ - Status: Ptr("OK"), + Status: new("OK"), Nodes: []*ClusterStatusNode{{ - Hostname: Ptr("primary"), - Status: Ptr("OK"), + Hostname: new("primary"), + Status: new("OK"), Services: []*ClusterStatusNodeServiceItem{}, }}, } @@ -128,7 +128,7 @@ func TestEnterpriseService_ReplicationStatus(t *testing.T) { }) opt := &NodeQueryOptions{ - UUID: Ptr("1234-1234"), ClusterRoles: Ptr("primary"), + UUID: new("1234-1234"), ClusterRoles: new("primary"), } ctx := t.Context() replicationStatus, _, err := client.Enterprise.ReplicationStatus(ctx, opt) @@ -137,10 +137,10 @@ func TestEnterpriseService_ReplicationStatus(t *testing.T) { } want := &ClusterStatus{ - Status: Ptr("OK"), + Status: new("OK"), Nodes: []*ClusterStatusNode{{ - Hostname: Ptr("primary"), - Status: Ptr("OK"), + Hostname: new("primary"), + Status: new("OK"), Services: []*ClusterStatusNodeServiceItem{}, }}, } @@ -180,7 +180,7 @@ func TestEnterpriseService_Versions(t *testing.T) { }) opt := &NodeQueryOptions{ - UUID: Ptr("1234-1234"), ClusterRoles: Ptr("primary"), + UUID: new("1234-1234"), ClusterRoles: new("primary"), } ctx := t.Context() releaseVersions, _, err := client.Enterprise.GetNodeReleaseVersions(ctx, opt) @@ -189,12 +189,12 @@ func TestEnterpriseService_Versions(t *testing.T) { } want := []*NodeReleaseVersion{{ - Hostname: Ptr("primary"), + Hostname: new("primary"), Version: &ReleaseVersion{ - Version: Ptr("3.9.0"), - Platform: Ptr("azure"), - BuildID: Ptr("fc542058b5"), - BuildDate: Ptr("2023-05-02"), + Version: new("3.9.0"), + Platform: new("azure"), + BuildID: new("fc542058b5"), + BuildDate: new("2023-05-02"), }, }} if !cmp.Equal(releaseVersions, want) { diff --git a/github/enterprise_network_configurations_test.go b/github/enterprise_network_configurations_test.go index c4154b5f654..e07fbc8444d 100644 --- a/github/enterprise_network_configurations_test.go +++ b/github/enterprise_network_configurations_test.go @@ -56,19 +56,19 @@ func TestEnterpriseService_ListEnterpriseNetworkConfigurations(t *testing.T) { } want := &NetworkConfigurations{ - TotalCount: Ptr(int64(2)), + TotalCount: new(int64(2)), NetworkConfigurations: []*NetworkConfiguration{ { - ID: Ptr("123456789ABCDEF"), - Name: Ptr("configuration one"), - ComputeService: Ptr(ComputeService("actions")), + ID: new("123456789ABCDEF"), + Name: new("configuration one"), + ComputeService: new(ComputeService("actions")), NetworkSettingsIDs: []string{"23456789ABDCEF1", "3456789ABDCEF12"}, CreatedOn: &referenceTimestamp, }, { - ID: Ptr("456789ABDCEF123"), - Name: Ptr("configuration two"), - ComputeService: Ptr(ComputeService("none")), + ID: new("456789ABDCEF123"), + Name: new("configuration two"), + ComputeService: new(ComputeService("none")), NetworkSettingsIDs: []string{"56789ABDCEF1234", "6789ABDCEF12345"}, CreatedOn: &referenceTimestamp, }, @@ -113,8 +113,8 @@ func TestEnterpriseService_CreateEnterpriseNetworkConfiguration(t *testing.T) { ctx := t.Context() req := NetworkConfigurationRequest{ - Name: Ptr("configuration-one"), - ComputeService: Ptr(ComputeService("actions")), + Name: new("configuration-one"), + ComputeService: new(ComputeService("actions")), NetworkSettingsIDs: []string{ "23456789ABDCEF1", }, @@ -125,9 +125,9 @@ func TestEnterpriseService_CreateEnterpriseNetworkConfiguration(t *testing.T) { } want := &NetworkConfiguration{ - ID: Ptr("123456789ABCDEF"), - Name: Ptr("configuration one"), - ComputeService: Ptr(ComputeService("actions")), + ID: new("123456789ABCDEF"), + Name: new("configuration one"), + ComputeService: new(ComputeService("actions")), NetworkSettingsIDs: []string{"23456789ABDCEF1"}, CreatedOn: &referenceTimestamp, } @@ -143,7 +143,7 @@ func TestEnterpriseService_CreateEnterpriseNetworkConfiguration(t *testing.T) { { name: "invalid network settings id", request: NetworkConfigurationRequest{ - Name: Ptr(""), + Name: new(""), NetworkSettingsIDs: []string{"56789ABDCEF1234"}, }, want: "validation failed: must be between 1 and 100 characters", @@ -151,15 +151,15 @@ func TestEnterpriseService_CreateEnterpriseNetworkConfiguration(t *testing.T) { { name: "invalid network settings id", request: NetworkConfigurationRequest{ - Name: Ptr("updated-configuration-one"), + Name: new("updated-configuration-one"), }, want: "validation failed: exactly one network settings id must be specified", }, { name: "invalid compute service", request: NetworkConfigurationRequest{ - Name: Ptr("updated-configuration-one"), - ComputeService: Ptr(ComputeService("")), + Name: new("updated-configuration-one"), + ComputeService: new(ComputeService("")), NetworkSettingsIDs: []string{"56789ABDCEF1234"}, }, want: "validation failed: compute service can only be one of: none, actions", @@ -212,9 +212,9 @@ func TestEnterpriseService_GetEnterpriseNetworkConfiguration(t *testing.T) { } want := &NetworkConfiguration{ - ID: Ptr("123456789ABCDEF"), - Name: Ptr("configuration one"), - ComputeService: Ptr(ComputeService("actions")), + ID: new("123456789ABCDEF"), + Name: new("configuration one"), + ComputeService: new(ComputeService("actions")), NetworkSettingsIDs: []string{"23456789ABDCEF1", "3456789ABDCEF12"}, CreatedOn: &referenceTimestamp, } @@ -256,11 +256,11 @@ func TestEnterpriseService_UpdateEnterpriseNetworkConfiguration(t *testing.T) { ctx := t.Context() req := NetworkConfigurationRequest{ - Name: Ptr("updated-configuration-one"), + Name: new("updated-configuration-one"), NetworkSettingsIDs: []string{ "456789ABDCEF123", }, - ComputeService: Ptr(ComputeService("none")), + ComputeService: new(ComputeService("none")), } configuration, _, err := client.Enterprise.UpdateEnterpriseNetworkConfiguration(ctx, "e", "123456789ABCDEF", req) if err != nil { @@ -268,9 +268,9 @@ func TestEnterpriseService_UpdateEnterpriseNetworkConfiguration(t *testing.T) { } want := &NetworkConfiguration{ - ID: Ptr("123456789ABCDEF"), - Name: Ptr("updated configuration one"), - ComputeService: Ptr(ComputeService("none")), + ID: new("123456789ABCDEF"), + Name: new("updated configuration one"), + ComputeService: new(ComputeService("none")), NetworkSettingsIDs: []string{"456789ABDCEF123"}, CreatedOn: &referenceTimestamp, } @@ -286,7 +286,7 @@ func TestEnterpriseService_UpdateEnterpriseNetworkConfiguration(t *testing.T) { { name: "invalid network settings id", request: NetworkConfigurationRequest{ - Name: Ptr(""), + Name: new(""), NetworkSettingsIDs: []string{"56789ABDCEF1234"}, }, want: "validation failed: must be between 1 and 100 characters", @@ -294,15 +294,15 @@ func TestEnterpriseService_UpdateEnterpriseNetworkConfiguration(t *testing.T) { { name: "invalid network settings id", request: NetworkConfigurationRequest{ - Name: Ptr("updated-configuration-one"), + Name: new("updated-configuration-one"), }, want: "validation failed: exactly one network settings id must be specified", }, { name: "invalid compute service", request: NetworkConfigurationRequest{ - Name: Ptr("updated-configuration-one"), - ComputeService: Ptr(ComputeService("something")), + Name: new("updated-configuration-one"), + ComputeService: new(ComputeService("something")), NetworkSettingsIDs: []string{"56789ABDCEF1234"}, }, want: "validation failed: compute service can only be one of: none, actions", @@ -377,11 +377,11 @@ func TestEnterpriseService_GetEnterpriseNetworkSettingsResource(t *testing.T) { } want := &NetworkSettingsResource{ - ID: Ptr("220F78DACB92BBFBC5E6F22DE1CCF52309D"), - NetworkConfigurationID: Ptr("934E208B3EE0BD60CF5F752C426BFB53562"), - Name: Ptr("my_network_settings"), - SubnetID: Ptr("/subscriptions/14839728-3ad9-43ab-bd2b-fa6ad0f75e2a/resourceGroups/my-rg/providers/Microsoft.Network/virtualNetworks/my-vnet/subnets/my-subnet"), - Region: Ptr("germanywestcentral"), + ID: new("220F78DACB92BBFBC5E6F22DE1CCF52309D"), + NetworkConfigurationID: new("934E208B3EE0BD60CF5F752C426BFB53562"), + Name: new("my_network_settings"), + SubnetID: new("/subscriptions/14839728-3ad9-43ab-bd2b-fa6ad0f75e2a/resourceGroups/my-rg/providers/Microsoft.Network/virtualNetworks/my-vnet/subnets/my-subnet"), + Region: new("germanywestcentral"), } if !cmp.Equal(resource, want) { t.Errorf("Enterprise.GetEnterpriseNetworkSettingsResource mismatch (-want +got):\n%v", cmp.Diff(want, resource)) diff --git a/github/enterprise_organization_properties_test.go b/github/enterprise_organization_properties_test.go index 567676eafb3..486bfe4d04e 100644 --- a/github/enterprise_organization_properties_test.go +++ b/github/enterprise_organization_properties_test.go @@ -37,9 +37,9 @@ func TestEnterpriseService_GetOrganizationCustomPropertySchema(t *testing.T) { want := &EnterpriseCustomPropertySchema{ Properties: []*CustomProperty{ { - PropertyName: Ptr("team"), + PropertyName: new("team"), ValueType: PropertyValueTypeString, - Description: Ptr("Team name"), + Description: new("Team name"), }, }, } @@ -73,7 +73,7 @@ func TestEnterpriseService_CreateOrUpdateOrganizationCustomPropertySchema(t *tes ctx := t.Context() schema := EnterpriseCustomPropertySchema{ - Properties: []*CustomProperty{{PropertyName: Ptr("team")}}, + Properties: []*CustomProperty{{PropertyName: new("team")}}, } _, err := client.Enterprise.CreateOrUpdateOrganizationCustomPropertySchema(ctx, "e", schema) if err != nil { @@ -110,9 +110,9 @@ func TestEnterpriseService_GetOrganizationCustomProperty(t *testing.T) { } want := &CustomProperty{ - PropertyName: Ptr("team"), + PropertyName: new("team"), ValueType: PropertyValueTypeString, - Description: Ptr("Team name"), + Description: new("Team name"), } if !cmp.Equal(got, want) { @@ -143,7 +143,7 @@ func TestEnterpriseService_CreateOrUpdateOrganizationCustomProperty(t *testing.T }) ctx := t.Context() - property := CustomProperty{PropertyName: Ptr("team")} + property := CustomProperty{PropertyName: new("team")} _, err := client.Enterprise.CreateOrUpdateOrganizationCustomProperty(ctx, "e", "prop", property) if err != nil { t.Errorf("Enterprise.CreateOrUpdateOrganizationCustomProperty returned error: %v", err) @@ -208,8 +208,8 @@ func TestEnterpriseService_ListOrganizationCustomPropertyValues(t *testing.T) { want := []*EnterpriseCustomPropertiesValues{ { - OrganizationID: Ptr(int64(1)), - OrganizationLogin: Ptr("org1"), + OrganizationID: new(int64(1)), + OrganizationLogin: new("org1"), Properties: []*CustomPropertyValue{ {PropertyName: "team", Value: "core"}, }, @@ -244,7 +244,7 @@ func TestEnterpriseService_CreateOrUpdateOrganizationCustomPropertyValues(t *tes }) ctx := t.Context() - values := []*CustomPropertyValue{{PropertyName: "team", Value: Ptr("core")}} + values := []*CustomPropertyValue{{PropertyName: "team", Value: new("core")}} orgs := []string{"org1"} opts := EnterpriseCustomPropertyValuesRequest{ diff --git a/github/enterprise_properties_test.go b/github/enterprise_properties_test.go index e6f62c4224a..e9c6c1cd04b 100644 --- a/github/enterprise_properties_test.go +++ b/github/enterprise_properties_test.go @@ -52,22 +52,22 @@ func TestEnterpriseService_GetAllCustomProperties(t *testing.T) { want := []*CustomProperty{ { - PropertyName: Ptr("name"), + PropertyName: new("name"), ValueType: PropertyValueTypeSingleSelect, - Required: Ptr(true), + Required: new(true), DefaultValue: "production", - Description: Ptr("Prod or dev environment"), + Description: new("Prod or dev environment"), AllowedValues: []string{"production", "development"}, - ValuesEditableBy: Ptr("org_actors"), + ValuesEditableBy: new("org_actors"), }, { - PropertyName: Ptr("service"), + PropertyName: new("service"), ValueType: PropertyValueTypeString, }, { - PropertyName: Ptr("team"), + PropertyName: new("team"), ValueType: PropertyValueTypeString, - Description: Ptr("Team owning the repository"), + Description: new("Team owning the repository"), }, } if !cmp.Equal(properties, want) { @@ -91,12 +91,12 @@ func TestEnterpriseService_CreateOrUpdateCustomProperties(t *testing.T) { properties := []*CustomProperty{ { - PropertyName: Ptr("name"), + PropertyName: new("name"), ValueType: PropertyValueTypeSingleSelect, - Required: Ptr(true), + Required: new(true), }, { - PropertyName: Ptr("service"), + PropertyName: new("service"), ValueType: PropertyValueTypeString, }, } @@ -129,12 +129,12 @@ func TestEnterpriseService_CreateOrUpdateCustomProperties(t *testing.T) { want := []*CustomProperty{ { - PropertyName: Ptr("name"), + PropertyName: new("name"), ValueType: PropertyValueTypeSingleSelect, - Required: Ptr(true), + Required: new(true), }, { - PropertyName: Ptr("service"), + PropertyName: new("service"), ValueType: PropertyValueTypeString, }, } @@ -181,13 +181,13 @@ func TestEnterpriseService_GetCustomProperty(t *testing.T) { } want := &CustomProperty{ - PropertyName: Ptr("name"), + PropertyName: new("name"), ValueType: PropertyValueTypeSingleSelect, - Required: Ptr(true), + Required: new(true), DefaultValue: "production", - Description: Ptr("Prod or dev environment"), + Description: new("Prod or dev environment"), AllowedValues: []string{"production", "development"}, - ValuesEditableBy: Ptr("org_actors"), + ValuesEditableBy: new("org_actors"), } if !cmp.Equal(property, want) { t.Errorf("Enterprise.GetCustomProperty returned %+v, want %+v", property, want) @@ -227,24 +227,24 @@ func TestEnterpriseService_CreateOrUpdateCustomProperty(t *testing.T) { ctx := t.Context() property, _, err := client.Enterprise.CreateOrUpdateCustomProperty(ctx, "e", "name", &CustomProperty{ ValueType: PropertyValueTypeSingleSelect, - Required: Ptr(true), + Required: new(true), DefaultValue: "production", - Description: Ptr("Prod or dev environment"), + Description: new("Prod or dev environment"), AllowedValues: []string{"production", "development"}, - ValuesEditableBy: Ptr("org_actors"), + ValuesEditableBy: new("org_actors"), }) if err != nil { t.Errorf("Enterprise.CreateOrUpdateCustomProperty returned error: %v", err) } want := &CustomProperty{ - PropertyName: Ptr("name"), + PropertyName: new("name"), ValueType: PropertyValueTypeSingleSelect, - Required: Ptr(true), + Required: new(true), DefaultValue: "production", - Description: Ptr("Prod or dev environment"), + Description: new("Prod or dev environment"), AllowedValues: []string{"production", "development"}, - ValuesEditableBy: Ptr("org_actors"), + ValuesEditableBy: new("org_actors"), } if !cmp.Equal(property, want) { t.Errorf("Enterprise.CreateOrUpdateCustomProperty returned %+v, want %+v", property, want) diff --git a/github/enterprise_rules_test.go b/github/enterprise_rules_test.go index 73065a8e7d0..900934df504 100644 --- a/github/enterprise_rules_test.go +++ b/github/enterprise_rules_test.go @@ -176,12 +176,12 @@ func TestEnterpriseService_CreateRepositoryRuleset_OrgNameRepoName(t *testing.T) ctx := t.Context() ruleset, _, err := client.Enterprise.CreateRepositoryRuleset(ctx, "e", RepositoryRuleset{ Name: "ruleset", - Target: Ptr(RulesetTargetBranch), + Target: new(RulesetTargetBranch), Enforcement: "active", BypassActors: []*BypassActor{ { - ActorID: Ptr(int64(234)), - ActorType: Ptr(BypassActorTypeTeam), + ActorID: new(int64(234)), + ActorType: new(BypassActorTypeTeam), }, }, Conditions: &RepositoryRulesetConditions{ @@ -192,7 +192,7 @@ func TestEnterpriseService_CreateRepositoryRuleset_OrgNameRepoName(t *testing.T) RepositoryName: &RepositoryRulesetRepositoryNamesConditionParameters{ Include: []string{"important_repository", "another_important_repository"}, Exclude: []string{"unimportant_repository"}, - Protected: Ptr(true), + Protected: new(true), }, RefName: &RepositoryRulesetRefConditionParameters{ Include: []string{"refs/heads/main", "refs/heads/master"}, @@ -219,19 +219,19 @@ func TestEnterpriseService_CreateRepositoryRuleset_OrgNameRepoName(t *testing.T) RequiredReviewThreadResolution: true, }, RequiredStatusChecks: &RequiredStatusChecksRuleParameters{ - DoNotEnforceOnCreate: Ptr(true), + DoNotEnforceOnCreate: new(true), RequiredStatusChecks: []*RuleStatusCheck{ { Context: "test", - IntegrationID: Ptr(int64(1)), + IntegrationID: new(int64(1)), }, }, StrictRequiredStatusChecksPolicy: true, }, NonFastForward: &EmptyRuleParameters{}, CommitMessagePattern: &PatternRuleParameters{ - Name: Ptr("avoid test commits"), - Negate: Ptr(true), + Name: new("avoid test commits"), + Negate: new(true), Operator: "starts_with", Pattern: "[test]", }, @@ -240,20 +240,20 @@ func TestEnterpriseService_CreateRepositoryRuleset_OrgNameRepoName(t *testing.T) Pattern: "github", }, CommitterEmailPattern: &PatternRuleParameters{ - Name: Ptr("avoid commit emails"), - Negate: Ptr(true), + Name: new("avoid commit emails"), + Negate: new(true), Operator: "ends_with", Pattern: "abc", }, BranchNamePattern: &PatternRuleParameters{ - Name: Ptr("avoid branch names"), - Negate: Ptr(true), + Name: new("avoid branch names"), + Negate: new(true), Operator: "regex", Pattern: "github$", }, TagNamePattern: &PatternRuleParameters{ - Name: Ptr("avoid tag names"), - Negate: Ptr(true), + Name: new("avoid tag names"), + Negate: new(true), Operator: "contains", Pattern: "github", }, @@ -273,16 +273,16 @@ func TestEnterpriseService_CreateRepositoryRuleset_OrgNameRepoName(t *testing.T) } want := &RepositoryRuleset{ - ID: Ptr(int64(84)), + ID: new(int64(84)), Name: "ruleset", - Target: Ptr(RulesetTargetBranch), - SourceType: Ptr(RulesetSourceTypeEnterprise), + Target: new(RulesetTargetBranch), + SourceType: new(RulesetSourceTypeEnterprise), Source: "e", Enforcement: "active", BypassActors: []*BypassActor{ { - ActorID: Ptr(int64(234)), - ActorType: Ptr(BypassActorTypeTeam), + ActorID: new(int64(234)), + ActorType: new(BypassActorTypeTeam), }, }, Conditions: &RepositoryRulesetConditions{ @@ -293,7 +293,7 @@ func TestEnterpriseService_CreateRepositoryRuleset_OrgNameRepoName(t *testing.T) RepositoryName: &RepositoryRulesetRepositoryNamesConditionParameters{ Include: []string{"important_repository", "another_important_repository"}, Exclude: []string{"unimportant_repository"}, - Protected: Ptr(true), + Protected: new(true), }, RefName: &RepositoryRulesetRefConditionParameters{ Include: []string{"refs/heads/main", "refs/heads/master"}, @@ -320,19 +320,19 @@ func TestEnterpriseService_CreateRepositoryRuleset_OrgNameRepoName(t *testing.T) RequiredReviewThreadResolution: true, }, RequiredStatusChecks: &RequiredStatusChecksRuleParameters{ - DoNotEnforceOnCreate: Ptr(true), + DoNotEnforceOnCreate: new(true), RequiredStatusChecks: []*RuleStatusCheck{ { Context: "test", - IntegrationID: Ptr(int64(1)), + IntegrationID: new(int64(1)), }, }, StrictRequiredStatusChecksPolicy: true, }, NonFastForward: &EmptyRuleParameters{}, CommitMessagePattern: &PatternRuleParameters{ - Name: Ptr("avoid test commits"), - Negate: Ptr(true), + Name: new("avoid test commits"), + Negate: new(true), Operator: "starts_with", Pattern: "[test]", }, @@ -341,20 +341,20 @@ func TestEnterpriseService_CreateRepositoryRuleset_OrgNameRepoName(t *testing.T) Pattern: "github", }, CommitterEmailPattern: &PatternRuleParameters{ - Name: Ptr("avoid commit emails"), - Negate: Ptr(true), + Name: new("avoid commit emails"), + Negate: new(true), Operator: "ends_with", Pattern: "abc", }, BranchNamePattern: &PatternRuleParameters{ - Name: Ptr("avoid branch names"), - Negate: Ptr(true), + Name: new("avoid branch names"), + Negate: new(true), Operator: "regex", Pattern: "github$", }, TagNamePattern: &PatternRuleParameters{ - Name: Ptr("avoid tag names"), - Negate: Ptr(true), + Name: new("avoid tag names"), + Negate: new(true), Operator: "contains", Pattern: "github", }, @@ -600,12 +600,12 @@ func TestEnterpriseService_CreateRepositoryRuleset_OrgNameRepoProperty(t *testin ctx := t.Context() ruleset, _, err := client.Enterprise.CreateRepositoryRuleset(ctx, "e", RepositoryRuleset{ Name: "ruleset", - Target: Ptr(RulesetTargetBranch), + Target: new(RulesetTargetBranch), Enforcement: "active", BypassActors: []*BypassActor{ { - ActorID: Ptr(int64(234)), - ActorType: Ptr(BypassActorTypeTeam), + ActorID: new(int64(234)), + ActorType: new(BypassActorTypeTeam), }, }, Conditions: &RepositoryRulesetConditions{ @@ -617,7 +617,7 @@ func TestEnterpriseService_CreateRepositoryRuleset_OrgNameRepoProperty(t *testin Include: []*RepositoryRulesetRepositoryPropertyTargetParameters{ { Name: "testIncludeProp", - Source: Ptr("custom"), + Source: new("custom"), PropertyValues: []string{"true"}, }, }, @@ -653,19 +653,19 @@ func TestEnterpriseService_CreateRepositoryRuleset_OrgNameRepoProperty(t *testin RequiredReviewThreadResolution: true, }, RequiredStatusChecks: &RequiredStatusChecksRuleParameters{ - DoNotEnforceOnCreate: Ptr(true), + DoNotEnforceOnCreate: new(true), RequiredStatusChecks: []*RuleStatusCheck{ { Context: "test", - IntegrationID: Ptr(int64(1)), + IntegrationID: new(int64(1)), }, }, StrictRequiredStatusChecksPolicy: true, }, NonFastForward: &EmptyRuleParameters{}, CommitMessagePattern: &PatternRuleParameters{ - Name: Ptr("avoid test commits"), - Negate: Ptr(true), + Name: new("avoid test commits"), + Negate: new(true), Operator: "starts_with", Pattern: "[test]", }, @@ -674,20 +674,20 @@ func TestEnterpriseService_CreateRepositoryRuleset_OrgNameRepoProperty(t *testin Pattern: "github", }, CommitterEmailPattern: &PatternRuleParameters{ - Name: Ptr("avoid commit emails"), - Negate: Ptr(true), + Name: new("avoid commit emails"), + Negate: new(true), Operator: "ends_with", Pattern: "abc", }, BranchNamePattern: &PatternRuleParameters{ - Name: Ptr("avoid branch names"), - Negate: Ptr(true), + Name: new("avoid branch names"), + Negate: new(true), Operator: "regex", Pattern: "github$", }, TagNamePattern: &PatternRuleParameters{ - Name: Ptr("avoid tag names"), - Negate: Ptr(true), + Name: new("avoid tag names"), + Negate: new(true), Operator: "contains", Pattern: "github", }, @@ -707,16 +707,16 @@ func TestEnterpriseService_CreateRepositoryRuleset_OrgNameRepoProperty(t *testin } want := &RepositoryRuleset{ - ID: Ptr(int64(84)), + ID: new(int64(84)), Name: "ruleset", - Target: Ptr(RulesetTargetBranch), - SourceType: Ptr(RulesetSourceTypeEnterprise), + Target: new(RulesetTargetBranch), + SourceType: new(RulesetSourceTypeEnterprise), Source: "e", Enforcement: "active", BypassActors: []*BypassActor{ { - ActorID: Ptr(int64(234)), - ActorType: Ptr(BypassActorTypeTeam), + ActorID: new(int64(234)), + ActorType: new(BypassActorTypeTeam), }, }, Conditions: &RepositoryRulesetConditions{ @@ -728,7 +728,7 @@ func TestEnterpriseService_CreateRepositoryRuleset_OrgNameRepoProperty(t *testin Include: []*RepositoryRulesetRepositoryPropertyTargetParameters{ { Name: "testIncludeProp", - Source: Ptr("custom"), + Source: new("custom"), PropertyValues: []string{"true"}, }, }, @@ -764,19 +764,19 @@ func TestEnterpriseService_CreateRepositoryRuleset_OrgNameRepoProperty(t *testin RequiredReviewThreadResolution: true, }, RequiredStatusChecks: &RequiredStatusChecksRuleParameters{ - DoNotEnforceOnCreate: Ptr(true), + DoNotEnforceOnCreate: new(true), RequiredStatusChecks: []*RuleStatusCheck{ { Context: "test", - IntegrationID: Ptr(int64(1)), + IntegrationID: new(int64(1)), }, }, StrictRequiredStatusChecksPolicy: true, }, NonFastForward: &EmptyRuleParameters{}, CommitMessagePattern: &PatternRuleParameters{ - Name: Ptr("avoid test commits"), - Negate: Ptr(true), + Name: new("avoid test commits"), + Negate: new(true), Operator: "starts_with", Pattern: "[test]", }, @@ -785,20 +785,20 @@ func TestEnterpriseService_CreateRepositoryRuleset_OrgNameRepoProperty(t *testin Pattern: "github", }, CommitterEmailPattern: &PatternRuleParameters{ - Name: Ptr("avoid commit emails"), - Negate: Ptr(true), + Name: new("avoid commit emails"), + Negate: new(true), Operator: "ends_with", Pattern: "abc", }, BranchNamePattern: &PatternRuleParameters{ - Name: Ptr("avoid branch names"), - Negate: Ptr(true), + Name: new("avoid branch names"), + Negate: new(true), Operator: "regex", Pattern: "github$", }, TagNamePattern: &PatternRuleParameters{ - Name: Ptr("avoid tag names"), - Negate: Ptr(true), + Name: new("avoid tag names"), + Negate: new(true), Operator: "contains", Pattern: "github", }, @@ -985,12 +985,12 @@ func TestEnterpriseService_CreateRepositoryRuleset_OrgIdRepoName(t *testing.T) { ctx := t.Context() ruleset, _, err := client.Enterprise.CreateRepositoryRuleset(ctx, "e", RepositoryRuleset{ Name: "ruleset", - Target: Ptr(RulesetTargetBranch), + Target: new(RulesetTargetBranch), Enforcement: "active", BypassActors: []*BypassActor{ { - ActorID: Ptr(int64(234)), - ActorType: Ptr(BypassActorTypeTeam), + ActorID: new(int64(234)), + ActorType: new(BypassActorTypeTeam), }, }, Conditions: &RepositoryRulesetConditions{ @@ -1000,7 +1000,7 @@ func TestEnterpriseService_CreateRepositoryRuleset_OrgIdRepoName(t *testing.T) { RepositoryName: &RepositoryRulesetRepositoryNamesConditionParameters{ Include: []string{"important_repository", "another_important_repository"}, Exclude: []string{"unimportant_repository"}, - Protected: Ptr(true), + Protected: new(true), }, RefName: &RepositoryRulesetRefConditionParameters{ Include: []string{"refs/heads/main", "refs/heads/master"}, @@ -1027,19 +1027,19 @@ func TestEnterpriseService_CreateRepositoryRuleset_OrgIdRepoName(t *testing.T) { RequiredReviewThreadResolution: true, }, RequiredStatusChecks: &RequiredStatusChecksRuleParameters{ - DoNotEnforceOnCreate: Ptr(true), + DoNotEnforceOnCreate: new(true), RequiredStatusChecks: []*RuleStatusCheck{ { Context: "test", - IntegrationID: Ptr(int64(1)), + IntegrationID: new(int64(1)), }, }, StrictRequiredStatusChecksPolicy: true, }, NonFastForward: &EmptyRuleParameters{}, CommitMessagePattern: &PatternRuleParameters{ - Name: Ptr("avoid test commits"), - Negate: Ptr(true), + Name: new("avoid test commits"), + Negate: new(true), Operator: "starts_with", Pattern: "[test]", }, @@ -1048,20 +1048,20 @@ func TestEnterpriseService_CreateRepositoryRuleset_OrgIdRepoName(t *testing.T) { Pattern: "github", }, CommitterEmailPattern: &PatternRuleParameters{ - Name: Ptr("avoid commit emails"), - Negate: Ptr(true), + Name: new("avoid commit emails"), + Negate: new(true), Operator: "ends_with", Pattern: "abc", }, BranchNamePattern: &PatternRuleParameters{ - Name: Ptr("avoid branch names"), - Negate: Ptr(true), + Name: new("avoid branch names"), + Negate: new(true), Operator: "regex", Pattern: "github$", }, TagNamePattern: &PatternRuleParameters{ - Name: Ptr("avoid tag names"), - Negate: Ptr(true), + Name: new("avoid tag names"), + Negate: new(true), Operator: "contains", Pattern: "github", }, @@ -1081,16 +1081,16 @@ func TestEnterpriseService_CreateRepositoryRuleset_OrgIdRepoName(t *testing.T) { } want := &RepositoryRuleset{ - ID: Ptr(int64(84)), + ID: new(int64(84)), Name: "ruleset", - Target: Ptr(RulesetTargetBranch), - SourceType: Ptr(RulesetSourceTypeEnterprise), + Target: new(RulesetTargetBranch), + SourceType: new(RulesetSourceTypeEnterprise), Source: "e", Enforcement: "active", BypassActors: []*BypassActor{ { - ActorID: Ptr(int64(234)), - ActorType: Ptr(BypassActorTypeTeam), + ActorID: new(int64(234)), + ActorType: new(BypassActorTypeTeam), }, }, Conditions: &RepositoryRulesetConditions{ @@ -1100,7 +1100,7 @@ func TestEnterpriseService_CreateRepositoryRuleset_OrgIdRepoName(t *testing.T) { RepositoryName: &RepositoryRulesetRepositoryNamesConditionParameters{ Include: []string{"important_repository", "another_important_repository"}, Exclude: []string{"unimportant_repository"}, - Protected: Ptr(true), + Protected: new(true), }, RefName: &RepositoryRulesetRefConditionParameters{ Include: []string{"refs/heads/main", "refs/heads/master"}, @@ -1127,19 +1127,19 @@ func TestEnterpriseService_CreateRepositoryRuleset_OrgIdRepoName(t *testing.T) { RequiredReviewThreadResolution: true, }, RequiredStatusChecks: &RequiredStatusChecksRuleParameters{ - DoNotEnforceOnCreate: Ptr(true), + DoNotEnforceOnCreate: new(true), RequiredStatusChecks: []*RuleStatusCheck{ { Context: "test", - IntegrationID: Ptr(int64(1)), + IntegrationID: new(int64(1)), }, }, StrictRequiredStatusChecksPolicy: true, }, NonFastForward: &EmptyRuleParameters{}, CommitMessagePattern: &PatternRuleParameters{ - Name: Ptr("avoid test commits"), - Negate: Ptr(true), + Name: new("avoid test commits"), + Negate: new(true), Operator: "starts_with", Pattern: "[test]", }, @@ -1148,20 +1148,20 @@ func TestEnterpriseService_CreateRepositoryRuleset_OrgIdRepoName(t *testing.T) { Pattern: "github", }, CommitterEmailPattern: &PatternRuleParameters{ - Name: Ptr("avoid commit emails"), - Negate: Ptr(true), + Name: new("avoid commit emails"), + Negate: new(true), Operator: "ends_with", Pattern: "abc", }, BranchNamePattern: &PatternRuleParameters{ - Name: Ptr("avoid branch names"), - Negate: Ptr(true), + Name: new("avoid branch names"), + Negate: new(true), Operator: "regex", Pattern: "github$", }, TagNamePattern: &PatternRuleParameters{ - Name: Ptr("avoid tag names"), - Negate: Ptr(true), + Name: new("avoid tag names"), + Negate: new(true), Operator: "contains", Pattern: "github", }, @@ -1357,12 +1357,12 @@ func TestEnterpriseService_CreateRepositoryRuleset_OrgIdRepoProperty(t *testing. ctx := t.Context() ruleset, _, err := client.Enterprise.CreateRepositoryRuleset(ctx, "e", RepositoryRuleset{ Name: "ruleset", - Target: Ptr(RulesetTargetBranch), + Target: new(RulesetTargetBranch), Enforcement: "active", BypassActors: []*BypassActor{ { - ActorID: Ptr(int64(234)), - ActorType: Ptr(BypassActorTypeTeam), + ActorID: new(int64(234)), + ActorType: new(BypassActorTypeTeam), }, }, Conditions: &RepositoryRulesetConditions{ @@ -1373,7 +1373,7 @@ func TestEnterpriseService_CreateRepositoryRuleset_OrgIdRepoProperty(t *testing. Include: []*RepositoryRulesetRepositoryPropertyTargetParameters{ { Name: "testIncludeProp", - Source: Ptr("custom"), + Source: new("custom"), PropertyValues: []string{"true"}, }, }, @@ -1409,19 +1409,19 @@ func TestEnterpriseService_CreateRepositoryRuleset_OrgIdRepoProperty(t *testing. RequiredReviewThreadResolution: true, }, RequiredStatusChecks: &RequiredStatusChecksRuleParameters{ - DoNotEnforceOnCreate: Ptr(true), + DoNotEnforceOnCreate: new(true), RequiredStatusChecks: []*RuleStatusCheck{ { Context: "test", - IntegrationID: Ptr(int64(1)), + IntegrationID: new(int64(1)), }, }, StrictRequiredStatusChecksPolicy: true, }, NonFastForward: &EmptyRuleParameters{}, CommitMessagePattern: &PatternRuleParameters{ - Name: Ptr("avoid test commits"), - Negate: Ptr(true), + Name: new("avoid test commits"), + Negate: new(true), Operator: "starts_with", Pattern: "[test]", }, @@ -1430,20 +1430,20 @@ func TestEnterpriseService_CreateRepositoryRuleset_OrgIdRepoProperty(t *testing. Pattern: "github", }, CommitterEmailPattern: &PatternRuleParameters{ - Name: Ptr("avoid commit emails"), - Negate: Ptr(true), + Name: new("avoid commit emails"), + Negate: new(true), Operator: "ends_with", Pattern: "abc", }, BranchNamePattern: &PatternRuleParameters{ - Name: Ptr("avoid branch names"), - Negate: Ptr(true), + Name: new("avoid branch names"), + Negate: new(true), Operator: "regex", Pattern: "github$", }, TagNamePattern: &PatternRuleParameters{ - Name: Ptr("avoid tag names"), - Negate: Ptr(true), + Name: new("avoid tag names"), + Negate: new(true), Operator: "contains", Pattern: "github", }, @@ -1463,16 +1463,16 @@ func TestEnterpriseService_CreateRepositoryRuleset_OrgIdRepoProperty(t *testing. } want := &RepositoryRuleset{ - ID: Ptr(int64(84)), + ID: new(int64(84)), Name: "ruleset", - Target: Ptr(RulesetTargetBranch), - SourceType: Ptr(RulesetSourceTypeEnterprise), + Target: new(RulesetTargetBranch), + SourceType: new(RulesetSourceTypeEnterprise), Source: "e", Enforcement: "active", BypassActors: []*BypassActor{ { - ActorID: Ptr(int64(234)), - ActorType: Ptr(BypassActorTypeTeam), + ActorID: new(int64(234)), + ActorType: new(BypassActorTypeTeam), }, }, Conditions: &RepositoryRulesetConditions{ @@ -1483,7 +1483,7 @@ func TestEnterpriseService_CreateRepositoryRuleset_OrgIdRepoProperty(t *testing. Include: []*RepositoryRulesetRepositoryPropertyTargetParameters{ { Name: "testIncludeProp", - Source: Ptr("custom"), + Source: new("custom"), PropertyValues: []string{"true"}, }, }, @@ -1519,19 +1519,19 @@ func TestEnterpriseService_CreateRepositoryRuleset_OrgIdRepoProperty(t *testing. RequiredReviewThreadResolution: true, }, RequiredStatusChecks: &RequiredStatusChecksRuleParameters{ - DoNotEnforceOnCreate: Ptr(true), + DoNotEnforceOnCreate: new(true), RequiredStatusChecks: []*RuleStatusCheck{ { Context: "test", - IntegrationID: Ptr(int64(1)), + IntegrationID: new(int64(1)), }, }, StrictRequiredStatusChecksPolicy: true, }, NonFastForward: &EmptyRuleParameters{}, CommitMessagePattern: &PatternRuleParameters{ - Name: Ptr("avoid test commits"), - Negate: Ptr(true), + Name: new("avoid test commits"), + Negate: new(true), Operator: "starts_with", Pattern: "[test]", }, @@ -1540,20 +1540,20 @@ func TestEnterpriseService_CreateRepositoryRuleset_OrgIdRepoProperty(t *testing. Pattern: "github", }, CommitterEmailPattern: &PatternRuleParameters{ - Name: Ptr("avoid commit emails"), - Negate: Ptr(true), + Name: new("avoid commit emails"), + Negate: new(true), Operator: "ends_with", Pattern: "abc", }, BranchNamePattern: &PatternRuleParameters{ - Name: Ptr("avoid branch names"), - Negate: Ptr(true), + Name: new("avoid branch names"), + Negate: new(true), Operator: "regex", Pattern: "github$", }, TagNamePattern: &PatternRuleParameters{ - Name: Ptr("avoid tag names"), - Negate: Ptr(true), + Name: new("avoid tag names"), + Negate: new(true), Operator: "contains", Pattern: "github", }, @@ -1648,15 +1648,15 @@ func TestEnterpriseService_GetRepositoryRuleset(t *testing.T) { } want := &RepositoryRuleset{ - ID: Ptr(int64(84)), + ID: new(int64(84)), Name: "test ruleset", - Target: Ptr(RulesetTargetBranch), - SourceType: Ptr(RulesetSourceTypeEnterprise), + Target: new(RulesetTargetBranch), + SourceType: new(RulesetSourceTypeEnterprise), Source: "e", Enforcement: "active", - NodeID: Ptr("nid"), + NodeID: new("nid"), Links: &RepositoryRulesetLinks{ - Self: &RepositoryRulesetLink{HRef: Ptr("https://api.github.com/enterprises/e/rulesets/84")}, + Self: &RepositoryRulesetLink{HRef: new("https://api.github.com/enterprises/e/rulesets/84")}, }, Conditions: &RepositoryRulesetConditions{ OrganizationName: &RepositoryRulesetOrganizationNamesConditionParameters{ @@ -1666,7 +1666,7 @@ func TestEnterpriseService_GetRepositoryRuleset(t *testing.T) { RepositoryName: &RepositoryRulesetRepositoryNamesConditionParameters{ Include: []string{"important_repository", "another_important_repository"}, Exclude: []string{"unimportant_repository"}, - Protected: Ptr(true), + Protected: new(true), }, RefName: &RepositoryRulesetRefConditionParameters{ Include: []string{"refs/heads/main", "refs/heads/master"}, @@ -1751,7 +1751,7 @@ func TestEnterpriseService_UpdateRepositoryRuleset(t *testing.T) { ctx := t.Context() rulesets, _, err := client.Enterprise.UpdateRepositoryRuleset(ctx, "e", 84, RepositoryRuleset{ Name: "test ruleset", - Target: Ptr(RulesetTargetBranch), + Target: new(RulesetTargetBranch), Enforcement: "active", Conditions: &RepositoryRulesetConditions{ RefName: &RepositoryRulesetRefConditionParameters{ @@ -1761,7 +1761,7 @@ func TestEnterpriseService_UpdateRepositoryRuleset(t *testing.T) { RepositoryName: &RepositoryRulesetRepositoryNamesConditionParameters{ Include: []string{"important_repository", "another_important_repository"}, Exclude: []string{"unimportant_repository"}, - Protected: Ptr(true), + Protected: new(true), }, }, Rules: &RepositoryRulesetRules{Creation: &EmptyRuleParameters{}}, @@ -1771,15 +1771,15 @@ func TestEnterpriseService_UpdateRepositoryRuleset(t *testing.T) { } want := &RepositoryRuleset{ - ID: Ptr(int64(84)), + ID: new(int64(84)), Name: "test ruleset", - Target: Ptr(RulesetTargetBranch), - SourceType: Ptr(RulesetSourceTypeEnterprise), + Target: new(RulesetTargetBranch), + SourceType: new(RulesetSourceTypeEnterprise), Source: "e", Enforcement: "active", - NodeID: Ptr("nid"), + NodeID: new("nid"), Links: &RepositoryRulesetLinks{ - Self: &RepositoryRulesetLink{HRef: Ptr("https://api.github.com/enterprises/e/rulesets/84")}, + Self: &RepositoryRulesetLink{HRef: new("https://api.github.com/enterprises/e/rulesets/84")}, }, Conditions: &RepositoryRulesetConditions{ OrganizationName: &RepositoryRulesetOrganizationNamesConditionParameters{ @@ -1789,7 +1789,7 @@ func TestEnterpriseService_UpdateRepositoryRuleset(t *testing.T) { RepositoryName: &RepositoryRulesetRepositoryNamesConditionParameters{ Include: []string{"important_repository", "another_important_repository"}, Exclude: []string{"unimportant_repository"}, - Protected: Ptr(true), + Protected: new(true), }, RefName: &RepositoryRulesetRefConditionParameters{ Include: []string{"refs/heads/main", "refs/heads/master"}, diff --git a/github/enterprise_scim_test.go b/github/enterprise_scim_test.go index c0759fff5f2..c5d2727d9a2 100644 --- a/github/enterprise_scim_test.go +++ b/github/enterprise_scim_test.go @@ -54,10 +54,10 @@ func TestEnterpriseService_ListProvisionedSCIMGroups(t *testing.T) { ctx := t.Context() opts := &ListProvisionedSCIMGroupsEnterpriseOptions{ - StartIndex: Ptr(1), - ExcludedAttributes: Ptr("members,meta"), - Count: Ptr(3), - Filter: Ptr(`externalId eq "914a"`), + StartIndex: new(1), + ExcludedAttributes: new("members,meta"), + Count: new(3), + Filter: new(`externalId eq "914a"`), } got, _, err := client.Enterprise.ListProvisionedSCIMGroups(ctx, "ee", opts) if err != nil { @@ -66,24 +66,24 @@ func TestEnterpriseService_ListProvisionedSCIMGroups(t *testing.T) { want := &SCIMEnterpriseGroups{ Schemas: []string{SCIMSchemasURINamespacesListResponse}, - TotalResults: Ptr(1), - ItemsPerPage: Ptr(1), - StartIndex: Ptr(1), + TotalResults: new(1), + ItemsPerPage: new(1), + StartIndex: new(1), Resources: []*SCIMEnterpriseGroupAttributes{{ - ID: Ptr("914a"), + ID: new("914a"), Meta: &SCIMEnterpriseMeta{ ResourceType: "Group", Created: &Timestamp{referenceTime}, LastModified: &Timestamp{referenceTime}, - Location: Ptr("https://api.github.com/scim/v2/enterprises/ee/Groups/914a"), + Location: new("https://api.github.com/scim/v2/enterprises/ee/Groups/914a"), }, - DisplayName: Ptr("gn1"), + DisplayName: new("gn1"), Schemas: []string{SCIMSchemasURINamespacesGroups}, - ExternalID: Ptr("de88"), + ExternalID: new("de88"), Members: []*SCIMEnterpriseDisplayReference{{ Value: "e7f9", - Ref: Ptr("https://api.github.com/scim/v2/enterprises/ee/Users/e7f9"), - Display: Ptr("d1"), + Ref: new("https://api.github.com/scim/v2/enterprises/ee/Users/e7f9"), + Display: new("d1"), }}, }}, } @@ -157,9 +157,9 @@ func TestEnterpriseService_ListProvisionedSCIMUsers(t *testing.T) { ctx := t.Context() opts := &ListProvisionedSCIMUsersEnterpriseOptions{ - StartIndex: Ptr(1), - Count: Ptr(3), - Filter: Ptr(`userName eq "octocat@github.com"`), + StartIndex: new(1), + Count: new(3), + Filter: new(`userName eq "octocat@github.com"`), } got, _, err := client.Enterprise.ListProvisionedSCIMUsers(ctx, "ee", opts) if err != nil { @@ -168,19 +168,19 @@ func TestEnterpriseService_ListProvisionedSCIMUsers(t *testing.T) { want := &SCIMEnterpriseUsers{ Schemas: []string{SCIMSchemasURINamespacesListResponse}, - TotalResults: Ptr(1), - ItemsPerPage: Ptr(1), - StartIndex: Ptr(1), + TotalResults: new(1), + ItemsPerPage: new(1), + StartIndex: new(1), Resources: []*SCIMEnterpriseUserAttributes{{ Schemas: []string{SCIMSchemasURINamespacesUser}, - ID: Ptr("5fc0"), + ID: new("5fc0"), ExternalID: "00u1", UserName: "octocat@github.com", DisplayName: "Mona Octocat", Name: &SCIMEnterpriseUserName{ GivenName: "Mona", FamilyName: "Octocat", - Formatted: Ptr("Mona Octocat"), + Formatted: new("Mona Octocat"), }, Emails: []*SCIMEnterpriseUserEmail{{ Value: "octocat@github.com", @@ -191,7 +191,7 @@ func TestEnterpriseService_ListProvisionedSCIMUsers(t *testing.T) { ResourceType: "User", Created: &Timestamp{referenceTime}, LastModified: &Timestamp{referenceTime}, - Location: Ptr("https://api.github.com/scim/v2/enterprises/ee/Users/5fc0"), + Location: new("https://api.github.com/scim/v2/enterprises/ee/Users/5fc0"), }, }}, } @@ -221,8 +221,8 @@ func TestEnterpriseService_SetProvisionedSCIMGroup(t *testing.T) { input := SCIMEnterpriseGroupAttributes{ Schemas: []string{SCIMSchemasURINamespacesGroups}, - ExternalID: Ptr("8aa1"), - DisplayName: Ptr("dn"), + ExternalID: new("8aa1"), + DisplayName: new("dn"), } mux.HandleFunc("/scim/v2/enterprises/ee/Groups/abcd", func(w http.ResponseWriter, r *http.Request) { @@ -245,14 +245,14 @@ func TestEnterpriseService_SetProvisionedSCIMGroup(t *testing.T) { }) want := &SCIMEnterpriseGroupAttributes{ Schemas: []string{SCIMSchemasURINamespacesGroups}, - ID: Ptr("abcd"), - ExternalID: Ptr("8aa1"), - DisplayName: Ptr("dn"), + ID: new("abcd"), + ExternalID: new("8aa1"), + DisplayName: new("dn"), Meta: &SCIMEnterpriseMeta{ ResourceType: "Group", Created: &Timestamp{referenceTime}, LastModified: &Timestamp{referenceTime}, - Location: Ptr("https://api.github.localhost/scim/v2/enterprises/ee/Groups/abcd"), + Location: new("https://api.github.localhost/scim/v2/enterprises/ee/Groups/abcd"), }, } @@ -324,7 +324,7 @@ func TestEnterpriseService_SetProvisionedSCIMUser(t *testing.T) { }) want := &SCIMEnterpriseUserAttributes{ Schemas: []string{SCIMSchemasURINamespacesUser}, - ID: Ptr("7fce"), + ID: new("7fce"), ExternalID: "e123", Active: true, UserName: "e123", @@ -338,7 +338,7 @@ func TestEnterpriseService_SetProvisionedSCIMUser(t *testing.T) { ResourceType: "User", Created: &Timestamp{referenceTime}, LastModified: &Timestamp{referenceTime}, - Location: Ptr("https://api.github.localhost/scim/v2/enterprises/ee/Users/7fce"), + Location: new("https://api.github.localhost/scim/v2/enterprises/ee/Users/7fce"), }, } @@ -374,7 +374,7 @@ func TestEnterpriseService_UpdateSCIMGroupAttribute(t *testing.T) { Schemas: []string{SCIMSchemasURINamespacesPatchOp}, Operations: []*SCIMEnterpriseAttributeOperation{{ Op: "replace", - Path: Ptr("displayName"), + Path: new("displayName"), Value: "Employees", }}, } @@ -404,19 +404,19 @@ func TestEnterpriseService_UpdateSCIMGroupAttribute(t *testing.T) { }) want := &SCIMEnterpriseGroupAttributes{ Schemas: []string{SCIMSchemasURINamespacesGroups}, - ID: Ptr("abcd"), - ExternalID: Ptr("8aa1"), - DisplayName: Ptr("Employees"), + ID: new("abcd"), + ExternalID: new("8aa1"), + DisplayName: new("Employees"), Members: []*SCIMEnterpriseDisplayReference{{ Value: "879d", - Ref: Ptr("https://api.github.localhost/scim/v2/enterprises/ee/Users/879d"), - Display: Ptr("User 1"), + Ref: new("https://api.github.localhost/scim/v2/enterprises/ee/Users/879d"), + Display: new("User 1"), }}, Meta: &SCIMEnterpriseMeta{ ResourceType: "Group", Created: &Timestamp{referenceTime}, LastModified: &Timestamp{referenceTime}, - Location: Ptr("https://api.github.localhost/scim/v2/enterprises/ee/Groups/abcd"), + Location: new("https://api.github.localhost/scim/v2/enterprises/ee/Groups/abcd"), }, } @@ -452,11 +452,11 @@ func TestEnterpriseService_UpdateSCIMUserAttribute(t *testing.T) { Schemas: []string{SCIMSchemasURINamespacesPatchOp}, Operations: []*SCIMEnterpriseAttributeOperation{{ Op: "replace", - Path: Ptr("emails[type eq 'work'].value"), + Path: new("emails[type eq 'work'].value"), Value: "updatedEmail@example.com", }, { Op: "replace", - Path: Ptr("name.familyName"), + Path: new("name.familyName"), Value: "updatedFamilyName", }}, } @@ -498,16 +498,16 @@ func TestEnterpriseService_UpdateSCIMUserAttribute(t *testing.T) { }) want := &SCIMEnterpriseUserAttributes{ Schemas: []string{SCIMSchemasURINamespacesUser}, - ID: Ptr("7fce"), + ID: new("7fce"), ExternalID: "e123", Active: true, UserName: "e123", DisplayName: "John Doe", Name: &SCIMEnterpriseUserName{ - Formatted: Ptr("John Doe X"), + Formatted: new("John Doe X"), FamilyName: "updatedFamilyName", GivenName: "John", - MiddleName: Ptr("X"), + MiddleName: new("X"), }, Emails: []*SCIMEnterpriseUserEmail{{ Value: "john@example.com", @@ -516,13 +516,13 @@ func TestEnterpriseService_UpdateSCIMUserAttribute(t *testing.T) { }}, Roles: []*SCIMEnterpriseUserRole{{ Value: "User", - Primary: Ptr(false), + Primary: new(false), }}, Meta: &SCIMEnterpriseMeta{ ResourceType: "User", Created: &Timestamp{referenceTime}, LastModified: &Timestamp{referenceTime}, - Location: Ptr("https://api.github.localhost/scim/v2/enterprises/ee/Users/7fce"), + Location: new("https://api.github.localhost/scim/v2/enterprises/ee/Users/7fce"), }, } @@ -556,14 +556,14 @@ func TestEnterpriseService_ProvisionSCIMGroup(t *testing.T) { input := SCIMEnterpriseGroupAttributes{ Schemas: []string{SCIMSchemasURINamespacesGroups}, - ExternalID: Ptr("8aa1"), - DisplayName: Ptr("dn"), + ExternalID: new("8aa1"), + DisplayName: new("dn"), Members: []*SCIMEnterpriseDisplayReference{{ Value: "879d", - Display: Ptr("d1"), + Display: new("d1"), }, { Value: "0db5", - Display: Ptr("d2"), + Display: new("d2"), }}, } @@ -599,23 +599,23 @@ func TestEnterpriseService_ProvisionSCIMGroup(t *testing.T) { }) want := &SCIMEnterpriseGroupAttributes{ Schemas: []string{SCIMSchemasURINamespacesGroups}, - ID: Ptr("abcd"), - ExternalID: Ptr("8aa1"), - DisplayName: Ptr("dn"), + ID: new("abcd"), + ExternalID: new("8aa1"), + DisplayName: new("dn"), Members: []*SCIMEnterpriseDisplayReference{{ Value: "879d", - Ref: Ptr("https://api.github.localhost/scim/v2/enterprises/ee/Users/879d"), - Display: Ptr("d1"), + Ref: new("https://api.github.localhost/scim/v2/enterprises/ee/Users/879d"), + Display: new("d1"), }, { Value: "0db5", - Ref: Ptr("https://api.github.localhost/scim/v2/enterprises/ee/Users/0db5"), - Display: Ptr("d2"), + Ref: new("https://api.github.localhost/scim/v2/enterprises/ee/Users/0db5"), + Display: new("d2"), }}, Meta: &SCIMEnterpriseMeta{ ResourceType: "Group", Created: &Timestamp{referenceTime}, LastModified: &Timestamp{referenceTime}, - Location: Ptr("https://api.github.localhost/scim/v2/enterprises/ee/Groups/abcd"), + Location: new("https://api.github.localhost/scim/v2/enterprises/ee/Groups/abcd"), }, } @@ -653,7 +653,7 @@ func TestEnterpriseService_ProvisionSCIMUser(t *testing.T) { Active: true, UserName: "e123", Name: &SCIMEnterpriseUserName{ - Formatted: Ptr("John Doe"), + Formatted: new("John Doe"), FamilyName: "Doe", GivenName: "John", }, @@ -665,7 +665,7 @@ func TestEnterpriseService_ProvisionSCIMUser(t *testing.T) { }}, Roles: []*SCIMEnterpriseUserRole{{ Value: "User", - Primary: Ptr(false), + Primary: new(false), }}, } @@ -705,13 +705,13 @@ func TestEnterpriseService_ProvisionSCIMUser(t *testing.T) { }) want := &SCIMEnterpriseUserAttributes{ Schemas: []string{SCIMSchemasURINamespacesUser}, - ID: Ptr("7fce"), + ID: new("7fce"), ExternalID: "e123", Active: true, UserName: "e123", DisplayName: "DOE John", Name: &SCIMEnterpriseUserName{ - Formatted: Ptr("John Doe"), + Formatted: new("John Doe"), FamilyName: "Doe", GivenName: "John", }, @@ -722,13 +722,13 @@ func TestEnterpriseService_ProvisionSCIMUser(t *testing.T) { }}, Roles: []*SCIMEnterpriseUserRole{{ Value: "User", - Primary: Ptr(false), + Primary: new(false), }}, Meta: &SCIMEnterpriseMeta{ ResourceType: "User", Created: &Timestamp{referenceTime}, LastModified: &Timestamp{referenceTime}, - Location: Ptr("https://api.github.localhost/scim/v2/enterprises/ee/Users/7fce"), + Location: new("https://api.github.localhost/scim/v2/enterprises/ee/Users/7fce"), }, } @@ -785,27 +785,27 @@ func TestEnterpriseService_GetProvisionedSCIMGroup(t *testing.T) { }) ctx := t.Context() - opts := &GetProvisionedSCIMGroupEnterpriseOptions{ExcludedAttributes: Ptr("members,meta")} + opts := &GetProvisionedSCIMGroupEnterpriseOptions{ExcludedAttributes: new("members,meta")} got, _, err := client.Enterprise.GetProvisionedSCIMGroup(ctx, "ee", "914a", opts) if err != nil { t.Fatalf("Enterprise.GetProvisionedSCIMGroup returned unexpected error: %v", err) } want := &SCIMEnterpriseGroupAttributes{ - ID: Ptr("914a"), + ID: new("914a"), Meta: &SCIMEnterpriseMeta{ ResourceType: "Group", Created: &Timestamp{referenceTime}, LastModified: &Timestamp{referenceTime}, - Location: Ptr("https://api.github.com/scim/v2/enterprises/ee/Groups/914a"), + Location: new("https://api.github.com/scim/v2/enterprises/ee/Groups/914a"), }, - DisplayName: Ptr("gn1"), + DisplayName: new("gn1"), Schemas: []string{SCIMSchemasURINamespacesGroups}, - ExternalID: Ptr("de88"), + ExternalID: new("de88"), Members: []*SCIMEnterpriseDisplayReference{{ Value: "e7f9", - Ref: Ptr("https://api.github.com/scim/v2/enterprises/ee/Users/e7f9"), - Display: Ptr("d1"), + Ref: new("https://api.github.com/scim/v2/enterprises/ee/Users/e7f9"), + Display: new("d1"), }}, } @@ -871,14 +871,14 @@ func TestEnterpriseService_GetProvisionedSCIMUser(t *testing.T) { want := &SCIMEnterpriseUserAttributes{ Schemas: []string{SCIMSchemasURINamespacesUser}, - ID: Ptr("5fc0"), + ID: new("5fc0"), ExternalID: "00u1", UserName: "octocat@github.com", DisplayName: "Mona Octocat", Name: &SCIMEnterpriseUserName{ GivenName: "Mona", FamilyName: "Octocat", - Formatted: Ptr("Mona Octocat"), + Formatted: new("Mona Octocat"), }, Emails: []*SCIMEnterpriseUserEmail{{ Value: "octocat@github.com", @@ -889,7 +889,7 @@ func TestEnterpriseService_GetProvisionedSCIMUser(t *testing.T) { ResourceType: "User", Created: &Timestamp{referenceTime}, LastModified: &Timestamp{referenceTime}, - Location: Ptr("https://api.github.com/scim/v2/enterprises/ee/Users/5fc0"), + Location: new("https://api.github.com/scim/v2/enterprises/ee/Users/5fc0"), }, } diff --git a/github/enterprise_team_test.go b/github/enterprise_team_test.go index e8a9562fcae..588b6b04bc1 100644 --- a/github/enterprise_team_test.go +++ b/github/enterprise_team_test.go @@ -255,9 +255,9 @@ func TestEnterpriseService_ListTeamMembers(t *testing.T) { want := []*User{ { - Login: Ptr("user1"), - ID: Ptr(int64(1001)), - URL: Ptr("https://example.com/user1"), + Login: new("user1"), + ID: new(int64(1001)), + URL: new("https://example.com/user1"), }, } @@ -302,8 +302,8 @@ func TestEnterpriseService_BulkAddTeamMembers(t *testing.T) { } want := []*User{ - {Login: Ptr("u1"), ID: Ptr(int64(1))}, - {Login: Ptr("u2"), ID: Ptr(int64(2))}, + {Login: new("u1"), ID: new(int64(1))}, + {Login: new("u2"), ID: new(int64(2))}, } if !cmp.Equal(got, want) { @@ -347,8 +347,8 @@ func TestEnterpriseService_BulkRemoveTeamMembers(t *testing.T) { } want := []*User{ - {Login: Ptr("u1"), ID: Ptr(int64(1))}, - {Login: Ptr("u2"), ID: Ptr(int64(2))}, + {Login: new("u1"), ID: new(int64(1))}, + {Login: new("u2"), ID: new(int64(2))}, } if !cmp.Equal(got, want) { @@ -388,8 +388,8 @@ func TestEnterpriseService_GetTeamMembership(t *testing.T) { } want := &User{ - Login: Ptr("u1"), - ID: Ptr(int64(10)), + Login: new("u1"), + ID: new(int64(10)), } if !cmp.Equal(got, want) { @@ -429,8 +429,8 @@ func TestEnterpriseService_AddTeamMember(t *testing.T) { } want := &User{ - Login: Ptr("u1"), - ID: Ptr(int64(5)), + Login: new("u1"), + ID: new(int64(5)), } if !cmp.Equal(got, want) { @@ -512,18 +512,18 @@ func TestEnterpriseService_ListAssignments(t *testing.T) { want := []*Organization{ { - Login: Ptr("team-one"), - URL: Ptr("https://example.com/team1"), - NodeID: Ptr("node-id"), - ReposURL: Ptr("https://example.com/members"), - EventsURL: Ptr("https://example.com/events"), - ID: Ptr(int64(1)), - HooksURL: Ptr("https://api.github.com/orgs/team-one/hooks"), - IssuesURL: Ptr("https://api.github.com/orgs/team-one/issues"), - MembersURL: Ptr("https://api.github.com/orgs/team-one/members"), - PublicMembersURL: Ptr("https://api.github.com/orgs/team-one/public_members"), - AvatarURL: Ptr("https://github.com/images/error/octocat_happy.gif"), - Description: Ptr("Team One"), + Login: new("team-one"), + URL: new("https://example.com/team1"), + NodeID: new("node-id"), + ReposURL: new("https://example.com/members"), + EventsURL: new("https://example.com/events"), + ID: new(int64(1)), + HooksURL: new("https://api.github.com/orgs/team-one/hooks"), + IssuesURL: new("https://api.github.com/orgs/team-one/issues"), + MembersURL: new("https://api.github.com/orgs/team-one/members"), + PublicMembersURL: new("https://api.github.com/orgs/team-one/public_members"), + AvatarURL: new("https://github.com/images/error/octocat_happy.gif"), + Description: new("Team One"), }, } @@ -569,8 +569,8 @@ func TestEnterpriseService_AddMultipleAssignments(t *testing.T) { } want := []*Organization{ - {Login: Ptr("o1"), ID: Ptr(int64(1))}, - {Login: Ptr("o2"), ID: Ptr(int64(2))}, + {Login: new("o1"), ID: new(int64(1))}, + {Login: new("o2"), ID: new(int64(2))}, } if !cmp.Equal(got, want) { @@ -614,8 +614,8 @@ func TestEnterpriseService_RemoveMultipleAssignments(t *testing.T) { } want := []*Organization{ - {Login: Ptr("o1"), ID: Ptr(int64(1))}, - {Login: Ptr("o2"), ID: Ptr(int64(2))}, + {Login: new("o1"), ID: new(int64(1))}, + {Login: new("o2"), ID: new(int64(2))}, } if !cmp.Equal(got, want) { @@ -655,8 +655,8 @@ func TestEnterpriseService_GetAssignment(t *testing.T) { } want := &Organization{ - Login: Ptr("o1"), - ID: Ptr(int64(10)), + Login: new("o1"), + ID: new(int64(10)), } if !cmp.Equal(got, want) { @@ -696,8 +696,8 @@ func TestEnterpriseService_AddAssignment(t *testing.T) { } want := &Organization{ - Login: Ptr("o1"), - ID: Ptr(int64(5)), + Login: new("o1"), + ID: new(int64(5)), } if !cmp.Equal(got, want) { diff --git a/github/event_test.go b/github/event_test.go index bbcf6d126b3..a516416c00d 100644 --- a/github/event_test.go +++ b/github/event_test.go @@ -19,14 +19,14 @@ func TestPayload_Panic(t *testing.T) { }() body := json.RawMessage("[") // bogus JSON - e := &Event{Type: Ptr("UserEvent"), RawPayload: &body} + e := &Event{Type: new("UserEvent"), RawPayload: &body} e.Payload() } func TestPayload_NoPanic(t *testing.T) { t.Parallel() body := json.RawMessage("{}") - e := &Event{Type: Ptr("UserEvent"), RawPayload: &body} + e := &Event{Type: new("UserEvent"), RawPayload: &body} e.Payload() } diff --git a/github/examples_test.go b/github/examples_test.go index e1c373b841d..c4a37952f1e 100644 --- a/github/examples_test.go +++ b/github/examples_test.go @@ -91,10 +91,10 @@ func ExampleRepositoriesService_CreateFile() { // Note: the file needs to be absent from the repository as you are not // specifying a SHA reference here. opts := &github.RepositoryContentFileOptions{ - Message: github.Ptr("This is my commit message"), + Message: new("This is my commit message"), Content: fileContent, - Branch: github.Ptr("master"), - Committer: &github.CommitAuthor{Name: github.Ptr("FirstName LastName"), Email: github.Ptr("user@example.com")}, + Branch: new("master"), + Committer: &github.CommitAuthor{Name: new("FirstName LastName"), Email: new("user@example.com")}, } if _, _, err := client.Repositories.CreateFile(ctx, "myOrganization", "myRepository", "myNewFile.md", opts); err != nil { log.Fatalf("Error creating file: %v", err) @@ -136,11 +136,11 @@ func ExamplePullRequestsService_Create() { } newPR := github.CreatePullRequest{ - Title: github.Ptr("My awesome pull request"), + Title: new("My awesome pull request"), Head: "branch_to_merge", Base: "master", - Body: github.Ptr("This is the description of the PR created with the package `github.com/google/go-github/github`"), - MaintainerCanModify: github.Ptr(true), + Body: new("This is the description of the PR created with the package `github.com/google/go-github/github`"), + MaintainerCanModify: new(true), } ctx := context.Background() diff --git a/github/gists_comments_test.go b/github/gists_comments_test.go index a18022cbb93..a5bb3f6deb7 100644 --- a/github/gists_comments_test.go +++ b/github/gists_comments_test.go @@ -30,7 +30,7 @@ func TestGistsService_ListComments(t *testing.T) { t.Errorf("Gists.ListComments returned error: %v", err) } - want := []*GistComment{{ID: Ptr(int64(1))}} + want := []*GistComment{{ID: new(int64(1))}} if !cmp.Equal(comments, want) { t.Errorf("Gists.ListComments returned %+v, want %+v", comments, want) } @@ -74,7 +74,7 @@ func TestGistsService_GetComment(t *testing.T) { t.Errorf("Gists.GetComment returned error: %v", err) } - want := &GistComment{ID: Ptr(int64(1))} + want := &GistComment{ID: new(int64(1))} if !cmp.Equal(comment, want) { t.Errorf("Gists.GetComment returned %+v, want %+v", comment, want) } @@ -121,7 +121,7 @@ func TestGistsService_CreateComment(t *testing.T) { t.Errorf("Gists.CreateComment returned error: %v", err) } - want := &GistComment{ID: Ptr(int64(1))} + want := &GistComment{ID: new(int64(1))} if !cmp.Equal(comment, want) { t.Errorf("Gists.CreateComment returned %+v, want %+v", comment, want) } @@ -168,7 +168,7 @@ func TestGistsService_UpdateComment(t *testing.T) { t.Errorf("Gists.UpdateComment returned error: %v", err) } - want := &GistComment{ID: Ptr(int64(1))} + want := &GistComment{ID: new(int64(1))} if !cmp.Equal(comment, want) { t.Errorf("Gists.UpdateComment returned %+v, want %+v", comment, want) } diff --git a/github/gists_test.go b/github/gists_test.go index 6a5b2859e5e..e024454d251 100644 --- a/github/gists_test.go +++ b/github/gists_test.go @@ -32,7 +32,7 @@ func TestGistsService_List_specifiedUser(t *testing.T) { t.Errorf("Gists.List returned error: %v", err) } - want := []*Gist{{ID: Ptr("1")}} + want := []*Gist{{ID: new("1")}} if !cmp.Equal(gists, want) { t.Errorf("Gists.List returned %+v, want %+v", gists, want) } @@ -67,7 +67,7 @@ func TestGistsService_List_authenticatedUser(t *testing.T) { t.Errorf("Gists.List returned error: %v", err) } - want := []*Gist{{ID: Ptr("1")}} + want := []*Gist{{ID: new("1")}} if !cmp.Equal(gists, want) { t.Errorf("Gists.List returned %+v, want %+v", gists, want) } @@ -115,7 +115,7 @@ func TestGistsService_ListAll(t *testing.T) { t.Errorf("Gists.ListAll returned error: %v", err) } - want := []*Gist{{ID: Ptr("1")}} + want := []*Gist{{ID: new("1")}} if !cmp.Equal(gists, want) { t.Errorf("Gists.ListAll returned %+v, want %+v", gists, want) } @@ -149,7 +149,7 @@ func TestGistsService_ListStarred(t *testing.T) { t.Errorf("Gists.ListStarred returned error: %v", err) } - want := []*Gist{{ID: Ptr("1")}} + want := []*Gist{{ID: new("1")}} if !cmp.Equal(gists, want) { t.Errorf("Gists.ListStarred returned %+v, want %+v", gists, want) } @@ -179,7 +179,7 @@ func TestGistsService_Get(t *testing.T) { t.Errorf("Gists.Get returned error: %v", err) } - want := &Gist{ID: Ptr("1")} + want := &Gist{ID: new("1")} if !cmp.Equal(gist, want) { t.Errorf("Gists.Get returned %+v, want %+v", gist, want) } @@ -223,7 +223,7 @@ func TestGistsService_GetRevision(t *testing.T) { t.Errorf("Gists.GetRevision returned error: %v", err) } - want := &Gist{ID: Ptr("1")} + want := &Gist{ID: new("1")} if !cmp.Equal(gist, want) { t.Errorf("Gists.GetRevision returned %+v, want %+v", gist, want) } @@ -257,8 +257,8 @@ func TestGistsService_Create(t *testing.T) { client, mux, _ := setup(t) input := CreateGistRequest{ - Description: Ptr("Gist description"), - Public: Ptr(false), + Description: new("Gist description"), + Public: new(false), Files: map[GistFilename]*CreateGistFile{ "test.txt": {Content: "Gist file content"}, }, @@ -289,11 +289,11 @@ func TestGistsService_Create(t *testing.T) { } want := &Gist{ - ID: Ptr("1"), - Description: Ptr("Gist description"), - Public: Ptr(false), + ID: new("1"), + Description: new("Gist description"), + Public: new(false), Files: map[GistFilename]GistFile{ - "test.txt": {Filename: Ptr("test.txt")}, + "test.txt": {Filename: new("test.txt")}, }, } if !cmp.Equal(gist, want) { @@ -315,9 +315,9 @@ func TestGistsService_Update(t *testing.T) { client, mux, _ := setup(t) input := UpdateGistRequest{ - Description: Ptr("New description"), + Description: new("New description"), Files: map[GistFilename]*UpdateGistFile{ - "new.txt": {Content: Ptr("new file content")}, + "new.txt": {Content: new("new file content")}, // A nil value deletes the file from the gist. "old.txt": nil, }, @@ -351,12 +351,12 @@ func TestGistsService_Update(t *testing.T) { } want := &Gist{ - ID: Ptr("1"), - Description: Ptr("new description"), - Public: Ptr(false), + ID: new("1"), + Description: new("new description"), + Public: new(false), Files: map[GistFilename]GistFile{ - "test.txt": {Filename: Ptr("test.txt")}, - "new.txt": {Filename: Ptr("new.txt")}, + "test.txt": {Filename: new("test.txt")}, + "new.txt": {Filename: new("new.txt")}, }, } if !cmp.Equal(gist, want) { @@ -420,14 +420,14 @@ func TestGistsService_ListCommits(t *testing.T) { } want := []*GistCommit{{ - URL: Ptr("https://api.github.com/gists/1/1"), - Version: Ptr("1"), - User: &User{ID: Ptr(int64(1))}, + URL: new("https://api.github.com/gists/1/1"), + Version: new("1"), + User: &User{ID: new(int64(1))}, CommittedAt: &referenceTimestamp, ChangeStatus: &CommitStats{ - Additions: Ptr(180), - Deletions: Ptr(0), - Total: Ptr(180), + Additions: new(180), + Deletions: new(0), + Total: new(180), }, }} @@ -684,7 +684,7 @@ func TestGistsService_Fork(t *testing.T) { t.Errorf("Gists.Fork returned error: %v", err) } - want := &Gist{ID: Ptr("2")} + want := &Gist{ID: new("2")} if !cmp.Equal(gist, want) { t.Errorf("Gists.Fork returned %+v, want %+v", gist, want) } @@ -730,9 +730,9 @@ func TestGistsService_ListForks(t *testing.T) { } want := []*GistFork{{ - URL: Ptr("https://api.github.com/gists/1"), - ID: Ptr("1"), - User: &User{ID: Ptr(int64(1))}, + URL: new("https://api.github.com/gists/1"), + ID: new("1"), + User: &User{ID: new(int64(1))}, CreatedAt: refTimestamp(1136178000), UpdatedAt: refTimestamp(1136178001), }} diff --git a/github/git_blobs_test.go b/github/git_blobs_test.go index cfc02da02de..c5cd0eb2c27 100644 --- a/github/git_blobs_test.go +++ b/github/git_blobs_test.go @@ -34,8 +34,8 @@ func TestGitService_GetBlob(t *testing.T) { } want := Blob{ - SHA: Ptr("s"), - Content: Ptr("blob content"), + SHA: new("s"), + Content: new("blob content"), } if !cmp.Equal(*blob, want) { @@ -108,10 +108,10 @@ func TestGitService_CreateBlob(t *testing.T) { client, mux, _ := setup(t) input := Blob{ - SHA: Ptr("s"), - Content: Ptr("blob content"), - Encoding: Ptr("utf-8"), - Size: Ptr(12), + SHA: new("s"), + Content: new("blob content"), + Encoding: new("utf-8"), + Size: new(12), } mux.HandleFunc("/repos/o/r/git/blobs", func(w http.ResponseWriter, r *http.Request) { diff --git a/github/git_commits_test.go b/github/git_commits_test.go index f7febde7246..5e20c13fcb6 100644 --- a/github/git_commits_test.go +++ b/github/git_commits_test.go @@ -51,7 +51,7 @@ func TestGitService_GetCommit(t *testing.T) { t.Errorf("Git.GetCommit returned error: %v", err) } - want := &Commit{SHA: Ptr("s"), Message: Ptr("Commit Message."), Author: &CommitAuthor{Name: Ptr("n")}} + want := &Commit{SHA: new("s"), Message: new("Commit Message."), Author: &CommitAuthor{Name: new("n")}} if !cmp.Equal(commit, want) { t.Errorf("Git.GetCommit returned %+v, want %+v", commit, want) } @@ -85,9 +85,9 @@ func TestGitService_CreateCommit(t *testing.T) { client, mux, _ := setup(t) input := Commit{ - Message: Ptr("Commit Message."), - Tree: &Tree{SHA: Ptr("t")}, - Parents: []*Commit{{SHA: Ptr("p")}}, + Message: new("Commit Message."), + Tree: &Tree{SHA: new("t")}, + Parents: []*Commit{{SHA: new("p")}}, } mux.HandleFunc("/repos/o/r/git/commits", func(w http.ResponseWriter, r *http.Request) { @@ -107,7 +107,7 @@ func TestGitService_CreateCommit(t *testing.T) { t.Errorf("Git.CreateCommit returned error: %v", err) } - want := &Commit{SHA: Ptr("s")} + want := &Commit{SHA: new("s")} if !cmp.Equal(commit, want) { t.Errorf("Git.CreateCommit returned %+v, want %+v", commit, want) } @@ -132,11 +132,11 @@ func TestGitService_CreateSignedCommit(t *testing.T) { client, mux, _ := setup(t) input := Commit{ - Message: Ptr("Commit Message."), - Tree: &Tree{SHA: Ptr("t")}, - Parents: []*Commit{{SHA: Ptr("p")}}, + Message: new("Commit Message."), + Tree: &Tree{SHA: new("t")}, + Parents: []*Commit{{SHA: new("p")}}, Verification: &SignatureVerification{ - Signature: Ptr("----- BEGIN PGP SIGNATURE -----\n\naaaa\naaaa\n----- END PGP SIGNATURE -----"), + Signature: new("----- BEGIN PGP SIGNATURE -----\n\naaaa\naaaa\n----- END PGP SIGNATURE -----"), }, } @@ -163,7 +163,7 @@ func TestGitService_CreateSignedCommit(t *testing.T) { t.Errorf("Git.CreateCommit returned error: %v", err) } - want := &Commit{SHA: Ptr("commitSha")} + want := &Commit{SHA: new("commitSha")} if !cmp.Equal(commit, want) { t.Errorf("Git.CreateCommit returned %+v, want %+v", commit, want) } @@ -204,8 +204,8 @@ func TestGitService_CreateCommit_WithSigner(t *testing.T) { signature := "my voice is my password" date := time.Date(2017, time.May, 4, 0, 3, 43, 0, time.FixedZone("CEST", 2*3600)) author := CommitAuthor{ - Name: Ptr("go-github"), - Email: Ptr("go-github@github.com"), + Name: new("go-github"), + Email: new("go-github@github.com"), Date: &Timestamp{date}, } wantMessage := `tree t @@ -217,14 +217,14 @@ Commit Message.` sha := "commitSha" input := Commit{ SHA: &sha, - Message: Ptr("Commit Message."), - Tree: &Tree{SHA: Ptr("t")}, - Parents: []*Commit{{SHA: Ptr("p")}}, + Message: new("Commit Message."), + Tree: &Tree{SHA: new("t")}, + Parents: []*Commit{{SHA: new("p")}}, Author: &author, } wantBody := &createCommit{ Message: input.Message, - Tree: Ptr("t"), + Tree: new("t"), Parents: []string{"p"}, Author: &author, Signature: &signature, @@ -247,8 +247,8 @@ Commit Message.` func TestGitService_createSignature_nilSigner(t *testing.T) { t.Parallel() a := &createCommit{ - Message: Ptr("Commit Message."), - Tree: Ptr("t"), + Message: new("Commit Message."), + Tree: new("t"), Parents: []string{"p"}, } @@ -271,10 +271,10 @@ func TestGitService_createSignature_nilCommit(t *testing.T) { func TestGitService_createSignature_signerError(t *testing.T) { t.Parallel() a := &createCommit{ - Message: Ptr("Commit Message."), - Tree: Ptr("t"), + Message: new("Commit Message."), + Tree: new("t"), Parents: []string{"p"}, - Author: &CommitAuthor{Name: Ptr("go-github")}, + Author: &CommitAuthor{Name: new("go-github")}, } signer := mockSigner(t, "", errors.New("signer error"), "") @@ -301,8 +301,8 @@ func TestGitService_createSignatureMessage_nilMessage(t *testing.T) { Message: nil, Parents: []string{"p"}, Author: &CommitAuthor{ - Name: Ptr("go-github"), - Email: Ptr("go-github@github.com"), + Name: new("go-github"), + Email: new("go-github@github.com"), Date: &Timestamp{date}, }, }) @@ -315,11 +315,11 @@ func TestGitService_createSignatureMessage_emptyMessage(t *testing.T) { t.Parallel() date, _ := time.Parse("Mon Jan 02 15:04:05 2006 -0700", "Thu May 04 00:03:43 2017 +0200") _, err := createSignatureMessage(&createCommit{ - Message: Ptr(""), + Message: new(""), Parents: []string{"p"}, Author: &CommitAuthor{ - Name: Ptr("go-github"), - Email: Ptr("go-github@github.com"), + Name: new("go-github"), + Email: new("go-github@github.com"), Date: &Timestamp{date}, }, }) @@ -331,7 +331,7 @@ func TestGitService_createSignatureMessage_emptyMessage(t *testing.T) { func TestGitService_createSignatureMessage_nilAuthor(t *testing.T) { t.Parallel() _, err := createSignatureMessage(&createCommit{ - Message: Ptr("Commit Message."), + Message: new("Commit Message."), Parents: []string{"p"}, Author: nil, }) @@ -345,11 +345,11 @@ func TestGitService_createSignatureMessage_withoutTree(t *testing.T) { date, _ := time.Parse("Mon Jan 02 15:04:05 2006 -0700", "Thu May 04 00:03:43 2017 +0200") msg, _ := createSignatureMessage(&createCommit{ - Message: Ptr("Commit Message."), + Message: new("Commit Message."), Parents: []string{"p"}, Author: &CommitAuthor{ - Name: Ptr("go-github"), - Email: Ptr("go-github@github.com"), + Name: new("go-github"), + Email: new("go-github@github.com"), Date: &Timestamp{date}, }, }) @@ -368,16 +368,16 @@ func TestGitService_createSignatureMessage_withoutCommitter(t *testing.T) { date, _ := time.Parse("Mon Jan 02 15:04:05 2006 -0700", "Thu May 04 00:03:43 2017 +0200") msg, _ := createSignatureMessage(&createCommit{ - Message: Ptr("Commit Message."), + Message: new("Commit Message."), Parents: []string{"p"}, Author: &CommitAuthor{ - Name: Ptr("go-github"), - Email: Ptr("go-github@github.com"), + Name: new("go-github"), + Email: new("go-github@github.com"), Date: &Timestamp{date}, }, Committer: &CommitAuthor{ - Name: Ptr("foo"), - Email: Ptr("foo@example.com"), + Name: new("foo"), + Email: new("foo@example.com"), Date: &Timestamp{date}, }, }) diff --git a/github/git_refs_test.go b/github/git_refs_test.go index f3dedaba172..c153c3861c6 100644 --- a/github/git_refs_test.go +++ b/github/git_refs_test.go @@ -39,12 +39,12 @@ func TestGitService_GetRef_singleRef(t *testing.T) { } want := &Reference{ - Ref: Ptr("refs/heads/b"), - URL: Ptr("https://api.github.com/repos/o/r/git/refs/heads/b"), + Ref: new("refs/heads/b"), + URL: new("https://api.github.com/repos/o/r/git/refs/heads/b"), Object: &GitObject{ - Type: Ptr("commit"), - SHA: Ptr("aa218f56b14c9653891f9e74264a383fa43fefbd"), - URL: Ptr("https://api.github.com/repos/o/r/git/commits/aa218f56b14c9653891f9e74264a383fa43fefbd"), + Type: new("commit"), + SHA: new("aa218f56b14c9653891f9e74264a383fa43fefbd"), + URL: new("https://api.github.com/repos/o/r/git/commits/aa218f56b14c9653891f9e74264a383fa43fefbd"), }, } if !cmp.Equal(ref, want) { @@ -135,12 +135,12 @@ func TestGitService_ListMatchingRefs_singleRef(t *testing.T) { ref := refs[0] want := &Reference{ - Ref: Ptr("refs/heads/b"), - URL: Ptr("https://api.github.com/repos/o/r/git/refs/heads/b"), + Ref: new("refs/heads/b"), + URL: new("https://api.github.com/repos/o/r/git/refs/heads/b"), Object: &GitObject{ - Type: Ptr("commit"), - SHA: Ptr("aa218f56b14c9653891f9e74264a383fa43fefbd"), - URL: Ptr("https://api.github.com/repos/o/r/git/commits/aa218f56b14c9653891f9e74264a383fa43fefbd"), + Type: new("commit"), + SHA: new("aa218f56b14c9653891f9e74264a383fa43fefbd"), + URL: new("https://api.github.com/repos/o/r/git/commits/aa218f56b14c9653891f9e74264a383fa43fefbd"), }, } if !cmp.Equal(ref, want) { @@ -199,12 +199,12 @@ func TestGitService_ListMatchingRefs_multipleRefs(t *testing.T) { } want := &Reference{ - Ref: Ptr("refs/heads/booger"), - URL: Ptr("https://api.github.com/repos/o/r/git/refs/heads/booger"), + Ref: new("refs/heads/booger"), + URL: new("https://api.github.com/repos/o/r/git/refs/heads/booger"), Object: &GitObject{ - Type: Ptr("commit"), - SHA: Ptr("aa218f56b14c9653891f9e74264a383fa43fefbd"), - URL: Ptr("https://api.github.com/repos/o/r/git/commits/aa218f56b14c9653891f9e74264a383fa43fefbd"), + Type: new("commit"), + SHA: new("aa218f56b14c9653891f9e74264a383fa43fefbd"), + URL: new("https://api.github.com/repos/o/r/git/commits/aa218f56b14c9653891f9e74264a383fa43fefbd"), }, } if !cmp.Equal(refs[0], want) { @@ -297,21 +297,21 @@ func TestGitService_ListMatchingRefs_allRefs(t *testing.T) { want := []*Reference{ { - Ref: Ptr("refs/heads/branchA"), - URL: Ptr("https://api.github.com/repos/o/r/git/refs/heads/branchA"), + Ref: new("refs/heads/branchA"), + URL: new("https://api.github.com/repos/o/r/git/refs/heads/branchA"), Object: &GitObject{ - Type: Ptr("commit"), - SHA: Ptr("aa218f56b14c9653891f9e74264a383fa43fefbd"), - URL: Ptr("https://api.github.com/repos/o/r/git/commits/aa218f56b14c9653891f9e74264a383fa43fefbd"), + Type: new("commit"), + SHA: new("aa218f56b14c9653891f9e74264a383fa43fefbd"), + URL: new("https://api.github.com/repos/o/r/git/commits/aa218f56b14c9653891f9e74264a383fa43fefbd"), }, }, { - Ref: Ptr("refs/heads/branchB"), - URL: Ptr("https://api.github.com/repos/o/r/git/refs/heads/branchB"), + Ref: new("refs/heads/branchB"), + URL: new("https://api.github.com/repos/o/r/git/refs/heads/branchB"), Object: &GitObject{ - Type: Ptr("commit"), - SHA: Ptr("aa218f56b14c9653891f9e74264a383fa43fefbd"), - URL: Ptr("https://api.github.com/repos/o/r/git/commits/aa218f56b14c9653891f9e74264a383fa43fefbd"), + Type: new("commit"), + SHA: new("aa218f56b14c9653891f9e74264a383fa43fefbd"), + URL: new("https://api.github.com/repos/o/r/git/commits/aa218f56b14c9653891f9e74264a383fa43fefbd"), }, }, } @@ -368,12 +368,12 @@ func TestGitService_CreateRef(t *testing.T) { } want := &Reference{ - Ref: Ptr("refs/heads/b"), - URL: Ptr("https://api.github.com/repos/o/r/git/refs/heads/b"), + Ref: new("refs/heads/b"), + URL: new("https://api.github.com/repos/o/r/git/refs/heads/b"), Object: &GitObject{ - Type: Ptr("commit"), - SHA: Ptr("aa218f56b14c9653891f9e74264a383fa43fefbd"), - URL: Ptr("https://api.github.com/repos/o/r/git/commits/aa218f56b14c9653891f9e74264a383fa43fefbd"), + Type: new("commit"), + SHA: new("aa218f56b14c9653891f9e74264a383fa43fefbd"), + URL: new("https://api.github.com/repos/o/r/git/commits/aa218f56b14c9653891f9e74264a383fa43fefbd"), }, } if !cmp.Equal(ref, want) { @@ -420,7 +420,7 @@ func TestGitService_UpdateRef(t *testing.T) { args := UpdateRef{ SHA: "aa218f56b14c9653891f9e74264a383fa43fefbd", - Force: Ptr(true), + Force: new(true), } mux.HandleFunc("/repos/o/r/git/refs/heads/b", func(w http.ResponseWriter, r *http.Request) { @@ -441,19 +441,19 @@ func TestGitService_UpdateRef(t *testing.T) { ctx := t.Context() ref, _, err := client.Git.UpdateRef(ctx, "o", "r", "refs/heads/b", UpdateRef{ SHA: "aa218f56b14c9653891f9e74264a383fa43fefbd", - Force: Ptr(true), + Force: new(true), }) if err != nil { t.Errorf("Git.UpdateRef returned error: %v", err) } want := &Reference{ - Ref: Ptr("refs/heads/b"), - URL: Ptr("https://api.github.com/repos/o/r/git/refs/heads/b"), + Ref: new("refs/heads/b"), + URL: new("https://api.github.com/repos/o/r/git/refs/heads/b"), Object: &GitObject{ - Type: Ptr("commit"), - SHA: Ptr("aa218f56b14c9653891f9e74264a383fa43fefbd"), - URL: Ptr("https://api.github.com/repos/o/r/git/commits/aa218f56b14c9653891f9e74264a383fa43fefbd"), + Type: new("commit"), + SHA: new("aa218f56b14c9653891f9e74264a383fa43fefbd"), + URL: new("https://api.github.com/repos/o/r/git/commits/aa218f56b14c9653891f9e74264a383fa43fefbd"), }, } if !cmp.Equal(ref, want) { @@ -463,7 +463,7 @@ func TestGitService_UpdateRef(t *testing.T) { // without 'refs/' prefix _, _, err = client.Git.UpdateRef(ctx, "o", "r", "heads/b", UpdateRef{ SHA: "aa218f56b14c9653891f9e74264a383fa43fefbd", - Force: Ptr(true), + Force: new(true), }) if err != nil { t.Errorf("Git.UpdateRef returned error: %v", err) @@ -481,7 +481,7 @@ func TestGitService_UpdateRef(t *testing.T) { testBadOptions(t, methodName, func() (err error) { _, _, err = client.Git.UpdateRef(ctx, "\n", "\n", "refs/heads/b", UpdateRef{ SHA: "aa218f56b14c9653891f9e74264a383fa43fefbd", - Force: Ptr(true), + Force: new(true), }) return err }) @@ -489,7 +489,7 @@ func TestGitService_UpdateRef(t *testing.T) { testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { got, resp, err := client.Git.UpdateRef(ctx, "o", "r", "refs/heads/b", UpdateRef{ SHA: "aa218f56b14c9653891f9e74264a383fa43fefbd", - Force: Ptr(true), + Force: new(true), }) if got != nil { t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got) @@ -576,7 +576,7 @@ func TestGitService_UpdateRef_pathEscape(t *testing.T) { args := UpdateRef{ SHA: "aa218f56b14c9653891f9e74264a383fa43fefbd", - Force: Ptr(true), + Force: new(true), } mux.HandleFunc("/repos/o/r/git/refs/heads/b#1", func(w http.ResponseWriter, r *http.Request) { @@ -597,19 +597,19 @@ func TestGitService_UpdateRef_pathEscape(t *testing.T) { ctx := t.Context() ref, _, err := client.Git.UpdateRef(ctx, "o", "r", "refs/heads/b#1", UpdateRef{ SHA: "aa218f56b14c9653891f9e74264a383fa43fefbd", - Force: Ptr(true), + Force: new(true), }) if err != nil { t.Errorf("Git.UpdateRef returned error: %v", err) } want := &Reference{ - Ref: Ptr("refs/heads/b#1"), - URL: Ptr("https://api.github.com/repos/o/r/git/refs/heads/b%231"), + Ref: new("refs/heads/b#1"), + URL: new("https://api.github.com/repos/o/r/git/refs/heads/b%231"), Object: &GitObject{ - Type: Ptr("commit"), - SHA: Ptr("aa218f56b14c9653891f9e74264a383fa43fefbd"), - URL: Ptr("https://api.github.com/repos/o/r/git/commits/aa218f56b14c9653891f9e74264a383fa43fefbd"), + Type: new("commit"), + SHA: new("aa218f56b14c9653891f9e74264a383fa43fefbd"), + URL: new("https://api.github.com/repos/o/r/git/commits/aa218f56b14c9653891f9e74264a383fa43fefbd"), }, } if !cmp.Equal(ref, want) { diff --git a/github/git_tags_test.go b/github/git_tags_test.go index 2ff9de0dc27..00b01e41751 100644 --- a/github/git_tags_test.go +++ b/github/git_tags_test.go @@ -28,7 +28,7 @@ func TestGitService_GetTag(t *testing.T) { t.Errorf("Git.GetTag returned error: %v", err) } - want := &Tag{Tag: Ptr("t")} + want := &Tag{Tag: new("t")} if !cmp.Equal(tag, want) { t.Errorf("Git.GetTag returned %+v, want %+v", tag, want) } @@ -71,7 +71,7 @@ func TestGitService_CreateTag(t *testing.T) { t.Errorf("Git.CreateTag returned error: %v", err) } - want := &Tag{Tag: Ptr("t")} + want := &Tag{Tag: new("t")} if !cmp.Equal(tag, want) { t.Errorf("Git.CreateTag returned %+v, want %+v", tag, want) } diff --git a/github/git_trees_test.go b/github/git_trees_test.go index 035c648e30c..6a86df28dd0 100644 --- a/github/git_trees_test.go +++ b/github/git_trees_test.go @@ -33,13 +33,13 @@ func TestGitService_GetTree(t *testing.T) { } want := Tree{ - SHA: Ptr("s"), + SHA: new("s"), Entries: []*TreeEntry{ { - Type: Ptr("blob"), + Type: new("blob"), }, }, - Truncated: Ptr(true), + Truncated: new(true), } if !cmp.Equal(*tree, want) { t.Errorf("Git.GetTree returned %+v, want %+v", *tree, want) @@ -75,10 +75,10 @@ func TestGitService_CreateTree(t *testing.T) { input := []*TreeEntry{ { - Path: Ptr("file.rb"), - Mode: Ptr("100644"), - Type: Ptr("blob"), - SHA: Ptr("7c258a9869f33c1e1e1f74fbb32f07c86cb5a75b"), + Path: new("file.rb"), + Mode: new("100644"), + Type: new("blob"), + SHA: new("7c258a9869f33c1e1e1f74fbb32f07c86cb5a75b"), }, } @@ -114,14 +114,14 @@ func TestGitService_CreateTree(t *testing.T) { } want := Tree{ - Ptr("cd8274d15fa3ae2ab983129fb037999f264ba9a7"), + new("cd8274d15fa3ae2ab983129fb037999f264ba9a7"), []*TreeEntry{ { - Path: Ptr("file.rb"), - Mode: Ptr("100644"), - Type: Ptr("blob"), - Size: Ptr(132), - SHA: Ptr("7c258a9869f33c1e1e1f74fbb32f07c86cb5a75b"), + Path: new("file.rb"), + Mode: new("100644"), + Type: new("blob"), + Size: new(132), + SHA: new("7c258a9869f33c1e1e1f74fbb32f07c86cb5a75b"), }, }, nil, @@ -152,9 +152,9 @@ func TestGitService_CreateTree_Content(t *testing.T) { input := []*TreeEntry{ { - Path: Ptr("content.md"), - Mode: Ptr("100644"), - Content: Ptr("file content"), + Path: new("content.md"), + Mode: new("100644"), + Content: new("file content"), }, } @@ -191,15 +191,15 @@ func TestGitService_CreateTree_Content(t *testing.T) { } want := Tree{ - Ptr("5c6780ad2c68743383b740fd1dab6f6a33202b11"), + new("5c6780ad2c68743383b740fd1dab6f6a33202b11"), []*TreeEntry{ { - Path: Ptr("content.md"), - Mode: Ptr("100644"), - Type: Ptr("blob"), - Size: Ptr(12), - SHA: Ptr("aad8feacf6f8063150476a7b2bd9770f2794c08b"), - URL: Ptr("https://api.github.com/repos/o/r/git/blobs/aad8feacf6f8063150476a7b2bd9770f2794c08b"), + Path: new("content.md"), + Mode: new("100644"), + Type: new("blob"), + Size: new(12), + SHA: new("aad8feacf6f8063150476a7b2bd9770f2794c08b"), + URL: new("https://api.github.com/repos/o/r/git/blobs/aad8feacf6f8063150476a7b2bd9770f2794c08b"), }, }, nil, @@ -230,8 +230,8 @@ func TestGitService_CreateTree_Delete(t *testing.T) { input := []*TreeEntry{ { - Path: Ptr("content.md"), - Mode: Ptr("100644"), + Path: new("content.md"), + Mode: new("100644"), }, } @@ -268,15 +268,15 @@ func TestGitService_CreateTree_Delete(t *testing.T) { } want := Tree{ - Ptr("5c6780ad2c68743383b740fd1dab6f6a33202b11"), + new("5c6780ad2c68743383b740fd1dab6f6a33202b11"), []*TreeEntry{ { - Path: Ptr("content.md"), - Mode: Ptr("100644"), - Type: Ptr("blob"), - Size: Ptr(12), + Path: new("content.md"), + Mode: new("100644"), + Type: new("blob"), + Size: new(12), SHA: nil, - URL: Ptr("https://api.github.com/repos/o/r/git/blobs/aad8feacf6f8063150476a7b2bd9770f2794c08b"), + URL: new("https://api.github.com/repos/o/r/git/blobs/aad8feacf6f8063150476a7b2bd9770f2794c08b"), }, }, nil, @@ -315,13 +315,13 @@ func TestTreeEntry_MarshalJSON(t *testing.T) { testJSONMarshal(t, &TreeEntry{}, `{"sha": null}`) u := &TreeEntry{ - SHA: Ptr("sha"), - Path: Ptr("path"), - Mode: Ptr("mode"), - Type: Ptr("type"), - Size: Ptr(1), - Content: Ptr("content"), - URL: Ptr("url"), + SHA: new("sha"), + Path: new("path"), + Mode: new("mode"), + Type: new("type"), + Size: new(1), + Content: new("content"), + URL: new("url"), } want := `{ @@ -340,11 +340,11 @@ func TestTreeEntry_MarshalJSON(t *testing.T) { func TestTreeEntry_MarshalJSON_withNilContentAndSHA(t *testing.T) { t.Parallel() te := TreeEntry{ - Path: Ptr("path"), - Mode: Ptr("mode"), - Type: Ptr("type"), - Size: Ptr(1), - URL: Ptr("url"), + Path: new("path"), + Mode: new("mode"), + Type: new("type"), + Size: new(1), + URL: new("url"), } want := `{"sha":null,"path":"path","mode":"mode","type":"type"}` @@ -357,13 +357,13 @@ func TestTreeEntryWithFileDelete_MarshalJSON(t *testing.T) { testJSONMarshal(t, &treeEntryWithFileDelete{}, `{"sha": null}`) u := &treeEntryWithFileDelete{ - SHA: Ptr("sha"), - Path: Ptr("path"), - Mode: Ptr("mode"), - Type: Ptr("type"), - Size: Ptr(1), - Content: Ptr("content"), - URL: Ptr("url"), + SHA: new("sha"), + Path: new("path"), + Mode: new("mode"), + Type: new("type"), + Size: new(1), + Content: new("content"), + URL: new("url"), } want := `{ diff --git a/github/github.go b/github/github.go index 07b08ea27bf..68ba6ee4de1 100644 --- a/github/github.go +++ b/github/github.go @@ -744,8 +744,8 @@ func (c *Client) Clone(opts ...ClientOptionsFunc) (*Client, error) { apiVersionMin: &c.apiVersionMin, apiVersionMax: &c.apiVersionMax, userAgent: &c.userAgent, - baseURL: Ptr(*c.baseURL), - uploadURL: Ptr(*c.uploadURL), + baseURL: new(*c.baseURL), + uploadURL: new(*c.uploadURL), disableRateLimitCheck: c.disableRateLimitCheck, rateLimitRedirectionalEndpoints: c.rateLimitRedirectionalEndpoints, maxSecondaryRateLimitRetryAfterDuration: &c.maxSecondaryRateLimitRetryAfterDuration, @@ -2170,8 +2170,10 @@ func (c *Client) checkRedirectHost(location string) error { // Ptr is a helper routine that allocates a new T value // to store v and returns a pointer to it. +// +//go:fix inline func Ptr[T any](v T) *T { - return &v + return new(v) } // Bool is a helper routine that allocates a new bool value @@ -2180,7 +2182,7 @@ func Ptr[T any](v T) *T { // Deprecated: use Ptr instead. // //go:fix inline -func Bool(v bool) *bool { return Ptr(v) } +func Bool(v bool) *bool { return new(v) } // Int is a helper routine that allocates a new int value // to store v and returns a pointer to it. @@ -2188,7 +2190,7 @@ func Bool(v bool) *bool { return Ptr(v) } // Deprecated: use Ptr instead. // //go:fix inline -func Int(v int) *int { return Ptr(v) } +func Int(v int) *int { return new(v) } // Int64 is a helper routine that allocates a new int64 value // to store v and returns a pointer to it. @@ -2196,7 +2198,7 @@ func Int(v int) *int { return Ptr(v) } // Deprecated: use Ptr instead. // //go:fix inline -func Int64(v int64) *int64 { return Ptr(v) } +func Int64(v int64) *int64 { return new(v) } // String is a helper routine that allocates a new string value // to store v and returns a pointer to it. @@ -2204,7 +2206,7 @@ func Int64(v int64) *int64 { return Ptr(v) } // Deprecated: use Ptr instead. // //go:fix inline -func String(v string) *string { return Ptr(v) } +func String(v string) *string { return new(v) } // roundTripperFunc creates a RoundTripper (transport). type roundTripperFunc func(*http.Request) (*http.Response, error) diff --git a/github/github_test.go b/github/github_test.go index ae585cede4d..393e9250390 100644 --- a/github/github_test.go +++ b/github/github_test.go @@ -608,41 +608,41 @@ func TestWithURLs(t *testing.T) { }{ { name: "does_not_modify_urls_with_trailing_slash", - baseURL: Ptr("https://example.com/"), - wantBaseURL: Ptr("https://example.com/"), - uploadURL: Ptr("https://upload.example.com/"), - wantUploadURL: Ptr("https://upload.example.com/"), + baseURL: new("https://example.com/"), + wantBaseURL: new("https://example.com/"), + uploadURL: new("https://upload.example.com/"), + wantUploadURL: new("https://upload.example.com/"), }, { name: "adds_trailing_slash", - baseURL: Ptr("https://example.com"), - wantBaseURL: Ptr("https://example.com/"), - uploadURL: Ptr("https://upload.example.com"), - wantUploadURL: Ptr("https://upload.example.com/"), + baseURL: new("https://example.com"), + wantBaseURL: new("https://example.com/"), + uploadURL: new("https://upload.example.com"), + wantUploadURL: new("https://upload.example.com/"), }, { name: "skips_unset", }, { name: "error_on_empty_base_url", - baseURL: Ptr(""), + baseURL: new(""), wantErr: "invalid base url: url cannot be empty", }, { name: "error_on_bad_base_url", - baseURL: Ptr("bogus\nbase\nURL"), + baseURL: new("bogus\nbase\nURL"), wantErr: "invalid base url: invalid url", }, { name: "error_on_empty_upload_url", - baseURL: Ptr("https://example.com/"), - uploadURL: Ptr(""), + baseURL: new("https://example.com/"), + uploadURL: new(""), wantErr: "invalid upload url: url cannot be empty", }, { name: "error_on_bad_upload_url", - baseURL: Ptr("https://example.com/"), - uploadURL: Ptr("bogus\nupload\nURL"), + baseURL: new("https://example.com/"), + uploadURL: new("bogus\nupload\nURL"), wantErr: "invalid upload url: invalid url", }, } { @@ -970,9 +970,9 @@ func Test_newClient(t *testing.T) { httpClient: &http.Client{Transport: &http.Transport{IdleConnTimeout: 5 * time.Second}}, transport: &http.Transport{IdleConnTimeout: 10 * time.Second}, timeout: Ptr(15 * time.Second), - apiVersionMin: Ptr(api20221128), - apiVersionMax: Ptr(api20221128), - userAgent: Ptr("CustomUserAgent/1.0"), + apiVersionMin: new(api20221128), + apiVersionMax: new(api20221128), + userAgent: new("CustomUserAgent/1.0"), baseURL: mustParseURL(t, "https://custom-url/api/v3/"), uploadURL: mustParseURL(t, "https://custom-upload-url/api/uploads/"), disableRateLimitCheck: true, @@ -1533,7 +1533,7 @@ func TestNewRequest(t *testing.T) { c := mustNewClient(t) inURL, outURL := "/foo", defaultBaseURL+"foo" - inBody, outBody := &User{Login: Ptr("l")}, `{"login":"l"}`+"\n" + inBody, outBody := &User{Login: new("l")}, `{"login":"l"}`+"\n" req, _ := c.NewRequest(t.Context(), "GET", inURL, inBody) // test that relative URL was expanded @@ -4676,10 +4676,10 @@ func TestPtr(t *testing.T) { } } - equal(t, true, *Ptr(true)) - equal(t, int(10), *Ptr(int(10))) - equal(t, int64(-10), *Ptr(int64(-10))) - equal(t, "str", *Ptr("str")) + equal(t, true, *new(true)) + equal(t, int(10), *new(int(10))) + equal(t, int64(-10), *new(int64(-10))) + equal(t, "str", *new("str")) } func TestDeploymentProtectionRuleEvent_GetRunID(t *testing.T) { diff --git a/github/gitignore_test.go b/github/gitignore_test.go index 1d21836ea4b..fdb1fe29a34 100644 --- a/github/gitignore_test.go +++ b/github/gitignore_test.go @@ -58,7 +58,7 @@ func TestGitignoresService_Get(t *testing.T) { t.Errorf("Gitignores.Get returned error: %v", err) } - want := &Gitignore{Name: Ptr("Name"), Source: Ptr("template source")} + want := &Gitignore{Name: new("Name"), Source: new("template source")} if !cmp.Equal(gitignore, want) { t.Errorf("Gitignores.Get returned %+v, want %+v", gitignore, want) } diff --git a/github/interactions_orgs_test.go b/github/interactions_orgs_test.go index e4acf9603ec..f161f26dcc0 100644 --- a/github/interactions_orgs_test.go +++ b/github/interactions_orgs_test.go @@ -29,7 +29,7 @@ func TestInteractionsService_GetRestrictionsForOrgs(t *testing.T) { t.Errorf("Interactions.GetRestrictionsForOrg returned error: %v", err) } - want := &InteractionRestriction{Origin: Ptr("organization")} + want := &InteractionRestriction{Origin: new("organization")} if !cmp.Equal(organizationInteractions, want) { t.Errorf("Interactions.GetRestrictionsForOrg returned %+v, want %+v", organizationInteractions, want) } @@ -53,7 +53,7 @@ func TestInteractionsService_UpdateRestrictionsForOrg(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - input := &InteractionRestriction{Limit: Ptr("existing_users")} + input := &InteractionRestriction{Limit: new("existing_users")} mux.HandleFunc("/orgs/o/interaction-limits", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "PUT") @@ -68,7 +68,7 @@ func TestInteractionsService_UpdateRestrictionsForOrg(t *testing.T) { t.Errorf("Interactions.UpdateRestrictionsForOrg returned error: %v", err) } - want := &InteractionRestriction{Origin: Ptr("organization")} + want := &InteractionRestriction{Origin: new("organization")} if !cmp.Equal(organizationInteractions, want) { t.Errorf("Interactions.UpdateRestrictionsForOrg returned %+v, want %+v", organizationInteractions, want) } diff --git a/github/interactions_repos_test.go b/github/interactions_repos_test.go index 0146f51a62b..5224a59db2c 100644 --- a/github/interactions_repos_test.go +++ b/github/interactions_repos_test.go @@ -29,7 +29,7 @@ func TestInteractionsService_GetRestrictionsForRepo(t *testing.T) { t.Errorf("Interactions.GetRestrictionsForRepo returned error: %v", err) } - want := &InteractionRestriction{Origin: Ptr("repository")} + want := &InteractionRestriction{Origin: new("repository")} if !cmp.Equal(repoInteractions, want) { t.Errorf("Interactions.GetRestrictionsForRepo returned %+v, want %+v", repoInteractions, want) } @@ -53,7 +53,7 @@ func TestInteractionsService_UpdateRestrictionsForRepo(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - input := &InteractionRestriction{Limit: Ptr("existing_users")} + input := &InteractionRestriction{Limit: new("existing_users")} mux.HandleFunc("/repos/o/r/interaction-limits", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "PUT") @@ -68,7 +68,7 @@ func TestInteractionsService_UpdateRestrictionsForRepo(t *testing.T) { t.Errorf("Interactions.UpdateRestrictionsForRepo returned error: %v", err) } - want := &InteractionRestriction{Origin: Ptr("repository")} + want := &InteractionRestriction{Origin: new("repository")} if !cmp.Equal(repoInteractions, want) { t.Errorf("Interactions.UpdateRestrictionsForRepo returned %+v, want %+v", repoInteractions, want) } diff --git a/github/issue_import_test.go b/github/issue_import_test.go index e3509145206..76151dc5985 100644 --- a/github/issue_import_test.go +++ b/github/issue_import_test.go @@ -20,11 +20,11 @@ func TestIssueImportService_Create(t *testing.T) { input := &IssueImportRequest{ IssueImport: IssueImport{ - Assignee: Ptr("developer"), + Assignee: new("developer"), Body: "Dummy description", CreatedAt: &referenceTimestamp, Labels: []string{"l1", "l2"}, - Milestone: Ptr(1), + Milestone: new(1), Title: "Dummy Issue", }, Comments: []*Comment{{ @@ -72,11 +72,11 @@ func TestIssueImportService_Create_deferred(t *testing.T) { input := &IssueImportRequest{ IssueImport: IssueImport{ - Assignee: Ptr("developer"), + Assignee: new("developer"), Body: "Dummy description", CreatedAt: &referenceTimestamp, Labels: []string{"l1", "l2"}, - Milestone: Ptr(1), + Milestone: new(1), Title: "Dummy Issue", }, Comments: []*Comment{{ @@ -112,11 +112,11 @@ func TestIssueImportService_Create_badResponse(t *testing.T) { input := &IssueImportRequest{ IssueImport: IssueImport{ - Assignee: Ptr("developer"), + Assignee: new("developer"), Body: "Dummy description", CreatedAt: &referenceTimestamp, Labels: []string{"l1", "l2"}, - Milestone: Ptr(1), + Milestone: new(1), Title: "Dummy Issue", }, Comments: []*Comment{{ @@ -268,9 +268,9 @@ var issueImportResponseJSON = []byte(`{ }`) var wantIssueImportResponse = &IssueImportResponse{ - ID: Ptr(3), - Status: Ptr("pending"), - URL: Ptr("https://api.github.com/repos/o/r/import/issues/3"), - ImportIssuesURL: Ptr("https://api.github.com/repos/o/r/import/issues"), - RepositoryURL: Ptr("https://api.github.com/repos/o/r"), + ID: new(3), + Status: new("pending"), + URL: new("https://api.github.com/repos/o/r/import/issues/3"), + ImportIssuesURL: new("https://api.github.com/repos/o/r/import/issues"), + RepositoryURL: new("https://api.github.com/repos/o/r"), } diff --git a/github/issues_assignees_test.go b/github/issues_assignees_test.go index 62002f95073..677f69d02af 100644 --- a/github/issues_assignees_test.go +++ b/github/issues_assignees_test.go @@ -30,7 +30,7 @@ func TestIssuesService_ListAssignees(t *testing.T) { t.Errorf("Issues.ListAssignees returned error: %v", err) } - want := []*User{{ID: Ptr(int64(1))}} + want := []*User{{ID: new(int64(1))}} if !cmp.Equal(assignees, want) { t.Errorf("Issues.ListAssignees returned %+v, want %+v", assignees, want) } @@ -187,7 +187,7 @@ func TestIssuesService_AddAssignees(t *testing.T) { t.Errorf("Issues.AddAssignees returned error: %v", err) } - want := &Issue{Number: Ptr(1), Assignees: []*User{{Login: Ptr("user1")}, {Login: Ptr("user2")}}} + want := &Issue{Number: new(1), Assignees: []*User{{Login: new("user1")}, {Login: new("user2")}}} if !cmp.Equal(got, want) { t.Errorf("Issues.AddAssignees = %+v, want %+v", got, want) } @@ -229,7 +229,7 @@ func TestIssuesService_RemoveAssignees(t *testing.T) { t.Errorf("Issues.RemoveAssignees returned error: %v", err) } - want := &Issue{Number: Ptr(1), Assignees: []*User{}} + want := &Issue{Number: new(1), Assignees: []*User{}} if !cmp.Equal(got, want) { t.Errorf("Issues.RemoveAssignees = %+v, want %+v", got, want) } diff --git a/github/issues_comments_test.go b/github/issues_comments_test.go index a91cc756ca6..49049033ae7 100644 --- a/github/issues_comments_test.go +++ b/github/issues_comments_test.go @@ -30,8 +30,8 @@ func TestIssuesService_ListComments_allIssues(t *testing.T) { }) opt := &IssueListCommentsOptions{ - Sort: Ptr("updated"), - Direction: Ptr("desc"), + Sort: new("updated"), + Direction: new("desc"), Since: &referenceTime, ListOptions: ListOptions{Page: 2}, } @@ -41,7 +41,7 @@ func TestIssuesService_ListComments_allIssues(t *testing.T) { t.Errorf("Issues.ListComments returned error: %v", err) } - want := []*IssueComment{{ID: Ptr(int64(1))}} + want := []*IssueComment{{ID: new(int64(1))}} if !cmp.Equal(comments, want) { t.Errorf("Issues.ListComments returned %+v, want %+v", comments, want) } @@ -77,7 +77,7 @@ func TestIssuesService_ListComments_specificIssue(t *testing.T) { t.Errorf("Issues.ListComments returned error: %v", err) } - want := []*IssueComment{{ID: Ptr(int64(1))}} + want := []*IssueComment{{ID: new(int64(1))}} if !cmp.Equal(comments, want) { t.Errorf("Issues.ListComments returned %+v, want %+v", comments, want) } @@ -122,7 +122,7 @@ func TestIssuesService_GetComment(t *testing.T) { t.Errorf("Issues.GetComment returned error: %v", err) } - want := &IssueComment{ID: Ptr(int64(1))} + want := &IssueComment{ID: new(int64(1))} if !cmp.Equal(comment, want) { t.Errorf("Issues.GetComment returned %+v, want %+v", comment, want) } @@ -169,7 +169,7 @@ func TestIssuesService_CreateComment(t *testing.T) { t.Errorf("Issues.CreateComment returned error: %v", err) } - want := &IssueComment{ID: Ptr(int64(1))} + want := &IssueComment{ID: new(int64(1))} if !cmp.Equal(comment, want) { t.Errorf("Issues.CreateComment returned %+v, want %+v", comment, want) } @@ -216,7 +216,7 @@ func TestIssuesService_UpdateComment(t *testing.T) { t.Errorf("Issues.UpdateComment returned error: %v", err) } - want := &IssueComment{ID: Ptr(int64(1))} + want := &IssueComment{ID: new(int64(1))} if !cmp.Equal(comment, want) { t.Errorf("Issues.UpdateComment returned %+v, want %+v", comment, want) } diff --git a/github/issues_dependencies_test.go b/github/issues_dependencies_test.go index 34a45f8c7fa..f0bba8bd885 100644 --- a/github/issues_dependencies_test.go +++ b/github/issues_dependencies_test.go @@ -30,7 +30,7 @@ func TestIssuesService_ListBlockedBy(t *testing.T) { t.Errorf("Issues.ListBlockedBy returned error: %v", err) } - want := []*Issue{{Number: Ptr(1347), Title: Ptr("Found a bug")}} + want := []*Issue{{Number: new(1347), Title: new("Found a bug")}} if !cmp.Equal(issues, want) { t.Errorf("Issues.ListBlockedBy returned %+v, want %+v", issues, want) } @@ -79,7 +79,7 @@ func TestIssuesService_AddBlockedBy(t *testing.T) { t.Errorf("Issues.AddBlockedBy returned error: %v", err) } - want := &Issue{Number: Ptr(42), Title: Ptr("Dependency issue")} + want := &Issue{Number: new(42), Title: new("Dependency issue")} if !cmp.Equal(issue, want) { t.Errorf("Issues.AddBlockedBy returned %+v, want %+v", issue, want) } @@ -123,7 +123,7 @@ func TestIssuesService_RemoveBlockedBy(t *testing.T) { t.Errorf("Issues.RemoveBlockedBy returned error: %v", err) } - want := &Issue{Number: Ptr(1), Title: Ptr("Original issue")} + want := &Issue{Number: new(1), Title: new("Original issue")} if !cmp.Equal(issue, want) { t.Errorf("Issues.RemoveBlockedBy returned %+v, want %+v", issue, want) } @@ -169,7 +169,7 @@ func TestIssuesService_ListBlocking(t *testing.T) { t.Errorf("Issues.ListBlocking returned error: %v", err) } - want := []*Issue{{Number: Ptr(1348), Title: Ptr("Blocked issue")}} + want := []*Issue{{Number: new(1348), Title: new("Blocked issue")}} if !cmp.Equal(issues, want) { t.Errorf("Issues.ListBlocking returned %+v, want %+v", issues, want) } diff --git a/github/issues_events_test.go b/github/issues_events_test.go index 48b1e9afc6b..03f3b1276df 100644 --- a/github/issues_events_test.go +++ b/github/issues_events_test.go @@ -34,7 +34,7 @@ func TestIssuesService_ListIssueEvents(t *testing.T) { t.Errorf("Issues.ListIssueEvents returned error: %v", err) } - want := []*IssueEvent{{ID: Ptr(int64(1))}} + want := []*IssueEvent{{ID: new(int64(1))}} if !cmp.Equal(events, want) { t.Errorf("Issues.ListIssueEvents returned %+v, want %+v", events, want) } @@ -74,7 +74,7 @@ func TestIssuesService_ListRepositoryEvents(t *testing.T) { t.Errorf("Issues.ListRepositoryEvents returned error: %v", err) } - want := []*IssueEvent{{ID: Ptr(int64(1))}} + want := []*IssueEvent{{ID: new(int64(1))}} if !cmp.Equal(events, want) { t.Errorf("Issues.ListRepositoryEvents returned %+v, want %+v", events, want) } @@ -109,7 +109,7 @@ func TestIssuesService_GetEvent(t *testing.T) { t.Errorf("Issues.GetEvent returned error: %v", err) } - want := &IssueEvent{ID: Ptr(int64(1))} + want := &IssueEvent{ID: new(int64(1))} if !cmp.Equal(event, want) { t.Errorf("Issues.GetEvent returned %+v, want %+v", event, want) } diff --git a/github/issues_labels_test.go b/github/issues_labels_test.go index 0b672218e2d..342b5a98c9b 100644 --- a/github/issues_labels_test.go +++ b/github/issues_labels_test.go @@ -74,7 +74,7 @@ func TestIssuesService_GetLabel(t *testing.T) { t.Errorf("Issues.GetLabel returned error: %v", err) } - want := &Label{URL: "u", Name: "n", Color: "c", Description: Ptr("d")} + want := &Label{URL: "u", Name: "n", Color: "c", Description: new("d")} if !cmp.Equal(label, want) { t.Errorf("Issues.GetLabel returned %+v, want %+v", label, want) } @@ -154,7 +154,7 @@ func TestIssuesService_UpdateLabel(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - input := UpdateIssueLabelRequest{NewName: Ptr("z")} + input := UpdateIssueLabelRequest{NewName: new("z")} mux.HandleFunc("/repos/o/r/labels/n", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "PATCH") diff --git a/github/issues_milestones_test.go b/github/issues_milestones_test.go index 233f4b59b5b..6e802d3b5a7 100644 --- a/github/issues_milestones_test.go +++ b/github/issues_milestones_test.go @@ -35,7 +35,7 @@ func TestIssuesService_ListMilestones(t *testing.T) { t.Errorf("IssuesService.ListMilestones returned error: %v", err) } - want := []*Milestone{{Number: Ptr(1)}} + want := []*Milestone{{Number: new(1)}} if !cmp.Equal(milestones, want) { t.Errorf("IssuesService.ListMilestones returned %+v, want %+v", milestones, want) } @@ -79,7 +79,7 @@ func TestIssuesService_GetMilestone(t *testing.T) { t.Errorf("IssuesService.GetMilestone returned error: %v", err) } - want := &Milestone{Number: Ptr(1)} + want := &Milestone{Number: new(1)} if !cmp.Equal(milestone, want) { t.Errorf("IssuesService.GetMilestone returned %+v, want %+v", milestone, want) } @@ -126,7 +126,7 @@ func TestIssuesService_CreateMilestone(t *testing.T) { t.Errorf("IssuesService.CreateMilestone returned error: %v", err) } - want := &Milestone{Number: Ptr(1)} + want := &Milestone{Number: new(1)} if !cmp.Equal(milestone, want) { t.Errorf("IssuesService.CreateMilestone returned %+v, want %+v", milestone, want) } @@ -159,7 +159,7 @@ func TestIssuesService_UpdateMilestone(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - input := UpdateMilestoneRequest{Title: Ptr("t")} + input := UpdateMilestoneRequest{Title: new("t")} mux.HandleFunc("/repos/o/r/milestones/1", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "PATCH") @@ -173,7 +173,7 @@ func TestIssuesService_UpdateMilestone(t *testing.T) { t.Errorf("IssuesService.UpdateMilestone returned error: %v", err) } - want := &Milestone{Number: Ptr(1)} + want := &Milestone{Number: new(1)} if !cmp.Equal(milestone, want) { t.Errorf("IssuesService.UpdateMilestone returned %+v, want %+v", milestone, want) } diff --git a/github/issues_test.go b/github/issues_test.go index 9c5f90fda8c..6952c5d5447 100644 --- a/github/issues_test.go +++ b/github/issues_test.go @@ -57,7 +57,7 @@ func TestIssuesService_ListAllIssues(t *testing.T) { t.Errorf("Issues.ListAllIssues returned error: %v", err) } - want := []*Issue{{Number: Ptr(1)}} + want := []*Issue{{Number: new(1)}} if !cmp.Equal(issues, want) { t.Errorf("Issues.ListAllIssues = %+v, want %+v", issues, want) } @@ -107,7 +107,7 @@ func TestIssuesService_ListUserIssues(t *testing.T) { t.Errorf("Issues.ListUserIssues returned error: %v", err) } - want := []*Issue{{Number: Ptr(1)}} + want := []*Issue{{Number: new(1)}} if !cmp.Equal(issues, want) { t.Errorf("Issues.ListUserIssues = %+v, want %+v", issues, want) } @@ -159,7 +159,7 @@ func TestIssuesService_ListByOrg(t *testing.T) { t.Errorf("Issues.ListByOrg returned error: %v", err) } - want := []*Issue{{Number: Ptr(1)}} + want := []*Issue{{Number: new(1)}} if !cmp.Equal(issues, want) { t.Errorf("Issues.ListByOrg returned %+v, want %+v", issues, want) } @@ -221,7 +221,7 @@ func TestIssuesService_ListByRepo(t *testing.T) { t.Errorf("Issues.ListByRepo returned error: %v", err) } - want := []*Issue{{Number: Ptr(1)}} + want := []*Issue{{Number: new(1)}} if !cmp.Equal(issues, want) { t.Errorf("Issues.ListByRepo returned %+v, want %+v", issues, want) } @@ -258,8 +258,8 @@ func TestIssuesService_Get(t *testing.T) { } want := &Issue{ - Number: Ptr(1), - AuthorAssociation: Ptr("MEMBER"), + Number: new(1), + AuthorAssociation: new("MEMBER"), Labels: []*Label{{ URL: "u", Name: "n", @@ -300,8 +300,8 @@ func TestIssuesService_Create(t *testing.T) { input := CreateIssueRequest{ Title: "t", - Body: Ptr("b"), - Assignee: Ptr("a"), + Body: new("b"), + Assignee: new("a"), Labels: []string{"l1", "l2"}, } @@ -317,7 +317,7 @@ func TestIssuesService_Create(t *testing.T) { t.Errorf("Issues.Create returned error: %v", err) } - want := &Issue{Number: Ptr(1)} + want := &Issue{Number: new(1)} if !cmp.Equal(issue, want) { t.Errorf("Issues.Create returned %+v, want %+v", issue, want) } @@ -350,7 +350,7 @@ func TestIssuesService_Update(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - input := UpdateIssueRequest{Title: Ptr("t"), Type: Ptr("bug")} + input := UpdateIssueRequest{Title: new("t"), Type: new("bug")} mux.HandleFunc("/repos/o/r/issues/1", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "PATCH") @@ -364,7 +364,7 @@ func TestIssuesService_Update(t *testing.T) { t.Errorf("Issues.Update returned error: %v", err) } - want := &Issue{Number: Ptr(1), Type: &IssueType{Name: Ptr("bug")}} + want := &Issue{Number: new(1), Type: &IssueType{Name: new("bug")}} if !cmp.Equal(issue, want) { t.Errorf("Issues.Update returned %+v, want %+v", issue, want) } @@ -399,7 +399,7 @@ func TestIssuesService_RemoveMilestone(t *testing.T) { t.Errorf("Issues.RemoveMilestone returned error: %v", err) } - want := &Issue{Number: Ptr(1)} + want := &Issue{Number: new(1)} if !cmp.Equal(issue, want) { t.Errorf("Issues.RemoveMilestone returned %+v, want %+v", issue, want) } @@ -547,7 +547,7 @@ func TestIsPullRequest(t *testing.T) { if i.IsPullRequest() { t.Errorf("expected i.IsPullRequest (%v) to return false, got true", i) } - i.PullRequestLinks = &PullRequestLinks{URL: Ptr("http://example.com")} + i.PullRequestLinks = &PullRequestLinks{URL: new("http://example.com")} if !i.IsPullRequest() { t.Errorf("expected i.IsPullRequest (%v) to return true, got false", i) } diff --git a/github/issues_timeline_test.go b/github/issues_timeline_test.go index 81cc6e5b0ae..4fc6b945bf8 100644 --- a/github/issues_timeline_test.go +++ b/github/issues_timeline_test.go @@ -36,7 +36,7 @@ func TestIssuesService_ListIssueTimeline(t *testing.T) { t.Errorf("Issues.ListIssueTimeline returned error: %v", err) } - want := []*Timeline{{ID: Ptr(int64(1))}} + want := []*Timeline{{ID: new(int64(1))}} if !cmp.Equal(events, want) { t.Errorf("Issues.ListIssueTimeline = %+v, want %+v", events, want) } @@ -104,35 +104,35 @@ func TestTimeline_ReviewRequests(t *testing.T) { want := []*Timeline{ { - ID: Ptr(int64(1234567890)), - URL: Ptr("http://example.com/timeline/1"), + ID: new(int64(1234567890)), + URL: new("http://example.com/timeline/1"), Actor: &User{ - Login: Ptr("actor-user"), - ID: Ptr(int64(1)), + Login: new("actor-user"), + ID: new(int64(1)), }, - Event: Ptr("review_requested"), + Event: new("review_requested"), CreatedAt: &Timestamp{referenceTime}, Reviewer: &User{ - Login: Ptr("reviewer-user"), - ID: Ptr(int64(2)), + Login: new("reviewer-user"), + ID: new(int64(2)), }, Requester: &User{ - Login: Ptr("requester-user"), - ID: Ptr(int64(1)), + Login: new("requester-user"), + ID: new(int64(1)), }, }, { - ID: Ptr(int64(1234567891)), - URL: Ptr("http://example.com/timeline/2"), + ID: new(int64(1234567891)), + URL: new("http://example.com/timeline/2"), Actor: &User{ - Login: Ptr("actor-user"), - ID: Ptr(int64(1)), + Login: new("actor-user"), + ID: new(int64(1)), }, - Event: Ptr("review_request_removed"), + Event: new("review_request_removed"), CreatedAt: &Timestamp{referenceTime}, Reviewer: &User{ - Login: Ptr("reviewer-user"), - ID: Ptr(int64(2)), + Login: new("reviewer-user"), + ID: new(int64(2)), }, }, } diff --git a/github/licenses_test.go b/github/licenses_test.go index 521e3712bcf..c69e3839e13 100644 --- a/github/licenses_test.go +++ b/github/licenses_test.go @@ -23,7 +23,7 @@ func TestLicensesService_List(t *testing.T) { fmt.Fprint(w, `[{"key":"mit","name":"MIT","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","featured":true}]`) }) - opts := &ListLicensesOptions{Featured: Ptr(true), ListOptions: ListOptions{Page: 2, PerPage: 20}} + opts := &ListLicensesOptions{Featured: new(true), ListOptions: ListOptions{Page: 2, PerPage: 20}} ctx := t.Context() licenses, _, err := client.Licenses.List(ctx, opts) if err != nil { @@ -31,11 +31,11 @@ func TestLicensesService_List(t *testing.T) { } want := []*License{{ - Key: Ptr("mit"), - Name: Ptr("MIT"), - SPDXID: Ptr("MIT"), - URL: Ptr("https://api.github.com/licenses/mit"), - Featured: Ptr(true), + Key: new("mit"), + Name: new("MIT"), + SPDXID: new("MIT"), + URL: new("https://api.github.com/licenses/mit"), + Featured: new(true), }} if !cmp.Equal(licenses, want) { t.Errorf("Licenses.List returned %+v, want %+v", licenses, want) @@ -66,7 +66,7 @@ func TestLicensesService_Get(t *testing.T) { t.Errorf("Licenses.Get returned error: %v", err) } - want := &License{Key: Ptr("mit"), Name: Ptr("MIT")} + want := &License{Key: new("mit"), Name: new("MIT")} if !cmp.Equal(license, want) { t.Errorf("Licenses.Get returned %+v, want %+v", license, want) } diff --git a/github/markdown_test.go b/github/markdown_test.go index 37eda279592..78c1400b020 100644 --- a/github/markdown_test.go +++ b/github/markdown_test.go @@ -16,9 +16,9 @@ func TestMarkdownService_Markdown(t *testing.T) { client, mux, _ := setup(t) input := &markdownRenderRequest{ - Text: Ptr("# text #"), - Mode: Ptr("gfm"), - Context: Ptr("google/go-github"), + Text: new("# text #"), + Mode: new("gfm"), + Context: new("google/go-github"), } mux.HandleFunc("/markdown", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "POST") diff --git a/github/meta_test.go b/github/meta_test.go index 443f2e75fd1..2e17a5d3437 100644 --- a/github/meta_test.go +++ b/github/meta_test.go @@ -64,7 +64,7 @@ func TestMetaService_Get(t *testing.T) { }, }, - VerifiablePasswordAuthentication: Ptr(true), + VerifiablePasswordAuthentication: new(true), } if !cmp.Equal(want, meta) { t.Errorf("Get returned %+v, want %+v", meta, want) diff --git a/github/migrations_source_import_test.go b/github/migrations_source_import_test.go index ae1fcce69ef..ff57ec40ac2 100644 --- a/github/migrations_source_import_test.go +++ b/github/migrations_source_import_test.go @@ -18,10 +18,10 @@ func TestMigrationService_StartImport(t *testing.T) { client, mux, _ := setup(t) input := &Import{ - VCS: Ptr("git"), - VCSURL: Ptr("url"), - VCSUsername: Ptr("u"), - VCSPassword: Ptr("p"), + VCS: new("git"), + VCSURL: new("url"), + VCSUsername: new("u"), + VCSPassword: new("p"), } mux.HandleFunc("/repos/o/r/import", func(w http.ResponseWriter, r *http.Request) { @@ -36,7 +36,7 @@ func TestMigrationService_StartImport(t *testing.T) { if err != nil { t.Errorf("StartImport returned error: %v", err) } - want := &Import{Status: Ptr("importing")} + want := &Import{Status: new("importing")} if !cmp.Equal(got, want) { t.Errorf("StartImport = %+v, want %+v", got, want) } @@ -70,7 +70,7 @@ func TestMigrationService_ImportProgress(t *testing.T) { if err != nil { t.Errorf("ImportProgress returned error: %v", err) } - want := &Import{Status: Ptr("complete")} + want := &Import{Status: new("complete")} if !cmp.Equal(got, want) { t.Errorf("ImportProgress = %+v, want %+v", got, want) } @@ -95,10 +95,10 @@ func TestMigrationService_UpdateImport(t *testing.T) { client, mux, _ := setup(t) input := &Import{ - VCS: Ptr("git"), - VCSURL: Ptr("url"), - VCSUsername: Ptr("u"), - VCSPassword: Ptr("p"), + VCS: new("git"), + VCSURL: new("url"), + VCSUsername: new("u"), + VCSPassword: new("p"), } mux.HandleFunc("/repos/o/r/import", func(w http.ResponseWriter, r *http.Request) { @@ -113,7 +113,7 @@ func TestMigrationService_UpdateImport(t *testing.T) { if err != nil { t.Errorf("UpdateImport returned error: %v", err) } - want := &Import{Status: Ptr("importing")} + want := &Import{Status: new("importing")} if !cmp.Equal(got, want) { t.Errorf("UpdateImport = %+v, want %+v", got, want) } @@ -148,8 +148,8 @@ func TestMigrationService_CommitAuthors(t *testing.T) { t.Errorf("CommitAuthors returned error: %v", err) } want := []*SourceImportAuthor{ - {ID: Ptr(int64(1)), Name: Ptr("a")}, - {ID: Ptr(int64(2)), Name: Ptr("b")}, + {ID: new(int64(1)), Name: new("a")}, + {ID: new(int64(2)), Name: new("b")}, } if !cmp.Equal(got, want) { t.Errorf("CommitAuthors = %+v, want %+v", got, want) @@ -174,7 +174,7 @@ func TestMigrationService_MapCommitAuthor(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - input := &SourceImportAuthor{Name: Ptr("n"), Email: Ptr("e")} + input := &SourceImportAuthor{Name: new("n"), Email: new("e")} mux.HandleFunc("/repos/o/r/import/authors/1", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "PATCH") @@ -187,7 +187,7 @@ func TestMigrationService_MapCommitAuthor(t *testing.T) { if err != nil { t.Errorf("MapCommitAuthor returned error: %v", err) } - want := &SourceImportAuthor{ID: Ptr(int64(1))} + want := &SourceImportAuthor{ID: new(int64(1))} if !cmp.Equal(got, want) { t.Errorf("MapCommitAuthor = %+v, want %+v", got, want) } @@ -211,7 +211,7 @@ func TestMigrationService_SetLFSPreference(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - input := &Import{UseLFS: Ptr("opt_in")} + input := &Import{UseLFS: new("opt_in")} mux.HandleFunc("/repos/o/r/import/lfs", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "PATCH") @@ -225,7 +225,7 @@ func TestMigrationService_SetLFSPreference(t *testing.T) { if err != nil { t.Errorf("SetLFSPreference returned error: %v", err) } - want := &Import{Status: Ptr("importing")} + want := &Import{Status: new("importing")} if !cmp.Equal(got, want) { t.Errorf("SetLFSPreference = %+v, want %+v", got, want) } @@ -260,8 +260,8 @@ func TestMigrationService_LargeFiles(t *testing.T) { t.Errorf("LargeFiles returned error: %v", err) } want := []*LargeFile{ - {OID: Ptr("a")}, - {OID: Ptr("b")}, + {OID: new("a")}, + {OID: new("b")}, } if !cmp.Equal(got, want) { t.Errorf("LargeFiles = %+v, want %+v", got, want) diff --git a/github/migrations_test.go b/github/migrations_test.go index 73d34ec46f2..894e512fa94 100644 --- a/github/migrations_test.go +++ b/github/migrations_test.go @@ -257,20 +257,20 @@ var migrationJSON = []byte(`{ }`) var wantMigration = &Migration{ - ID: Ptr(int64(79)), - GUID: Ptr("0b989ba4-242f-11e5-81e1-c7b6966d2516"), - State: Ptr("pending"), - LockRepositories: Ptr(true), - ExcludeAttachments: Ptr(false), - URL: Ptr("https://api.github.com/orgs/octo-org/migrations/79"), - CreatedAt: Ptr("2015-07-06T15:33:38-07:00"), - UpdatedAt: Ptr("2015-07-06T15:33:38-07:00"), + ID: new(int64(79)), + GUID: new("0b989ba4-242f-11e5-81e1-c7b6966d2516"), + State: new("pending"), + LockRepositories: new(true), + ExcludeAttachments: new(false), + URL: new("https://api.github.com/orgs/octo-org/migrations/79"), + CreatedAt: new("2015-07-06T15:33:38-07:00"), + UpdatedAt: new("2015-07-06T15:33:38-07:00"), Repositories: []*Repository{ { - ID: Ptr(int64(1296269)), - Name: Ptr("Hello-World"), - FullName: Ptr("octocat/Hello-World"), - Description: Ptr("This your first repo!"), + ID: new(int64(1296269)), + Name: new("Hello-World"), + FullName: new("octocat/Hello-World"), + Description: new("This your first repo!"), }, }, } diff --git a/github/migrations_user_test.go b/github/migrations_user_test.go index 7ffdc0935ea..7ebc30cff61 100644 --- a/github/migrations_user_test.go +++ b/github/migrations_user_test.go @@ -231,20 +231,20 @@ var userMigrationJSON = []byte(`{ }`) var wantUserMigration = &UserMigration{ - ID: Ptr(int64(79)), - GUID: Ptr("0b989ba4-242f-11e5-81e1-c7b6966d2516"), - State: Ptr("pending"), - LockRepositories: Ptr(true), - ExcludeAttachments: Ptr(false), - URL: Ptr("https://api.github.com/orgs/octo-org/migrations/79"), - CreatedAt: Ptr("2015-07-06T15:33:38-07:00"), - UpdatedAt: Ptr("2015-07-06T15:33:38-07:00"), + ID: new(int64(79)), + GUID: new("0b989ba4-242f-11e5-81e1-c7b6966d2516"), + State: new("pending"), + LockRepositories: new(true), + ExcludeAttachments: new(false), + URL: new("https://api.github.com/orgs/octo-org/migrations/79"), + CreatedAt: new("2015-07-06T15:33:38-07:00"), + UpdatedAt: new("2015-07-06T15:33:38-07:00"), Repositories: []*Repository{ { - ID: Ptr(int64(1296269)), - Name: Ptr("Hello-World"), - FullName: Ptr("octocat/Hello-World"), - Description: Ptr("This your first repo!"), + ID: new(int64(1296269)), + Name: new("Hello-World"), + FullName: new("octocat/Hello-World"), + Description: new("This your first repo!"), }, }, } diff --git a/github/orgs_actions_allowed_test.go b/github/orgs_actions_allowed_test.go index 4eb5e9496ed..a4de8ebaa73 100644 --- a/github/orgs_actions_allowed_test.go +++ b/github/orgs_actions_allowed_test.go @@ -27,7 +27,7 @@ func TestOrganizationsService_GetActionsAllowed(t *testing.T) { if err != nil { t.Errorf("Organizations.GetActionsAllowed returned error: %v", err) } - want := &ActionsAllowed{GithubOwnedAllowed: Ptr(true), VerifiedAllowed: Ptr(false), PatternsAllowed: []string{"a/b"}} + want := &ActionsAllowed{GithubOwnedAllowed: new(true), VerifiedAllowed: new(false), PatternsAllowed: []string{"a/b"}} if !cmp.Equal(org, want) { t.Errorf("Organizations.GetActionsAllowed returned %+v, want %+v", org, want) } @@ -51,7 +51,7 @@ func TestOrganizationsService_UpdateActionsAllowed(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - input := &ActionsAllowed{GithubOwnedAllowed: Ptr(true), VerifiedAllowed: Ptr(false), PatternsAllowed: []string{"a/b"}} + input := &ActionsAllowed{GithubOwnedAllowed: new(true), VerifiedAllowed: new(false), PatternsAllowed: []string{"a/b"}} mux.HandleFunc("/orgs/o/actions/permissions/selected-actions", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "PUT") @@ -65,7 +65,7 @@ func TestOrganizationsService_UpdateActionsAllowed(t *testing.T) { t.Errorf("Organizations.UpdateActionsAllowed returned error: %v", err) } - want := &ActionsAllowed{GithubOwnedAllowed: Ptr(true), VerifiedAllowed: Ptr(false), PatternsAllowed: []string{"a/b"}} + want := &ActionsAllowed{GithubOwnedAllowed: new(true), VerifiedAllowed: new(false), PatternsAllowed: []string{"a/b"}} if !cmp.Equal(org, want) { t.Errorf("Organizations.UpdateActionsAllowed returned %+v, want %+v", org, want) } diff --git a/github/orgs_actions_permissions_test.go b/github/orgs_actions_permissions_test.go index c97f783fe35..bbb2113f10f 100644 --- a/github/orgs_actions_permissions_test.go +++ b/github/orgs_actions_permissions_test.go @@ -27,7 +27,7 @@ func TestOrganizationsService_GetActionsPermissions(t *testing.T) { if err != nil { t.Errorf("Organizations.GetActionsPermissions returned error: %v", err) } - want := &ActionsPermissions{EnabledRepositories: Ptr("all"), AllowedActions: Ptr("all")} + want := &ActionsPermissions{EnabledRepositories: new("all"), AllowedActions: new("all")} if !cmp.Equal(org, want) { t.Errorf("Organizations.GetActionsPermissions returned %+v, want %+v", org, want) } @@ -51,7 +51,7 @@ func TestOrganizationsService_UpdateActionsPermissions(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - input := &ActionsPermissions{EnabledRepositories: Ptr("all"), AllowedActions: Ptr("selected")} + input := &ActionsPermissions{EnabledRepositories: new("all"), AllowedActions: new("selected")} mux.HandleFunc("/orgs/o/actions/permissions", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "PUT") @@ -65,7 +65,7 @@ func TestOrganizationsService_UpdateActionsPermissions(t *testing.T) { t.Errorf("Organizations.UpdateActionsPermissions returned error: %v", err) } - want := &ActionsPermissions{EnabledRepositories: Ptr("all"), AllowedActions: Ptr("selected")} + want := &ActionsPermissions{EnabledRepositories: new("all"), AllowedActions: new("selected")} if !cmp.Equal(org, want) { t.Errorf("Organizations.UpdateActionsPermissions returned %+v, want %+v", org, want) } diff --git a/github/orgs_artifacts_test.go b/github/orgs_artifacts_test.go index 8ebfbc3df08..71a640a1759 100644 --- a/github/orgs_artifacts_test.go +++ b/github/orgs_artifacts_test.go @@ -20,12 +20,12 @@ func TestOrganizationsService_CreateArtifactDeploymentRecord(t *testing.T) { input := CreateArtifactDeploymentRequest{ Name: "test-n", Digest: "sha256:123", - Version: Ptr("v1.0.0"), + Version: new("v1.0.0"), Status: "deployed", LogicalEnvironment: "prod", DeploymentName: "dep-1", RuntimeRisks: []DeploymentRuntimeRisk{DeploymentRuntimeRiskCriticalResource, DeploymentRuntimeRiskInternetExposed}, - GithubRepository: Ptr("octo-org/octo-repo"), + GithubRepository: new("octo-org/octo-repo"), Tags: map[string]string{ "data-access": "sensitive", }, @@ -44,8 +44,8 @@ func TestOrganizationsService_CreateArtifactDeploymentRecord(t *testing.T) { } want := &ArtifactDeploymentResponse{ - TotalCount: Ptr(1), - DeploymentRecords: []*ArtifactDeploymentRecord{{ID: Ptr(int64(1))}}, + TotalCount: new(1), + DeploymentRecords: []*ArtifactDeploymentRecord{{ID: new(int64(1))}}, } if !cmp.Equal(got, want) { @@ -73,13 +73,13 @@ func TestOrganizationsService_SetClusterDeploymentRecords(t *testing.T) { input := ClusterDeploymentRecordsRequest{ LogicalEnvironment: "prod", - PhysicalEnvironment: Ptr("pacific-east"), + PhysicalEnvironment: new("pacific-east"), Deployments: []*ClusterArtifactDeployment{ { Name: "awesome-image", Digest: "sha256:abc", DeploymentName: "dep-1", - Version: Ptr("v2.0"), + Version: new("v2.0"), Status: "deployed", }, }, @@ -98,8 +98,8 @@ func TestOrganizationsService_SetClusterDeploymentRecords(t *testing.T) { } want := &ArtifactDeploymentResponse{ - TotalCount: Ptr(1), - DeploymentRecords: []*ArtifactDeploymentRecord{{ID: Ptr(int64(2))}}, + TotalCount: new(1), + DeploymentRecords: []*ArtifactDeploymentRecord{{ID: new(int64(2))}}, } if !cmp.Equal(got, want) { t.Errorf("SetClusterDeploymentRecords returned %+v, want %+v", got, want) @@ -127,11 +127,11 @@ func TestOrganizationsService_CreateArtifactStorageRecord(t *testing.T) { input := CreateArtifactStorageRequest{ Name: "libfoo", Digest: "sha256:123", - Version: Ptr("v1.2.3"), - Path: Ptr("target/libs"), - GithubRepository: Ptr("org/repo"), + Version: new("v1.2.3"), + Path: new("target/libs"), + GithubRepository: new("org/repo"), RegistryURL: "https://reg.example.com", - Status: Ptr("active"), + Status: new("active"), } mux.HandleFunc("/orgs/o/artifacts/metadata/storage-record", func(w http.ResponseWriter, r *http.Request) { @@ -147,8 +147,8 @@ func TestOrganizationsService_CreateArtifactStorageRecord(t *testing.T) { } want := &ArtifactStorageResponse{ - TotalCount: Ptr(1), - StorageRecords: []*ArtifactStorageRecord{{Name: Ptr("libfoo")}}, + TotalCount: new(1), + StorageRecords: []*ArtifactStorageRecord{{Name: new("libfoo")}}, } if !cmp.Equal(got, want) { @@ -187,9 +187,9 @@ func TestOrganizationsService_ListArtifactDeploymentRecords(t *testing.T) { } want := &ArtifactDeploymentResponse{ - TotalCount: Ptr(1), + TotalCount: new(1), DeploymentRecords: []*ArtifactDeploymentRecord{ - {ID: Ptr(int64(1)), RuntimeRisks: []DeploymentRuntimeRisk{DeploymentRuntimeRiskSensitiveData}}, + {ID: new(int64(1)), RuntimeRisks: []DeploymentRuntimeRisk{DeploymentRuntimeRiskSensitiveData}}, }, } if !cmp.Equal(got, want) { @@ -228,8 +228,8 @@ func TestOrganizationsService_ListArtifactStorageRecords(t *testing.T) { } want := &ArtifactStorageResponse{ - TotalCount: Ptr(1), - StorageRecords: []*ArtifactStorageRecord{{Name: Ptr("libfoo")}}, + TotalCount: new(1), + StorageRecords: []*ArtifactStorageRecord{{Name: new("libfoo")}}, } if !cmp.Equal(got, want) { t.Errorf("ListArtifactStorageRecords returned %+v, want %+v", got, want) diff --git a/github/orgs_audit_log.go b/github/orgs_audit_log.go index 65e65e893b0..db87e2b65b3 100644 --- a/github/orgs_audit_log.go +++ b/github/orgs_audit_log.go @@ -132,7 +132,7 @@ func unmarshalStringOrArray(raw json.RawMessage) (*string, error) { if len(ss) == 0 { return nil, nil } - return Ptr(strings.Join(ss, ", ")), nil + return new(strings.Join(ss, ", ")), nil } // unmarshalIntOrArray decodes a JSON value that is either a plain integer or an array of integers. diff --git a/github/orgs_audit_log_test.go b/github/orgs_audit_log_test.go index 67833e90ccd..cd8a1657d1b 100644 --- a/github/orgs_audit_log_test.go +++ b/github/orgs_audit_log_test.go @@ -82,9 +82,9 @@ func TestOrganizationService_GetAuditLog(t *testing.T) { }) ctx := t.Context() getOpts := GetAuditLogOptions{ - Include: Ptr("all"), - Phrase: Ptr("action:workflows"), - Order: Ptr("asc"), + Include: new("all"), + Phrase: new("action:workflows"), + Order: new("asc"), } auditEntries, _, err := client.Organizations.GetAuditLog(ctx, "o", &getOpts) @@ -96,18 +96,18 @@ func TestOrganizationService_GetAuditLog(t *testing.T) { want := []*AuditEntry{ { Timestamp: &Timestamp{timestamp}, - DocumentID: Ptr("beeZYapIUe-wKg5-beadb33"), - Action: Ptr("workflows.completed_workflow_run"), - Actor: Ptr("testactor"), + DocumentID: new("beeZYapIUe-wKg5-beadb33"), + Action: new("workflows.completed_workflow_run"), + Actor: new("testactor"), ActorLocation: &ActorLocation{ - CountryCode: Ptr("US"), + CountryCode: new("US"), }, CreatedAt: &Timestamp{timestamp}, - HashedToken: Ptr("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="), - Org: Ptr("o"), - OrgID: Ptr(int64(1)), - TokenID: Ptr(int64(1)), - TokenScopes: Ptr("gist,repo:read"), + HashedToken: new("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="), + Org: new("o"), + OrgID: new(int64(1)), + TokenID: new(int64(1)), + TokenScopes: new("gist,repo:read"), AdditionalFields: map[string]any{ "actor_ip": "10.0.0.1", "active": true, @@ -172,21 +172,21 @@ func TestAuditEntry_MarshalJSON(t *testing.T) { testJSONMarshal(t, &AuditEntry{}, "{}") u := AuditEntry{ - Action: Ptr("a"), - Actor: Ptr("ac"), - ActorLocation: &ActorLocation{CountryCode: Ptr("alcc")}, - Business: Ptr("b"), + Action: new("a"), + Actor: new("ac"), + ActorLocation: &ActorLocation{CountryCode: new("alcc")}, + Business: new("b"), CreatedAt: &Timestamp{referenceTime}, - DocumentID: Ptr("did"), - ExternalIdentityNameID: Ptr("ein"), - ExternalIdentityUsername: Ptr("eiu"), - HashedToken: Ptr("ht"), - Org: Ptr("o"), - OrgID: Ptr(int64(1)), + DocumentID: new("did"), + ExternalIdentityNameID: new("ein"), + ExternalIdentityUsername: new("eiu"), + HashedToken: new("ht"), + Org: new("o"), + OrgID: new(int64(1)), Timestamp: &Timestamp{referenceTime}, - TokenID: Ptr(int64(1)), - TokenScopes: Ptr("ts"), - User: Ptr("u"), + TokenID: new(int64(1)), + TokenScopes: new("ts"), + User: new("u"), Data: map[string]any{ "old_name": "on", "old_login": "ol", @@ -381,42 +381,42 @@ func TestAuditEntry_UnmarshalJSON(t *testing.T) { { name: "org is scalar", payload: `{"action":"test","org":"myorg","org_id":42}`, - want: &AuditEntry{Action: Ptr("test"), Org: Ptr("myorg"), OrgID: Ptr(int64(42))}, + want: &AuditEntry{Action: new("test"), Org: new("myorg"), OrgID: new(int64(42))}, }, { name: "org is single element array", payload: `{"action":"test","org":["myorg"],"org_id":[42]}`, - want: &AuditEntry{Action: Ptr("test"), Org: Ptr("myorg"), OrgID: Ptr(int64(42))}, + want: &AuditEntry{Action: new("test"), Org: new("myorg"), OrgID: new(int64(42))}, }, { name: "org is multi-element array", payload: `{"action":"test","org":["org1","org2","org3"],"org_id":[1,2,3]}`, - want: &AuditEntry{Action: Ptr("test"), Org: Ptr("org1, org2, org3"), OrgID: Ptr(int64(1))}, + want: &AuditEntry{Action: new("test"), Org: new("org1, org2, org3"), OrgID: new(int64(1))}, }, { name: "org_id is scalar", payload: `{"action":"test","org_id":42}`, - want: &AuditEntry{Action: Ptr("test"), OrgID: Ptr(int64(42))}, + want: &AuditEntry{Action: new("test"), OrgID: new(int64(42))}, }, { name: "org_id is array", payload: `{"action":"test","org_id":[42,43,44]}`, - want: &AuditEntry{Action: Ptr("test"), OrgID: Ptr(int64(42))}, // first element + want: &AuditEntry{Action: new("test"), OrgID: new(int64(42))}, // first element }, { name: "org is empty array", payload: `{"action":"test","org":[]}`, - want: &AuditEntry{Action: Ptr("test"), AdditionalFields: map[string]any{"org": []any{}}}, + want: &AuditEntry{Action: new("test"), AdditionalFields: map[string]any{"org": []any{}}}, }, { name: "org_id is empty array", payload: `{"action":"test","org_id":[]}`, - want: &AuditEntry{Action: Ptr("test"), AdditionalFields: map[string]any{"org_id": []any{}}}, + want: &AuditEntry{Action: new("test"), AdditionalFields: map[string]any{"org_id": []any{}}}, }, { name: "org and org_id are null", payload: `{"action":"test","org":null,"org_id":null}`, - want: &AuditEntry{Action: Ptr("test")}, + want: &AuditEntry{Action: new("test")}, }, } diff --git a/github/orgs_codesecurity_configurations_test.go b/github/orgs_codesecurity_configurations_test.go index 15f845aac41..a425bd25bde 100644 --- a/github/orgs_codesecurity_configurations_test.go +++ b/github/orgs_codesecurity_configurations_test.go @@ -43,8 +43,8 @@ func TestOrganizationsService_ListCodeSecurityConfigurations(t *testing.T) { } want := []*CodeSecurityConfiguration{ - {ID: Ptr(int64(1)), Name: "config1", Description: "desc1", CodeScanningDefaultSetup: Ptr("enabled")}, - {ID: Ptr(int64(2)), Name: "config2", Description: "desc2", PrivateVulnerabilityReporting: Ptr("enabled")}, + {ID: new(int64(1)), Name: "config1", Description: "desc1", CodeScanningDefaultSetup: new("enabled")}, + {ID: new(int64(2)), Name: "config2", Description: "desc2", PrivateVulnerabilityReporting: new("enabled")}, } if !cmp.Equal(configurations, want) { t.Errorf("Organizations.ListCodeSecurityConfigurations returned %+v, want %+v", configurations, want) @@ -83,7 +83,7 @@ func TestOrganizationsService_GetCodeSecurityConfiguration(t *testing.T) { t.Errorf("Organizations.GetCodeSecurityConfiguration returned error: %v", err) } - want := &CodeSecurityConfiguration{ID: Ptr(int64(1)), Name: "config1", Description: "desc1", CodeScanningDefaultSetup: Ptr("enabled")} + want := &CodeSecurityConfiguration{ID: new(int64(1)), Name: "config1", Description: "desc1", CodeScanningDefaultSetup: new("enabled")} if !cmp.Equal(configuration, want) { t.Errorf("Organizations.GetCodeSecurityConfiguration returned %+v, want %+v", configuration, want) } @@ -111,7 +111,7 @@ func TestOrganizationsService_CreateCodeSecurityConfiguration(t *testing.T) { input := CodeSecurityConfiguration{ Name: "config1", Description: "desc1", - CodeScanningDefaultSetup: Ptr("enabled"), + CodeScanningDefaultSetup: new("enabled"), } mux.HandleFunc("/orgs/o/code-security/configurations", func(w http.ResponseWriter, r *http.Request) { @@ -129,7 +129,7 @@ func TestOrganizationsService_CreateCodeSecurityConfiguration(t *testing.T) { t.Errorf("Organizations.CreateCodeSecurityConfiguration returned error: %v", err) } - want := &CodeSecurityConfiguration{ID: Ptr(int64(1)), Name: "config1", Description: "desc1", CodeScanningDefaultSetup: Ptr("enabled")} + want := &CodeSecurityConfiguration{ID: new(int64(1)), Name: "config1", Description: "desc1", CodeScanningDefaultSetup: new("enabled")} if !cmp.Equal(configuration, want) { t.Errorf("Organizations.CreateCodeSecurityConfiguration returned %+v, want %+v", configuration, want) } @@ -157,10 +157,10 @@ func TestOrganizationsService_CreateCodeSecurityConfigurationWithDelegatedBypass input := CodeSecurityConfiguration{ Name: "config1", Description: "desc1", - SecretProtection: Ptr("enabled"), // required to configure bypass - SecretScanning: Ptr("enabled"), // required to configure bypass - SecretScanningPushProtection: Ptr("enabled"), // required to configure bypass - SecretScanningDelegatedBypass: Ptr("enabled"), + SecretProtection: new("enabled"), // required to configure bypass + SecretScanning: new("enabled"), // required to configure bypass + SecretScanningPushProtection: new("enabled"), // required to configure bypass + SecretScanningDelegatedBypass: new("enabled"), SecretScanningDelegatedBypassOptions: &SecretScanningDelegatedBypassOptions{ Reviewers: []*BypassReviewer{ { @@ -208,22 +208,22 @@ func TestOrganizationsService_CreateCodeSecurityConfigurationWithDelegatedBypass } want := &CodeSecurityConfiguration{ - ID: Ptr(int64(123)), + ID: new(int64(123)), Name: "config1", Description: "desc1", - SecretProtection: Ptr("enabled"), - SecretScanning: Ptr("enabled"), - SecretScanningPushProtection: Ptr("enabled"), - SecretScanningDelegatedBypass: Ptr("enabled"), + SecretProtection: new("enabled"), + SecretScanning: new("enabled"), + SecretScanningPushProtection: new("enabled"), + SecretScanningDelegatedBypass: new("enabled"), SecretScanningDelegatedBypassOptions: &SecretScanningDelegatedBypassOptions{ Reviewers: []*BypassReviewer{ { - SecurityConfigurationID: Ptr(int64(123)), + SecurityConfigurationID: new(int64(123)), ReviewerType: "TEAM", ReviewerID: 456, }, { - SecurityConfigurationID: Ptr(int64(123)), + SecurityConfigurationID: new(int64(123)), ReviewerType: "ROLE", ReviewerID: 789, }, @@ -284,8 +284,8 @@ func TestOrganizationsService_ListDefaultCodeSecurityConfigurations(t *testing.T } want := []*CodeSecurityConfigurationWithDefaultForNewRepos{ - {DefaultForNewRepos: Ptr("public"), Configuration: &CodeSecurityConfiguration{ID: Ptr(int64(1)), Name: "config1", Description: "desc1", CodeScanningDefaultSetup: Ptr("enabled")}}, - {DefaultForNewRepos: Ptr("private_and_internal"), Configuration: &CodeSecurityConfiguration{ID: Ptr(int64(2)), Name: "config2", Description: "desc2", PrivateVulnerabilityReporting: Ptr("enabled")}}, + {DefaultForNewRepos: new("public"), Configuration: &CodeSecurityConfiguration{ID: new(int64(1)), Name: "config1", Description: "desc1", CodeScanningDefaultSetup: new("enabled")}}, + {DefaultForNewRepos: new("private_and_internal"), Configuration: &CodeSecurityConfiguration{ID: new(int64(2)), Name: "config2", Description: "desc2", PrivateVulnerabilityReporting: new("enabled")}}, } if !cmp.Equal(configurations, want) { t.Errorf("Organizations.ListDefaultCodeSecurityConfigurations returned %+v, want %+v", configurations, want) @@ -346,7 +346,7 @@ func TestOrganizationsService_UpdateCodeSecurityConfiguration(t *testing.T) { input := CodeSecurityConfiguration{ Name: "config1", Description: "desc1", - CodeScanningDefaultSetup: Ptr("enabled"), + CodeScanningDefaultSetup: new("enabled"), } mux.HandleFunc("/orgs/o/code-security/configurations/1", func(w http.ResponseWriter, r *http.Request) { @@ -364,7 +364,7 @@ func TestOrganizationsService_UpdateCodeSecurityConfiguration(t *testing.T) { t.Errorf("Organizations.UpdateCodeSecurityConfiguration returned error: %v", err) } - want := &CodeSecurityConfiguration{ID: Ptr(int64(1)), Name: "config1", Description: "desc1", CodeScanningDefaultSetup: Ptr("enabled")} + want := &CodeSecurityConfiguration{ID: new(int64(1)), Name: "config1", Description: "desc1", CodeScanningDefaultSetup: new("enabled")} if !cmp.Equal(configuration, want) { t.Errorf("Organizations.UpdateCodeSecurityConfiguration returned %+v, want %+v", configuration, want) } @@ -485,9 +485,9 @@ func TestOrganizationsService_SetDefaultCodeSecurityConfiguration(t *testing.T) t.Errorf("Organizations.SetDefaultCodeSecurityConfiguration returned status %v, want %v", resp.StatusCode, wantStatus) } want := &CodeSecurityConfigurationWithDefaultForNewRepos{ - DefaultForNewRepos: Ptr("all"), + DefaultForNewRepos: new("all"), Configuration: &CodeSecurityConfiguration{ - ID: Ptr(int64(1)), Name: "config1", Description: "desc1", CodeScanningDefaultSetup: Ptr("enabled"), + ID: new(int64(1)), Name: "config1", Description: "desc1", CodeScanningDefaultSetup: new("enabled"), }, } if !cmp.Equal(got, want) { @@ -541,8 +541,8 @@ func TestOrganizationsService_ListCodeSecurityConfigurationRepositories(t *testi t.Errorf("Organizations.ListCodeSecurityConfigurationRepositories returned error: %v", err) } want := []*RepositoryAttachment{ - {Status: Ptr("attached"), Repository: &Repository{ID: Ptr(int64(8)), Name: Ptr("repo8")}}, - {Status: Ptr("attached"), Repository: &Repository{ID: Ptr(int64(42)), Name: Ptr("repo42")}}, + {Status: new("attached"), Repository: &Repository{ID: new(int64(8)), Name: new("repo8")}}, + {Status: new("attached"), Repository: &Repository{ID: new(int64(42)), Name: new("repo42")}}, } if !cmp.Equal(attachments, want) { t.Errorf("Organizations.ListCodeSecurityConfigurationRepositories returned %+v, want %+v", attachments, want) @@ -585,9 +585,9 @@ func TestOrganizationsService_GetCodeSecurityConfigurationForRepository(t *testi if err != nil { t.Errorf("Organizations.GetCodeSecurityConfigurationForRepository returned error: %v", err) } - c := &CodeSecurityConfiguration{ID: Ptr(int64(42)), Name: "config42", Description: "desc1", CodeScanningDefaultSetup: Ptr("enabled")} + c := &CodeSecurityConfiguration{ID: new(int64(42)), Name: "config42", Description: "desc1", CodeScanningDefaultSetup: new("enabled")} want := &RepositoryCodeSecurityConfiguration{ - State: Ptr("attached"), + State: new("attached"), Configuration: c, } if !cmp.Equal(rc, want) { diff --git a/github/orgs_credential_authorizations_test.go b/github/orgs_credential_authorizations_test.go index 8770c77c8ec..46e10d5ed0a 100644 --- a/github/orgs_credential_authorizations_test.go +++ b/github/orgs_credential_authorizations_test.go @@ -45,12 +45,12 @@ func TestOrganizationsService_ListCredentialAuthorizations(t *testing.T) { want := []*CredentialAuthorization{ { - Login: Ptr("l"), - CredentialID: Ptr(int64(1)), - CredentialType: Ptr("t"), + Login: new("l"), + CredentialID: new(int64(1)), + CredentialType: new("t"), CredentialAuthorizedAt: refTimestamp(1136178000), CredentialAccessedAt: refTimestamp(1136178001), - AuthorizedCredentialID: Ptr(int64(1)), + AuthorizedCredentialID: new(int64(1)), }, } if !cmp.Equal(creds, want) { diff --git a/github/orgs_custom_repository_roles_test.go b/github/orgs_custom_repository_roles_test.go index 4a980a4809e..47bc439a952 100644 --- a/github/orgs_custom_repository_roles_test.go +++ b/github/orgs_custom_repository_roles_test.go @@ -51,24 +51,24 @@ func TestOrganizationsService_ListCustomRepoRoles(t *testing.T) { } want := &OrganizationCustomRepoRoles{ - TotalCount: Ptr(1), + TotalCount: new(1), CustomRepoRoles: []*CustomRepoRoles{ { - ID: Ptr(int64(1)), - Name: Ptr("Developer"), - BaseRole: Ptr("write"), + ID: new(int64(1)), + Name: new("Developer"), + BaseRole: new("write"), Permissions: []string{"delete_alerts_code_scanning"}, Org: &Organization{ - Login: Ptr("l"), - ID: Ptr(int64(1)), - NodeID: Ptr("n"), - AvatarURL: Ptr("a"), - HTMLURL: Ptr("h"), - Name: Ptr("n"), - Company: Ptr("c"), - Blog: Ptr("b"), - Location: Ptr("l"), - Email: Ptr("e"), + Login: new("l"), + ID: new(int64(1)), + NodeID: new("n"), + AvatarURL: new("a"), + HTMLURL: new("h"), + Name: new("n"), + Company: new("c"), + Blog: new("b"), + Location: new("l"), + Email: new("e"), }, CreatedAt: refTimestamp(1136178000), UpdatedAt: refTimestamp(1136178001), @@ -129,21 +129,21 @@ func TestOrganizationsService_GetCustomRepoRole(t *testing.T) { } want := &CustomRepoRoles{ - ID: Ptr(int64(1)), - Name: Ptr("Developer"), - BaseRole: Ptr("write"), + ID: new(int64(1)), + Name: new("Developer"), + BaseRole: new("write"), Permissions: []string{"delete_alerts_code_scanning"}, Org: &Organization{ - Login: Ptr("l"), - ID: Ptr(int64(1)), - NodeID: Ptr("n"), - AvatarURL: Ptr("a"), - HTMLURL: Ptr("h"), - Name: Ptr("n"), - Company: Ptr("c"), - Blog: Ptr("b"), - Location: Ptr("l"), - Email: Ptr("e"), + Login: new("l"), + ID: new(int64(1)), + NodeID: new("n"), + AvatarURL: new("a"), + HTMLURL: new("h"), + Name: new("n"), + Company: new("c"), + Blog: new("b"), + Location: new("l"), + Email: new("e"), }, CreatedAt: refTimestamp(1136178000), UpdatedAt: refTimestamp(1136178001), @@ -185,7 +185,7 @@ func TestOrganizationsService_CreateCustomRepoRole(t *testing.T) { body := CreateCustomRepoRoleRequest{ Name: "Labeler", - Description: Ptr("A role for issue and PR labelers"), + Description: new("A role for issue and PR labelers"), BaseRole: "read", Permissions: []string{"add_label"}, } @@ -194,7 +194,7 @@ func TestOrganizationsService_CreateCustomRepoRole(t *testing.T) { t.Errorf("Organizations.CreateCustomRepoRole returned error: %v", err) } - want := &CustomRepoRoles{ID: Ptr(int64(8030)), Name: Ptr("Labeler"), BaseRole: Ptr("read"), Permissions: []string{"add_label"}, Description: Ptr("A role for issue and PR labelers")} + want := &CustomRepoRoles{ID: new(int64(8030)), Name: new("Labeler"), BaseRole: new("read"), Permissions: []string{"add_label"}, Description: new("A role for issue and PR labelers")} if !cmp.Equal(apps, want) { t.Errorf("Organizations.CreateCustomRepoRole returned %+v, want %+v", apps, want) @@ -227,15 +227,15 @@ func TestOrganizationsService_UpdateCustomRepoRole(t *testing.T) { ctx := t.Context() body := UpdateCustomRepoRoleRequest{ - Name: Ptr("Updated Name"), - Description: Ptr("Updated Description"), + Name: new("Updated Name"), + Description: new("Updated Description"), } apps, _, err := client.Organizations.UpdateCustomRepoRole(ctx, "o", 8030, body) if err != nil { t.Errorf("Organizations.UpdateCustomRepoRole returned error: %v", err) } - want := &CustomRepoRoles{ID: Ptr(int64(8030)), Name: Ptr("Updated Name"), BaseRole: Ptr("read"), Permissions: []string{"add_label"}, Description: Ptr("Updated Description")} + want := &CustomRepoRoles{ID: new(int64(8030)), Name: new("Updated Name"), BaseRole: new("read"), Permissions: []string{"add_label"}, Description: new("Updated Description")} if !cmp.Equal(apps, want) { t.Errorf("Organizations.UpdateCustomRepoRole returned %+v, want %+v", apps, want) diff --git a/github/orgs_hooks_configuration_test.go b/github/orgs_hooks_configuration_test.go index db31cf9df25..57958834659 100644 --- a/github/orgs_hooks_configuration_test.go +++ b/github/orgs_hooks_configuration_test.go @@ -29,10 +29,10 @@ func TestOrganizationsService_GetHookConfiguration(t *testing.T) { } want := &HookConfig{ - ContentType: Ptr("json"), - InsecureSSL: Ptr("0"), - Secret: Ptr("********"), - URL: Ptr("https://example.com/webhook"), + ContentType: new("json"), + InsecureSSL: new("0"), + Secret: new("********"), + URL: new("https://example.com/webhook"), } if !cmp.Equal(config, want) { t.Errorf("Organizations.GetHookConfiguration returned %+v, want %+v", config, want) @@ -81,10 +81,10 @@ func TestOrganizationsService_UpdateHookConfiguration(t *testing.T) { } want := &HookConfig{ - ContentType: Ptr("json"), - InsecureSSL: Ptr("0"), - Secret: Ptr("********"), - URL: Ptr("https://example.com/webhook"), + ContentType: new("json"), + InsecureSSL: new("0"), + Secret: new("********"), + URL: new("https://example.com/webhook"), } if !cmp.Equal(config, want) { t.Errorf("Organizations.UpdateHookConfiguration returned %+v, want %+v", config, want) diff --git a/github/orgs_hooks_deliveries_test.go b/github/orgs_hooks_deliveries_test.go index 66c85ff905c..3f24fc362a5 100644 --- a/github/orgs_hooks_deliveries_test.go +++ b/github/orgs_hooks_deliveries_test.go @@ -31,7 +31,7 @@ func TestOrganizationsService_ListHookDeliveries(t *testing.T) { t.Errorf("Organizations.ListHookDeliveries returned error: %v", err) } - want := []*HookDelivery{{ID: Ptr(int64(1))}, {ID: Ptr(int64(2))}} + want := []*HookDelivery{{ID: new(int64(1))}, {ID: new(int64(2))}} if d := cmp.Diff(hooks, want); d != "" { t.Errorf("Organizations.ListHooks want (-), got (+):\n%v", d) } @@ -75,7 +75,7 @@ func TestOrganizationsService_GetHookDelivery(t *testing.T) { t.Errorf("Organizations.GetHookDelivery returned error: %v", err) } - want := &HookDelivery{ID: Ptr(int64(1))} + want := &HookDelivery{ID: new(int64(1))} if !cmp.Equal(hook, want) { t.Errorf("Organizations.GetHookDelivery returned %+v, want %+v", hook, want) } @@ -119,7 +119,7 @@ func TestOrganizationsService_RedeliverHookDelivery(t *testing.T) { t.Errorf("Organizations.RedeliverHookDelivery returned error: %v", err) } - want := &HookDelivery{ID: Ptr(int64(1))} + want := &HookDelivery{ID: new(int64(1))} if !cmp.Equal(hook, want) { t.Errorf("Organizations.RedeliverHookDelivery returned %+v, want %+v", hook, want) } diff --git a/github/orgs_hooks_test.go b/github/orgs_hooks_test.go index 40cdae6096b..ddc2dbc2e7a 100644 --- a/github/orgs_hooks_test.go +++ b/github/orgs_hooks_test.go @@ -31,7 +31,7 @@ func TestOrganizationsService_ListHooks(t *testing.T) { t.Errorf("Organizations.ListHooks returned error: %v", err) } - want := []*Hook{{ID: Ptr(int64(1))}, {ID: Ptr(int64(2))}} + want := []*Hook{{ID: new(int64(1))}, {ID: new(int64(2))}} if !cmp.Equal(hooks, want) { t.Errorf("Organizations.ListHooks returned %+v, want %+v", hooks, want) } @@ -79,7 +79,7 @@ func TestOrganizationsService_CreateHook(t *testing.T) { t.Errorf("Organizations.CreateHook returned error: %v", err) } - want := &Hook{ID: Ptr(int64(1))} + want := &Hook{ID: new(int64(1))} if !cmp.Equal(hook, want) { t.Errorf("Organizations.CreateHook returned %+v, want %+v", hook, want) } @@ -118,7 +118,7 @@ func TestOrganizationsService_GetHook(t *testing.T) { t.Errorf("Organizations.GetHook returned error: %v", err) } - want := &Hook{ID: Ptr(int64(1))} + want := &Hook{ID: new(int64(1))} if !cmp.Equal(hook, want) { t.Errorf("Organizations.GetHook returned %+v, want %+v", hook, want) } @@ -165,7 +165,7 @@ func TestOrganizationsService_EditHook(t *testing.T) { t.Errorf("Organizations.EditHook returned error: %v", err) } - want := &Hook{ID: Ptr(int64(1))} + want := &Hook{ID: new(int64(1))} if !cmp.Equal(hook, want) { t.Errorf("Organizations.EditHook returned %+v, want %+v", hook, want) } diff --git a/github/orgs_immutable_releases_test.go b/github/orgs_immutable_releases_test.go index e6729ed4f08..1906189fb50 100644 --- a/github/orgs_immutable_releases_test.go +++ b/github/orgs_immutable_releases_test.go @@ -32,8 +32,8 @@ func TestOrganizationsService_GetImmutableReleasesSettings(t *testing.T) { } want := &ImmutableReleaseSettings{ - EnforcedRepositories: Ptr("selected"), - SelectedRepositoriesURL: Ptr("https://api.github.com/orgs/o/r"), + EnforcedRepositories: new("selected"), + SelectedRepositoriesURL: new("https://api.github.com/orgs/o/r"), } if !cmp.Equal(settings, want) { @@ -61,7 +61,7 @@ func TestOrganizationsService_UpdateImmutableReleasesSettings(t *testing.T) { client, mux, _ := setup(t) input := ImmutableReleasePolicy{ - EnforcedRepositories: Ptr("selected"), + EnforcedRepositories: new("selected"), } mux.HandleFunc("/orgs/o/settings/immutable-releases", func(w http.ResponseWriter, r *http.Request) { @@ -119,10 +119,10 @@ func TestOrganizationsService_ListImmutableReleaseRepositories(t *testing.T) { } want := &ListRepositories{ - TotalCount: Ptr(2), + TotalCount: new(2), Repositories: []*Repository{ - {ID: Ptr(int64(1)), Name: Ptr("repo1")}, - {ID: Ptr(int64(2)), Name: Ptr("repo2")}, + {ID: new(int64(1)), Name: new("repo1")}, + {ID: new(int64(2)), Name: new("repo2")}, }, } diff --git a/github/orgs_issue_types_test.go b/github/orgs_issue_types_test.go index dad06d3cbf0..f126c84efd7 100644 --- a/github/orgs_issue_types_test.go +++ b/github/orgs_issue_types_test.go @@ -47,18 +47,18 @@ func TestOrganizationsService_ListIssueTypes(t *testing.T) { want := []*IssueType{ { - ID: Ptr(int64(410)), - NodeID: Ptr("IT_kwDNAd3NAZo"), - Name: Ptr("Task"), - Description: Ptr("A specific piece of work"), + ID: new(int64(410)), + NodeID: new("IT_kwDNAd3NAZo"), + Name: new("Task"), + Description: new("A specific piece of work"), CreatedAt: refTimestamp(1136178000), UpdatedAt: refTimestamp(1136178001), }, { - ID: Ptr(int64(411)), - NodeID: Ptr("IT_kwDNAd3NAZs"), - Name: Ptr("Bug"), - Description: Ptr("An unexpected problem or behavior"), + ID: new(int64(411)), + NodeID: new("IT_kwDNAd3NAZs"), + Name: new("Bug"), + Description: new("An unexpected problem or behavior"), CreatedAt: refTimestamp(1136178002), UpdatedAt: refTimestamp(1136178003), }, @@ -88,10 +88,10 @@ func TestOrganizationsService_CreateIssueType(t *testing.T) { input := &CreateOrUpdateIssueTypesOptions{ Name: "Epic", - Description: Ptr("An issue type for a multi-week tracking of work"), + Description: new("An issue type for a multi-week tracking of work"), IsEnabled: true, - Color: Ptr("green"), - IsPrivate: Ptr(true), + Color: new("green"), + IsPrivate: new(true), } mux.HandleFunc("/orgs/o/issue-types", func(w http.ResponseWriter, r *http.Request) { @@ -113,10 +113,10 @@ func TestOrganizationsService_CreateIssueType(t *testing.T) { t.Errorf("Organizations.CreateIssueType returned error: %v", err) } want := &IssueType{ - ID: Ptr(int64(410)), - NodeID: Ptr("IT_kwDNAd3NAZo"), - Name: Ptr("Epic"), - Description: Ptr("An issue type for a multi-week tracking of work"), + ID: new(int64(410)), + NodeID: new("IT_kwDNAd3NAZo"), + Name: new("Epic"), + Description: new("An issue type for a multi-week tracking of work"), CreatedAt: refTimestamp(1136178000), UpdatedAt: refTimestamp(1136178001), } @@ -146,10 +146,10 @@ func TestOrganizationsService_UpdateIssueType(t *testing.T) { input := &CreateOrUpdateIssueTypesOptions{ Name: "Epic", - Description: Ptr("An issue type for a multi-week tracking of work"), + Description: new("An issue type for a multi-week tracking of work"), IsEnabled: true, - Color: Ptr("green"), - IsPrivate: Ptr(true), + Color: new("green"), + IsPrivate: new(true), } mux.HandleFunc("/orgs/o/issue-types/410", func(w http.ResponseWriter, r *http.Request) { @@ -171,10 +171,10 @@ func TestOrganizationsService_UpdateIssueType(t *testing.T) { t.Errorf("Organizations.UpdateIssueType returned error: %v", err) } want := &IssueType{ - ID: Ptr(int64(410)), - NodeID: Ptr("IT_kwDNAd3NAZo"), - Name: Ptr("Epic"), - Description: Ptr("An issue type for a multi-week tracking of work"), + ID: new(int64(410)), + NodeID: new("IT_kwDNAd3NAZo"), + Name: new("Epic"), + Description: new("An issue type for a multi-week tracking of work"), CreatedAt: refTimestamp(1136178000), UpdatedAt: refTimestamp(1136178001), } diff --git a/github/orgs_members_test.go b/github/orgs_members_test.go index 576620a77ec..ca6fb90785c 100644 --- a/github/orgs_members_test.go +++ b/github/orgs_members_test.go @@ -39,7 +39,7 @@ func TestOrganizationsService_ListMembers(t *testing.T) { t.Errorf("Organizations.ListMembers returned error: %v", err) } - want := []*User{{ID: Ptr(int64(1))}} + want := []*User{{ID: new(int64(1))}} if !cmp.Equal(members, want) { t.Errorf("Organizations.ListMembers returned %+v, want %+v", members, want) } @@ -84,7 +84,7 @@ func TestOrganizationsService_ListMembers_public(t *testing.T) { t.Errorf("Organizations.ListMembers returned error: %v", err) } - want := []*User{{ID: Ptr(int64(1))}} + want := []*User{{ID: new(int64(1))}} if !cmp.Equal(members, want) { t.Errorf("Organizations.ListMembers returned %+v, want %+v", members, want) } @@ -389,7 +389,7 @@ func TestOrganizationsService_ListOrgMemberships(t *testing.T) { t.Errorf("Organizations.ListOrgMemberships returned error: %v", err) } - want := []*Membership{{URL: Ptr("u")}} + want := []*Membership{{URL: new("u")}} if !cmp.Equal(memberships, want) { t.Errorf("Organizations.ListOrgMemberships returned %+v, want %+v", memberships, want) } @@ -419,7 +419,7 @@ func TestOrganizationsService_GetOrgMembership_AuthenticatedUser(t *testing.T) { t.Errorf("Organizations.GetOrgMembership returned error: %v", err) } - want := &Membership{URL: Ptr("u")} + want := &Membership{URL: new("u")} if !cmp.Equal(membership, want) { t.Errorf("Organizations.GetOrgMembership returned %+v, want %+v", membership, want) } @@ -454,7 +454,7 @@ func TestOrganizationsService_GetOrgMembership_SpecifiedUser(t *testing.T) { t.Errorf("Organizations.GetOrgMembership returned error: %v", err) } - want := &Membership{URL: Ptr("u")} + want := &Membership{URL: new("u")} if !cmp.Equal(membership, want) { t.Errorf("Organizations.GetOrgMembership returned %+v, want %+v", membership, want) } @@ -464,7 +464,7 @@ func TestOrganizationsService_EditOrgMembership_AuthenticatedUser(t *testing.T) t.Parallel() client, mux, _ := setup(t) - input := &Membership{State: Ptr("active")} + input := &Membership{State: new("active")} mux.HandleFunc("/user/memberships/orgs/o", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "PATCH") @@ -478,7 +478,7 @@ func TestOrganizationsService_EditOrgMembership_AuthenticatedUser(t *testing.T) t.Errorf("Organizations.EditOrgMembership returned error: %v", err) } - want := &Membership{URL: Ptr("u")} + want := &Membership{URL: new("u")} if !cmp.Equal(membership, want) { t.Errorf("Organizations.EditOrgMembership returned %+v, want %+v", membership, want) } @@ -502,7 +502,7 @@ func TestOrganizationsService_EditOrgMembership_SpecifiedUser(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - input := &Membership{State: Ptr("active")} + input := &Membership{State: new("active")} mux.HandleFunc("/orgs/o/memberships/u", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "PUT") @@ -516,7 +516,7 @@ func TestOrganizationsService_EditOrgMembership_SpecifiedUser(t *testing.T) { t.Errorf("Organizations.EditOrgMembership returned error: %v", err) } - want := &Membership{URL: Ptr("u")} + want := &Membership{URL: new("u")} if !cmp.Equal(membership, want) { t.Errorf("Organizations.EditOrgMembership returned %+v, want %+v", membership, want) } @@ -596,32 +596,32 @@ func TestOrganizationsService_ListPendingOrgInvitations(t *testing.T) { want := []*Invitation{ { - ID: Ptr(int64(1)), - Login: Ptr("monalisa"), - Email: Ptr("octocat@github.com"), - Role: Ptr("direct_member"), + ID: new(int64(1)), + Login: new("monalisa"), + Email: new("octocat@github.com"), + Role: new("direct_member"), CreatedAt: &referenceTimestamp, Inviter: &User{ - Login: Ptr("other_user"), - ID: Ptr(int64(1)), - AvatarURL: Ptr("https://github.com/images/error/other_user_happy.gif"), - GravatarID: Ptr(""), - URL: Ptr("https://api.github.com/users/other_user"), - HTMLURL: Ptr("https://github.com/other_user"), - FollowersURL: Ptr("https://api.github.com/users/other_user/followers"), - FollowingURL: Ptr("https://api.github.com/users/other_user/following/other_user"), - GistsURL: Ptr("https://api.github.com/users/other_user/gists/gist_id"), - StarredURL: Ptr("https://api.github.com/users/other_user/starred/owner/repo"), - SubscriptionsURL: Ptr("https://api.github.com/users/other_user/subscriptions"), - OrganizationsURL: Ptr("https://api.github.com/users/other_user/orgs"), - ReposURL: Ptr("https://api.github.com/users/other_user/repos"), - EventsURL: Ptr("https://api.github.com/users/other_user/events/privacy"), - ReceivedEventsURL: Ptr("https://api.github.com/users/other_user/received_events/privacy"), - Type: Ptr("User"), - SiteAdmin: Ptr(false), + Login: new("other_user"), + ID: new(int64(1)), + AvatarURL: new("https://github.com/images/error/other_user_happy.gif"), + GravatarID: new(""), + URL: new("https://api.github.com/users/other_user"), + HTMLURL: new("https://github.com/other_user"), + FollowersURL: new("https://api.github.com/users/other_user/followers"), + FollowingURL: new("https://api.github.com/users/other_user/following/other_user"), + GistsURL: new("https://api.github.com/users/other_user/gists/gist_id"), + StarredURL: new("https://api.github.com/users/other_user/starred/owner/repo"), + SubscriptionsURL: new("https://api.github.com/users/other_user/subscriptions"), + OrganizationsURL: new("https://api.github.com/users/other_user/orgs"), + ReposURL: new("https://api.github.com/users/other_user/repos"), + EventsURL: new("https://api.github.com/users/other_user/events/privacy"), + ReceivedEventsURL: new("https://api.github.com/users/other_user/received_events/privacy"), + Type: new("User"), + SiteAdmin: new(false), }, - TeamCount: Ptr(2), - InvitationTeamURL: Ptr("https://api.github.com/organizations/2/invitations/1/teams"), + TeamCount: new(2), + InvitationTeamURL: new("https://api.github.com/organizations/2/invitations/1/teams"), }, } @@ -649,8 +649,8 @@ func TestOrganizationsService_CreateOrgInvitation(t *testing.T) { client, mux, _ := setup(t) input := &CreateOrgInvitationOptions{ - Email: Ptr("octocat@github.com"), - Role: Ptr("direct_member"), + Email: new("octocat@github.com"), + Role: new("direct_member"), TeamID: []int64{ 12, 26, @@ -669,7 +669,7 @@ func TestOrganizationsService_CreateOrgInvitation(t *testing.T) { t.Errorf("Organizations.CreateOrgInvitation returned error: %v", err) } - want := &Invitation{Email: Ptr("octocat@github.com")} + want := &Invitation{Email: new("octocat@github.com")} if !cmp.Equal(invitations, want) { t.Errorf("Organizations.CreateOrgInvitation returned %+v, want %+v", invitations, want) } @@ -720,15 +720,15 @@ func TestOrganizationsService_ListOrgInvitationTeams(t *testing.T) { want := []*Team{ { - ID: Ptr(int64(1)), - URL: Ptr("https://api.github.com/teams/1"), - Name: Ptr("Justice League"), - Slug: Ptr("justice-league"), - Description: Ptr("A great team."), - Privacy: Ptr("closed"), - Permission: Ptr("admin"), - MembersURL: Ptr("https://api.github.com/teams/1/members{/member}"), - RepositoriesURL: Ptr("https://api.github.com/teams/1/repos"), + ID: new(int64(1)), + URL: new("https://api.github.com/teams/1"), + Name: new("Justice League"), + Slug: new("justice-league"), + Description: new("A great team."), + Privacy: new("closed"), + Permission: new("admin"), + MembersURL: new("https://api.github.com/teams/1/members{/member}"), + RepositoriesURL: new("https://api.github.com/teams/1/repos"), }, } @@ -803,36 +803,36 @@ func TestOrganizationsService_ListFailedOrgInvitations(t *testing.T) { want := []*Invitation{ { - ID: Ptr(int64(1)), - Login: Ptr("monalisa"), - NodeID: Ptr("MDQ6VXNlcjE="), - Email: Ptr("octocat@github.com"), - Role: Ptr("direct_member"), + ID: new(int64(1)), + Login: new("monalisa"), + NodeID: new("MDQ6VXNlcjE="), + Email: new("octocat@github.com"), + Role: new("direct_member"), CreatedAt: refTimestamp(1136178000), FailedAt: refTimestamp(1136178001), - FailedReason: Ptr("the reason"), + FailedReason: new("the reason"), Inviter: &User{ - Login: Ptr("other_user"), - ID: Ptr(int64(1)), - NodeID: Ptr("MDQ6VXNlcjE="), - AvatarURL: Ptr("https://github.com/images/error/other_user_happy.gif"), - GravatarID: Ptr(""), - URL: Ptr("https://api.github.com/users/other_user"), - HTMLURL: Ptr("https://github.com/other_user"), - FollowersURL: Ptr("https://api.github.com/users/other_user/followers"), - FollowingURL: Ptr("https://api.github.com/users/other_user/following{/other_user}"), - GistsURL: Ptr("https://api.github.com/users/other_user/gists{/gist_id}"), - StarredURL: Ptr("https://api.github.com/users/other_user/starred{/owner}{/repo}"), - SubscriptionsURL: Ptr("https://api.github.com/users/other_user/subscriptions"), - OrganizationsURL: Ptr("https://api.github.com/users/other_user/orgs"), - ReposURL: Ptr("https://api.github.com/users/other_user/repos"), - EventsURL: Ptr("https://api.github.com/users/other_user/events{/privacy}"), - ReceivedEventsURL: Ptr("https://api.github.com/users/other_user/received_events"), - Type: Ptr("User"), - SiteAdmin: Ptr(false), + Login: new("other_user"), + ID: new(int64(1)), + NodeID: new("MDQ6VXNlcjE="), + AvatarURL: new("https://github.com/images/error/other_user_happy.gif"), + GravatarID: new(""), + URL: new("https://api.github.com/users/other_user"), + HTMLURL: new("https://github.com/other_user"), + FollowersURL: new("https://api.github.com/users/other_user/followers"), + FollowingURL: new("https://api.github.com/users/other_user/following{/other_user}"), + GistsURL: new("https://api.github.com/users/other_user/gists{/gist_id}"), + StarredURL: new("https://api.github.com/users/other_user/starred{/owner}{/repo}"), + SubscriptionsURL: new("https://api.github.com/users/other_user/subscriptions"), + OrganizationsURL: new("https://api.github.com/users/other_user/orgs"), + ReposURL: new("https://api.github.com/users/other_user/repos"), + EventsURL: new("https://api.github.com/users/other_user/events{/privacy}"), + ReceivedEventsURL: new("https://api.github.com/users/other_user/received_events"), + Type: new("User"), + SiteAdmin: new(false), }, - TeamCount: Ptr(2), - InvitationTeamURL: Ptr("https://api.github.com/organizations/2/invitations/1/teams"), + TeamCount: new(2), + InvitationTeamURL: new("https://api.github.com/organizations/2/invitations/1/teams"), }, } diff --git a/github/orgs_network_configurations_test.go b/github/orgs_network_configurations_test.go index cb2767cfe51..1150005bf8e 100644 --- a/github/orgs_network_configurations_test.go +++ b/github/orgs_network_configurations_test.go @@ -65,12 +65,12 @@ func TestOrganizationsService_ListOrgsNetworkConfigurations(t *testing.T) { t.Errorf("Organizations.ListNetworkConfigurations returned error %v", err) } want := &NetworkConfigurations{ - TotalCount: Ptr(int64(3)), + TotalCount: new(int64(3)), NetworkConfigurations: []*NetworkConfiguration{ { - ID: Ptr("123456789ABCDEF"), - Name: Ptr("Network Configuration One"), - ComputeService: Ptr(ComputeService("actions")), + ID: new("123456789ABCDEF"), + Name: new("Network Configuration One"), + ComputeService: new(ComputeService("actions")), NetworkSettingsIDs: []string{ "23456789ABDCEF1", "3456789ABDCEF12", @@ -78,9 +78,9 @@ func TestOrganizationsService_ListOrgsNetworkConfigurations(t *testing.T) { CreatedOn: &referenceTimestamp, }, { - ID: Ptr("456789ABDCEF123"), - Name: Ptr("Network Configuration Two"), - ComputeService: Ptr(ComputeService("none")), + ID: new("456789ABDCEF123"), + Name: new("Network Configuration Two"), + ComputeService: new(ComputeService("none")), NetworkSettingsIDs: []string{ "56789ABDCEF1234", "6789ABDCEF12345", @@ -88,9 +88,9 @@ func TestOrganizationsService_ListOrgsNetworkConfigurations(t *testing.T) { CreatedOn: &referenceTimestamp, }, { - ID: Ptr("789ABDCEF123456"), - Name: Ptr("Network Configuration Three"), - ComputeService: Ptr(ComputeService("codespaces")), + ID: new("789ABDCEF123456"), + Name: new("Network Configuration Three"), + ComputeService: new(ComputeService("codespaces")), NetworkSettingsIDs: []string{ "56789ABDCEF1234", "6789ABDCEF12345", @@ -138,8 +138,8 @@ func TestOrganizationsService_CreateOrgsNetworkConfiguration(t *testing.T) { ctx := t.Context() req := NetworkConfigurationRequest{ - Name: Ptr("network-configuration-two"), - ComputeService: Ptr(ComputeService("none")), + Name: new("network-configuration-two"), + ComputeService: new(ComputeService("none")), NetworkSettingsIDs: []string{ "56789ABDCEF1234", }, @@ -151,9 +151,9 @@ func TestOrganizationsService_CreateOrgsNetworkConfiguration(t *testing.T) { } want := &NetworkConfiguration{ - ID: Ptr("456789ABDCEF123"), - Name: Ptr("network-configuration-two"), - ComputeService: Ptr(ComputeService("none")), + ID: new("456789ABDCEF123"), + Name: new("network-configuration-two"), + ComputeService: new(ComputeService("none")), NetworkSettingsIDs: []string{ "56789ABDCEF1234", }, @@ -172,8 +172,8 @@ func TestOrganizationsService_CreateOrgsNetworkConfiguration(t *testing.T) { { name: "invalid network configuration name length", request: NetworkConfigurationRequest{ - Name: Ptr(""), - ComputeService: Ptr(ComputeService("none")), + Name: new(""), + ComputeService: new(ComputeService("none")), NetworkSettingsIDs: []string{ "56789ABDCEF1234", }, @@ -184,7 +184,7 @@ func TestOrganizationsService_CreateOrgsNetworkConfiguration(t *testing.T) { name: "invalid network configuration name", // may only contain upper and lowercase letters a-z, numbers 0-9, '.', '-', and '_'. request: NetworkConfigurationRequest{ - Name: Ptr("network configuration two"), + Name: new("network configuration two"), NetworkSettingsIDs: []string{ "56789ABDCEF1234", }, @@ -194,8 +194,8 @@ func TestOrganizationsService_CreateOrgsNetworkConfiguration(t *testing.T) { { name: "invalid network settings ids", request: NetworkConfigurationRequest{ - Name: Ptr("network-configuration-two"), - ComputeService: Ptr(ComputeService("none")), + Name: new("network-configuration-two"), + ComputeService: new(ComputeService("none")), NetworkSettingsIDs: []string{ "56789ABDCEF1234", "3456789ABDCEF12", @@ -206,8 +206,8 @@ func TestOrganizationsService_CreateOrgsNetworkConfiguration(t *testing.T) { { name: "invalid compute service", request: NetworkConfigurationRequest{ - Name: Ptr("network-configuration-two"), - ComputeService: Ptr(ComputeService("codespaces")), + Name: new("network-configuration-two"), + ComputeService: new(ComputeService("codespaces")), NetworkSettingsIDs: []string{ "56789ABDCEF1234", }, @@ -263,9 +263,9 @@ func TestOrganizationsService_GetOrgsNetworkConfiguration(t *testing.T) { t.Errorf("Organizations.GetNetworkConfiguration returned error: %v", err) } want := &NetworkConfiguration{ - ID: Ptr("789ABDCEF123456"), - Name: Ptr("Network Configuration Three"), - ComputeService: Ptr(ComputeService("codespaces")), + ID: new("789ABDCEF123456"), + Name: new("Network Configuration Three"), + ComputeService: new(ComputeService("codespaces")), NetworkSettingsIDs: []string{ "56789ABDCEF1234", "6789ABDCEF12345", @@ -312,8 +312,8 @@ func TestOrganizationsService_UpdateOrgsNetworkConfiguration(t *testing.T) { ctx := t.Context() req := NetworkConfigurationRequest{ - Name: Ptr("network-configuration-three-update"), - ComputeService: Ptr(ComputeService("actions")), + Name: new("network-configuration-three-update"), + ComputeService: new(ComputeService("actions")), NetworkSettingsIDs: []string{ "56789ABDCEF1234", }, @@ -324,9 +324,9 @@ func TestOrganizationsService_UpdateOrgsNetworkConfiguration(t *testing.T) { } want := &NetworkConfiguration{ - ID: Ptr("789ABDCEF123456"), - Name: Ptr("Network Configuration Three Update"), - ComputeService: Ptr(ComputeService("actions")), + ID: new("789ABDCEF123456"), + Name: new("Network Configuration Three Update"), + ComputeService: new(ComputeService("actions")), NetworkSettingsIDs: []string{ "56789ABDCEF1234", "6789ABDCEF12345", @@ -345,8 +345,8 @@ func TestOrganizationsService_UpdateOrgsNetworkConfiguration(t *testing.T) { { name: "invalid network configuration name length", request: NetworkConfigurationRequest{ - Name: Ptr(""), - ComputeService: Ptr(ComputeService("none")), + Name: new(""), + ComputeService: new(ComputeService("none")), NetworkSettingsIDs: []string{ "56789ABDCEF1234", }, @@ -357,7 +357,7 @@ func TestOrganizationsService_UpdateOrgsNetworkConfiguration(t *testing.T) { name: "invalid network configuration name", // may only contain upper and lowercase letters a-z, numbers 0-9, '.', '-', and '_'. request: NetworkConfigurationRequest{ - Name: Ptr("network configuration three update"), + Name: new("network configuration three update"), NetworkSettingsIDs: []string{ "56789ABDCEF1234", }, @@ -367,8 +367,8 @@ func TestOrganizationsService_UpdateOrgsNetworkConfiguration(t *testing.T) { { name: "invalid network settings ids", request: NetworkConfigurationRequest{ - Name: Ptr("network-configuration-three-update"), - ComputeService: Ptr(ComputeService("none")), + Name: new("network-configuration-three-update"), + ComputeService: new(ComputeService("none")), NetworkSettingsIDs: []string{ "56789ABDCEF1234", "3456789ABDCEF12", @@ -379,8 +379,8 @@ func TestOrganizationsService_UpdateOrgsNetworkConfiguration(t *testing.T) { { name: "invalid compute service", request: NetworkConfigurationRequest{ - Name: Ptr("network-configuration-three-update"), - ComputeService: Ptr(ComputeService("codespaces")), + Name: new("network-configuration-three-update"), + ComputeService: new(ComputeService("codespaces")), NetworkSettingsIDs: []string{ "56789ABDCEF1234", }, @@ -460,11 +460,11 @@ func TestOrganizationsService_GetOrgsNetworkConfigurationResource(t *testing.T) } want := &NetworkSettingsResource{ - ID: Ptr("220F78DACB92BBFBC5E6F22DE1CCF52309D"), - Name: Ptr("my_network_settings"), - NetworkConfigurationID: Ptr("934E208B3EE0BD60CF5F752C426BFB53562"), - SubnetID: Ptr("/subscriptions/14839728-3ad9-43ab-bd2b-fa6ad0f75e2a/resourceGroups/my-rg/providers/Microsoft.Network/virtualNetworks/my-vnet/subnets/my-subnet"), - Region: Ptr("germanywestcentral"), + ID: new("220F78DACB92BBFBC5E6F22DE1CCF52309D"), + Name: new("my_network_settings"), + NetworkConfigurationID: new("934E208B3EE0BD60CF5F752C426BFB53562"), + SubnetID: new("/subscriptions/14839728-3ad9-43ab-bd2b-fa6ad0f75e2a/resourceGroups/my-rg/providers/Microsoft.Network/virtualNetworks/my-vnet/subnets/my-subnet"), + Region: new("germanywestcentral"), } if !cmp.Equal(want, resource) { diff --git a/github/orgs_organization_properties_test.go b/github/orgs_organization_properties_test.go index e7bc715c164..1f2cd0a8b9f 100644 --- a/github/orgs_organization_properties_test.go +++ b/github/orgs_organization_properties_test.go @@ -71,8 +71,8 @@ func TestOrganizationsService_CreateOrUpdateOrganizationCustomPropertyValues(t * ctx := t.Context() values := []*CustomPropertyValue{ - {PropertyName: "team", Value: Ptr("core")}, - {PropertyName: "level", Value: Ptr("gold")}, + {PropertyName: "team", Value: new("core")}, + {PropertyName: "level", Value: new("gold")}, } props := OrganizationCustomPropertyValues{ diff --git a/github/orgs_organization_roles_test.go b/github/orgs_organization_roles_test.go index e1300ad5356..ef9f7d70115 100644 --- a/github/orgs_organization_roles_test.go +++ b/github/orgs_organization_roles_test.go @@ -52,28 +52,28 @@ func TestOrganizationsService_ListRoles(t *testing.T) { } want := &OrganizationCustomRoles{ - TotalCount: Ptr(1), + TotalCount: new(1), CustomRepoRoles: []*CustomOrgRole{ { - ID: Ptr(int64(1)), - Name: Ptr("Auditor"), + ID: new(int64(1)), + Name: new("Auditor"), Permissions: []string{"read_audit_logs"}, Org: &Organization{ - Login: Ptr("l"), - ID: Ptr(int64(1)), - NodeID: Ptr("n"), - AvatarURL: Ptr("a"), - HTMLURL: Ptr("h"), - Name: Ptr("n"), - Company: Ptr("c"), - Blog: Ptr("b"), - Location: Ptr("l"), - Email: Ptr("e"), + Login: new("l"), + ID: new(int64(1)), + NodeID: new("n"), + AvatarURL: new("a"), + HTMLURL: new("h"), + Name: new("n"), + Company: new("c"), + Blog: new("b"), + Location: new("l"), + Email: new("e"), }, CreatedAt: refTimestamp(1136178000), UpdatedAt: refTimestamp(1136178001), - Source: Ptr("Organization"), - BaseRole: Ptr("admin"), + Source: new("Organization"), + BaseRole: new("admin"), }, }, } @@ -123,14 +123,14 @@ func TestOrganizationsService_GetOrgRole(t *testing.T) { } wantBuiltInRole := &CustomOrgRole{ - ID: Ptr(int64(8132)), - Name: Ptr("all_repo_read"), - Description: Ptr("Grants read access to all repositories in the organization."), + ID: new(int64(8132)), + Name: new("all_repo_read"), + Description: new("Grants read access to all repositories in the organization."), Permissions: []string{}, CreatedAt: refTimestamp(1136178000), UpdatedAt: refTimestamp(1136178001), - Source: Ptr("Predefined"), - BaseRole: Ptr("read"), + Source: new("Predefined"), + BaseRole: new("read"), } if !cmp.Equal(gotBuiltInRole, wantBuiltInRole) { @@ -162,9 +162,9 @@ func TestOrganizationsService_GetOrgRole(t *testing.T) { } wantCustomRole := &CustomOrgRole{ - ID: Ptr(int64(123456)), - Name: Ptr("test-role"), - Description: Ptr("test-role"), + ID: new(int64(123456)), + Name: new("test-role"), + Description: new("test-role"), Permissions: []string{ "read_organization_custom_org_role", "read_organization_custom_repo_role", @@ -172,7 +172,7 @@ func TestOrganizationsService_GetOrgRole(t *testing.T) { }, CreatedAt: refTimestamp(1136178000), UpdatedAt: refTimestamp(1136178001), - Source: Ptr("Organization"), + Source: new("Organization"), BaseRole: nil, } @@ -209,14 +209,14 @@ func TestOrganizationsService_CreateCustomOrgRole(t *testing.T) { opts := CreateCustomOrgRoleRequest{ Name: "Reader", Permissions: []string{"read_organization_custom_org_role"}, - Description: Ptr("A role for reading custom org roles"), + Description: new("A role for reading custom org roles"), } gotRoles, _, err := client.Organizations.CreateCustomOrgRole(ctx, "o", opts) if err != nil { t.Errorf("Organizations.CreateCustomOrgRole returned error: %v", err) } - want := &CustomOrgRole{ID: Ptr(int64(8030)), Name: Ptr("Reader"), Permissions: []string{"read_organization_custom_org_role"}, Description: Ptr("A role for reading custom org roles")} + want := &CustomOrgRole{ID: new(int64(8030)), Name: new("Reader"), Permissions: []string{"read_organization_custom_org_role"}, Description: new("A role for reading custom org roles")} if !cmp.Equal(gotRoles, want) { t.Errorf("Organizations.CreateCustomOrgRole returned %+v, want %+v", gotRoles, want) @@ -249,15 +249,15 @@ func TestOrganizationsService_UpdateCustomOrgRole(t *testing.T) { ctx := t.Context() opts := UpdateCustomOrgRoleRequest{ - Name: Ptr("Updated Name"), - Description: Ptr("Updated Description"), + Name: new("Updated Name"), + Description: new("Updated Description"), } gotRoles, _, err := client.Organizations.UpdateCustomOrgRole(ctx, "o", 8030, opts) if err != nil { t.Errorf("Organizations.UpdateCustomOrgRole returned error: %v", err) } - want := &CustomOrgRole{ID: Ptr(int64(8030)), Name: Ptr("Updated Name"), Permissions: []string{"read_organization_custom_org_role"}, Description: Ptr("Updated Description")} + want := &CustomOrgRole{ID: new(int64(8030)), Name: new("Updated Name"), Permissions: []string{"read_organization_custom_org_role"}, Description: new("Updated Description")} if !cmp.Equal(gotRoles, want) { t.Errorf("Organizations.UpdateCustomOrgRole returned %+v, want %+v", gotRoles, want) @@ -440,7 +440,7 @@ func TestOrganizationsService_ListTeamsAssignedToOrgRole(t *testing.T) { t.Errorf("Organizations.ListTeamsAssignedToOrgRole returned error: %v", err) } - want := []*Team{{ID: Ptr(int64(1))}} + want := []*Team{{ID: new(int64(1))}} if !cmp.Equal(apps, want) { t.Errorf("Organizations.ListTeamsAssignedToOrgRole returned %+v, want %+v", apps, want) } @@ -475,7 +475,7 @@ func TestOrganizationsService_ListUsersAssignedToOrgRole(t *testing.T) { t.Errorf("Organizations.ListUsersAssignedToOrgRole returned error: %v", err) } - want := []*User{{ID: Ptr(int64(1))}} + want := []*User{{ID: new(int64(1))}} if !cmp.Equal(apps, want) { t.Errorf("Organizations.ListUsersAssignedToOrgRole returned %+v, want %+v", apps, want) } diff --git a/github/orgs_outside_collaborators_test.go b/github/orgs_outside_collaborators_test.go index 8d27a13b8b7..7ffe1897c35 100644 --- a/github/orgs_outside_collaborators_test.go +++ b/github/orgs_outside_collaborators_test.go @@ -37,7 +37,7 @@ func TestOrganizationsService_ListOutsideCollaborators(t *testing.T) { t.Errorf("Organizations.ListOutsideCollaborators returned error: %v", err) } - want := []*User{{ID: Ptr(int64(1))}} + want := []*User{{ID: new(int64(1))}} if !cmp.Equal(members, want) { t.Errorf("Organizations.ListOutsideCollaborators returned %+v, want %+v", members, want) } diff --git a/github/orgs_packages_test.go b/github/orgs_packages_test.go index 18e506a006e..7084d8785d8 100644 --- a/github/orgs_packages_test.go +++ b/github/orgs_packages_test.go @@ -64,34 +64,34 @@ func TestOrganizationsService_ListPackages(t *testing.T) { } want := []*Package{{ - ID: Ptr(int64(197)), - Name: Ptr("hello_docker"), - PackageType: Ptr("container"), - VersionCount: Ptr(int64(1)), - Visibility: Ptr("private"), - URL: Ptr("https://api.github.com/orgs/github/packages/container/hello_docker"), - HTMLURL: Ptr("https://github.com/orgs/github/packages/container/package/hello_docker"), + ID: new(int64(197)), + Name: new("hello_docker"), + PackageType: new("container"), + VersionCount: new(int64(1)), + Visibility: new("private"), + URL: new("https://api.github.com/orgs/github/packages/container/hello_docker"), + HTMLURL: new("https://github.com/orgs/github/packages/container/package/hello_docker"), CreatedAt: &Timestamp{referenceTime}, UpdatedAt: &Timestamp{referenceTime}, Owner: &User{ - Login: Ptr("github"), - ID: Ptr(int64(9919)), - NodeID: Ptr("MDEyOk9yZ2FuaXphdGlvbjk5MTk="), - AvatarURL: Ptr("https://avatars.githubusercontent.com/u/9919?v=4"), - GravatarID: Ptr(""), - URL: Ptr("https://api.github.com/users/github"), - HTMLURL: Ptr("https://github.com/github"), - FollowersURL: Ptr("https://api.github.com/users/github/followers"), - FollowingURL: Ptr("https://api.github.com/users/github/following{/other_user}"), - GistsURL: Ptr("https://api.github.com/users/github/gists{/gist_id}"), - StarredURL: Ptr("https://api.github.com/users/github/starred{/owner}{/repo}"), - SubscriptionsURL: Ptr("https://api.github.com/users/github/subscriptions"), - OrganizationsURL: Ptr("https://api.github.com/users/github/orgs"), - ReposURL: Ptr("https://api.github.com/users/github/repos"), - EventsURL: Ptr("https://api.github.com/users/github/events{/privacy}"), - ReceivedEventsURL: Ptr("https://api.github.com/users/github/received_events"), - Type: Ptr("Organization"), - SiteAdmin: Ptr(false), + Login: new("github"), + ID: new(int64(9919)), + NodeID: new("MDEyOk9yZ2FuaXphdGlvbjk5MTk="), + AvatarURL: new("https://avatars.githubusercontent.com/u/9919?v=4"), + GravatarID: new(""), + URL: new("https://api.github.com/users/github"), + HTMLURL: new("https://github.com/github"), + FollowersURL: new("https://api.github.com/users/github/followers"), + FollowingURL: new("https://api.github.com/users/github/following{/other_user}"), + GistsURL: new("https://api.github.com/users/github/gists{/gist_id}"), + StarredURL: new("https://api.github.com/users/github/starred{/owner}{/repo}"), + SubscriptionsURL: new("https://api.github.com/users/github/subscriptions"), + OrganizationsURL: new("https://api.github.com/users/github/orgs"), + ReposURL: new("https://api.github.com/users/github/repos"), + EventsURL: new("https://api.github.com/users/github/events{/privacy}"), + ReceivedEventsURL: new("https://api.github.com/users/github/received_events"), + Type: new("Organization"), + SiteAdmin: new(false), }, }} if !cmp.Equal(packages, want) { @@ -143,13 +143,13 @@ func TestOrganizationsService_GetPackage(t *testing.T) { } want := &Package{ - ID: Ptr(int64(197)), - Name: Ptr("hello/hello_docker"), - PackageType: Ptr("container"), - VersionCount: Ptr(int64(1)), - Visibility: Ptr("private"), - URL: Ptr("https://api.github.com/orgs/github/packages/container/hello%2Fhello_docker"), - HTMLURL: Ptr("https://github.com/orgs/github/packages/container/package/hello%2Fhello_docker"), + ID: new(int64(197)), + Name: new("hello/hello_docker"), + PackageType: new("container"), + VersionCount: new(int64(1)), + Visibility: new("private"), + URL: new("https://api.github.com/orgs/github/packages/container/hello%2Fhello_docker"), + HTMLURL: new("https://github.com/orgs/github/packages/container/package/hello%2Fhello_docker"), CreatedAt: &Timestamp{referenceTime}, UpdatedAt: &Timestamp{referenceTime}, } @@ -263,7 +263,7 @@ func TestOrganizationsService_ListPackagesVersions(t *testing.T) { ctx := t.Context() opts := &PackageListOptions{ - Ptr("internal"), Ptr("container"), Ptr("deleted"), ListOptions{Page: 1, PerPage: 2}, + new("internal"), new("container"), new("deleted"), ListOptions{Page: 1, PerPage: 2}, } packages, _, err := client.Organizations.PackageGetAllVersions(ctx, "o", "container", "hello/hello_docker", opts) if err != nil { @@ -271,13 +271,13 @@ func TestOrganizationsService_ListPackagesVersions(t *testing.T) { } want := []*PackageVersion{{ - ID: Ptr(int64(45763)), - Name: Ptr("sha256:08a44bab0bddaddd8837a8b381aebc2e4b933768b981685a9e088360af0d3dd9"), - URL: Ptr("https://api.github.com/users/octocat/packages/container/hello%2Fhello_docker/versions/45763"), - PackageHTMLURL: Ptr("https://github.com/users/octocat/packages/container/package/hello%2Fhello_docker"), + ID: new(int64(45763)), + Name: new("sha256:08a44bab0bddaddd8837a8b381aebc2e4b933768b981685a9e088360af0d3dd9"), + URL: new("https://api.github.com/users/octocat/packages/container/hello%2Fhello_docker/versions/45763"), + PackageHTMLURL: new("https://github.com/users/octocat/packages/container/package/hello%2Fhello_docker"), CreatedAt: &Timestamp{referenceTime}, UpdatedAt: &Timestamp{referenceTime}, - HTMLURL: Ptr("https://github.com/users/octocat/packages/container/hello%2Fhello_docker/45763"), + HTMLURL: new("https://github.com/users/octocat/packages/container/hello%2Fhello_docker/45763"), Metadata: json.RawMessage(m), }} if !cmp.Equal(packages, want) { @@ -338,13 +338,13 @@ func TestOrganizationsService_PackageGetVersion(t *testing.T) { } want := &PackageVersion{ - ID: Ptr(int64(45763)), - Name: Ptr("sha256:08a44bab0bddaddd8837a8b381aebc2e4b933768b981685a9e088360af0d3dd9"), - URL: Ptr("https://api.github.com/users/octocat/packages/container/hello%2Fhello_docker/versions/45763"), - PackageHTMLURL: Ptr("https://github.com/users/octocat/packages/container/package/hello%2Fhello_docker"), + ID: new(int64(45763)), + Name: new("sha256:08a44bab0bddaddd8837a8b381aebc2e4b933768b981685a9e088360af0d3dd9"), + URL: new("https://api.github.com/users/octocat/packages/container/hello%2Fhello_docker/versions/45763"), + PackageHTMLURL: new("https://github.com/users/octocat/packages/container/package/hello%2Fhello_docker"), CreatedAt: &Timestamp{referenceTime}, UpdatedAt: &Timestamp{referenceTime}, - HTMLURL: Ptr("https://github.com/users/octocat/packages/container/hello%2Fhello_docker/45763"), + HTMLURL: new("https://github.com/users/octocat/packages/container/hello%2Fhello_docker/45763"), Metadata: json.RawMessage(m), } if !cmp.Equal(packages, want) { diff --git a/github/orgs_personal_access_tokens_test.go b/github/orgs_personal_access_tokens_test.go index b2d82399cbb..f29854b7eba 100644 --- a/github/orgs_personal_access_tokens_test.go +++ b/github/orgs_personal_access_tokens_test.go @@ -84,35 +84,35 @@ func TestOrganizationsService_ListFineGrainedPersonalAccessTokens(t *testing.T) want := []*PersonalAccessToken{ { - ID: Ptr(int64(25381)), + ID: new(int64(25381)), Owner: &User{ - Login: Ptr("octocat"), - ID: Ptr(int64(1)), - NodeID: Ptr("MDQ6VXNlcjE="), - AvatarURL: Ptr("https://github.com/images/error/octocat_happy.gif"), - GravatarID: Ptr(""), - URL: Ptr("https://api.github.com/users/octocat"), - HTMLURL: Ptr("https://github.com/octocat"), - FollowersURL: Ptr("https://api.github.com/users/octocat/followers"), - FollowingURL: Ptr("https://api.github.com/users/octocat/following{/other_user}"), - GistsURL: Ptr("https://api.github.com/users/octocat/gists{/gist_id}"), - StarredURL: Ptr("https://api.github.com/users/octocat/starred{/owner}{/repo}"), - SubscriptionsURL: Ptr("https://api.github.com/users/octocat/subscriptions"), - OrganizationsURL: Ptr("https://api.github.com/users/octocat/orgs"), - ReposURL: Ptr("https://api.github.com/users/octocat/repos"), - EventsURL: Ptr("https://api.github.com/users/octocat/events{/privacy}"), - ReceivedEventsURL: Ptr("https://api.github.com/users/octocat/received_events"), - Type: Ptr("User"), - SiteAdmin: Ptr(false), + Login: new("octocat"), + ID: new(int64(1)), + NodeID: new("MDQ6VXNlcjE="), + AvatarURL: new("https://github.com/images/error/octocat_happy.gif"), + GravatarID: new(""), + URL: new("https://api.github.com/users/octocat"), + HTMLURL: new("https://github.com/octocat"), + FollowersURL: new("https://api.github.com/users/octocat/followers"), + FollowingURL: new("https://api.github.com/users/octocat/following{/other_user}"), + GistsURL: new("https://api.github.com/users/octocat/gists{/gist_id}"), + StarredURL: new("https://api.github.com/users/octocat/starred{/owner}{/repo}"), + SubscriptionsURL: new("https://api.github.com/users/octocat/subscriptions"), + OrganizationsURL: new("https://api.github.com/users/octocat/orgs"), + ReposURL: new("https://api.github.com/users/octocat/repos"), + EventsURL: new("https://api.github.com/users/octocat/events{/privacy}"), + ReceivedEventsURL: new("https://api.github.com/users/octocat/received_events"), + Type: new("User"), + SiteAdmin: new(false), }, - RepositorySelection: Ptr("all"), - RepositoriesURL: Ptr("https://api.github.com/organizations/652551/personal-access-tokens/25381/repositories"), + RepositorySelection: new("all"), + RepositoriesURL: new("https://api.github.com/organizations/652551/personal-access-tokens/25381/repositories"), Permissions: &PersonalAccessTokenPermissions{ Org: map[string]string{"members": "read"}, Repo: map[string]string{"metadata": "read"}, }, AccessGrantedAt: refTimestamp(1136178000), - TokenExpired: Ptr(false), + TokenExpired: new(false), TokenExpiresAt: refTimestamp(1136178001), TokenLastUsedAt: nil, }, @@ -237,24 +237,24 @@ func TestOrganizationsService_ListFineGrainedPersonalAccessTokenRequests(t *test ID: 1848980, Reason: "", Owner: User{ - Login: Ptr("octocat"), - ID: Ptr(int64(1)), - NodeID: Ptr("MDQ6VXNlcjE="), - AvatarURL: Ptr("https://github.com/images/error/octocat_happy.gif"), - GravatarID: Ptr(""), - URL: Ptr("https://api.github.com/users/octocat"), - HTMLURL: Ptr("https://github.com/octocat"), - FollowersURL: Ptr("https://api.github.com/users/octocat/followers"), - FollowingURL: Ptr("https://api.github.com/users/octocat/following{/other_user}"), - GistsURL: Ptr("https://api.github.com/users/octocat/gists{/gist_id}"), - StarredURL: Ptr("https://api.github.com/users/octocat/starred{/owner}{/repo}"), - SubscriptionsURL: Ptr("https://api.github.com/users/octocat/subscriptions"), - OrganizationsURL: Ptr("https://api.github.com/users/octocat/orgs"), - ReposURL: Ptr("https://api.github.com/users/octocat/repos"), - EventsURL: Ptr("https://api.github.com/users/octocat/events{/privacy}"), - ReceivedEventsURL: Ptr("https://api.github.com/users/octocat/received_events"), - Type: Ptr("User"), - SiteAdmin: Ptr(false), + Login: new("octocat"), + ID: new(int64(1)), + NodeID: new("MDQ6VXNlcjE="), + AvatarURL: new("https://github.com/images/error/octocat_happy.gif"), + GravatarID: new(""), + URL: new("https://api.github.com/users/octocat"), + HTMLURL: new("https://github.com/octocat"), + FollowersURL: new("https://api.github.com/users/octocat/followers"), + FollowingURL: new("https://api.github.com/users/octocat/following{/other_user}"), + GistsURL: new("https://api.github.com/users/octocat/gists{/gist_id}"), + StarredURL: new("https://api.github.com/users/octocat/starred{/owner}{/repo}"), + SubscriptionsURL: new("https://api.github.com/users/octocat/subscriptions"), + OrganizationsURL: new("https://api.github.com/users/octocat/orgs"), + ReposURL: new("https://api.github.com/users/octocat/repos"), + EventsURL: new("https://api.github.com/users/octocat/events{/privacy}"), + ReceivedEventsURL: new("https://api.github.com/users/octocat/received_events"), + Type: new("User"), + SiteAdmin: new(false), }, RepositorySelection: "all", RepositoriesURL: "https://api.github.com/organizations/135028681/personal-access-token-requests/1848980/repositories", @@ -338,7 +338,7 @@ func TestOrganizationsService_ReviewPersonalAccessTokenRequest(t *testing.T) { input := ReviewPersonalAccessTokenRequestOptions{ Action: "a", - Reason: Ptr("r"), + Reason: new("r"), } mux.HandleFunc("/orgs/o/personal-access-token-requests/1", func(w http.ResponseWriter, r *http.Request) { diff --git a/github/orgs_properties_test.go b/github/orgs_properties_test.go index c2e5f8a5201..10de42fe2da 100644 --- a/github/orgs_properties_test.go +++ b/github/orgs_properties_test.go @@ -76,37 +76,37 @@ func TestOrganizationsService_GetAllCustomProperties(t *testing.T) { want := []*CustomProperty{ { - PropertyName: Ptr("name"), + PropertyName: new("name"), ValueType: PropertyValueTypeSingleSelect, - Required: Ptr(true), + Required: new(true), DefaultValue: "production", - Description: Ptr("Prod or dev environment"), + Description: new("Prod or dev environment"), AllowedValues: []string{"production", "development"}, - ValuesEditableBy: Ptr("org_actors"), + ValuesEditableBy: new("org_actors"), }, { - PropertyName: Ptr("test"), + PropertyName: new("test"), ValueType: PropertyValueTypeMultiSelect, - Required: Ptr(true), + Required: new(true), DefaultValue: []any{"foo", "baz"}, - Description: Ptr("Prod or dev environment"), + Description: new("Prod or dev environment"), AllowedValues: []string{"foo", "bar", "baz"}, - ValuesEditableBy: Ptr("org_actors"), + ValuesEditableBy: new("org_actors"), }, { - PropertyName: Ptr("service"), + PropertyName: new("service"), ValueType: PropertyValueTypeString, }, { - PropertyName: Ptr("team"), + PropertyName: new("team"), ValueType: PropertyValueTypeString, - Description: Ptr("Team owning the repository"), + Description: new("Team owning the repository"), }, { - PropertyName: Ptr("documentation"), + PropertyName: new("documentation"), ValueType: PropertyValueTypeURL, - Required: Ptr(true), - Description: Ptr("Link to the documentation"), + Required: new(true), + Description: new("Link to the documentation"), DefaultValue: "https://example.com/docs", }, } @@ -135,12 +135,12 @@ func TestOrganizationsService_CreateOrUpdateCustomProperties(t *testing.T) { }{ Properties: []*CustomProperty{ { - PropertyName: Ptr("name"), + PropertyName: new("name"), ValueType: PropertyValueTypeSingleSelect, - Required: Ptr(true), + Required: new(true), }, { - PropertyName: Ptr("service"), + PropertyName: new("service"), ValueType: PropertyValueTypeString, }, }, @@ -170,12 +170,12 @@ func TestOrganizationsService_CreateOrUpdateCustomProperties(t *testing.T) { want := []*CustomProperty{ { - PropertyName: Ptr("name"), + PropertyName: new("name"), ValueType: PropertyValueTypeSingleSelect, - Required: Ptr(true), + Required: new(true), }, { - PropertyName: Ptr("service"), + PropertyName: new("service"), ValueType: PropertyValueTypeString, }, } @@ -222,13 +222,13 @@ func TestOrganizationsService_GetCustomProperty(t *testing.T) { } want := &CustomProperty{ - PropertyName: Ptr("name"), + PropertyName: new("name"), ValueType: PropertyValueTypeSingleSelect, - Required: Ptr(true), + Required: new(true), DefaultValue: "production", - Description: Ptr("Prod or dev environment"), + Description: new("Prod or dev environment"), AllowedValues: []string{"production", "development"}, - ValuesEditableBy: Ptr("org_actors"), + ValuesEditableBy: new("org_actors"), } if !cmp.Equal(property, want) { t.Errorf("Organizations.GetCustomProperty returned %+v, want %+v", property, want) @@ -268,24 +268,24 @@ func TestOrganizationsService_CreateOrUpdateCustomProperty(t *testing.T) { ctx := t.Context() property, _, err := client.Organizations.CreateOrUpdateCustomProperty(ctx, "o", "name", &CustomProperty{ ValueType: PropertyValueTypeSingleSelect, - Required: Ptr(true), + Required: new(true), DefaultValue: "production", - Description: Ptr("Prod or dev environment"), + Description: new("Prod or dev environment"), AllowedValues: []string{"production", "development"}, - ValuesEditableBy: Ptr("org_actors"), + ValuesEditableBy: new("org_actors"), }) if err != nil { t.Errorf("Organizations.CreateOrUpdateCustomProperty returned error: %v", err) } want := &CustomProperty{ - PropertyName: Ptr("name"), + PropertyName: new("name"), ValueType: PropertyValueTypeSingleSelect, - Required: Ptr(true), + Required: new(true), DefaultValue: "production", - Description: Ptr("Prod or dev environment"), + Description: new("Prod or dev environment"), AllowedValues: []string{"production", "development"}, - ValuesEditableBy: Ptr("org_actors"), + ValuesEditableBy: new("org_actors"), } if !cmp.Equal(property, want) { t.Errorf("Organizations.CreateOrUpdateCustomProperty returned %+v, want %+v", property, want) diff --git a/github/orgs_rules_test.go b/github/orgs_rules_test.go index 8d46b456c33..4b9c601b002 100644 --- a/github/orgs_rules_test.go +++ b/github/orgs_rules_test.go @@ -43,15 +43,15 @@ func TestOrganizationsService_ListAllRepositoryRulesets(t *testing.T) { } want := []*RepositoryRuleset{{ - ID: Ptr(int64(21)), + ID: new(int64(21)), Name: "test ruleset", - Target: Ptr(RulesetTargetBranch), - SourceType: Ptr(RulesetSourceTypeOrganization), + Target: new(RulesetTargetBranch), + SourceType: new(RulesetSourceTypeOrganization), Source: "o", Enforcement: "active", - NodeID: Ptr("nid"), + NodeID: new("nid"), Links: &RepositoryRulesetLinks{ - Self: &RepositoryRulesetLink{HRef: Ptr("https://api.github.com/orgs/o/rulesets/21")}, + Self: &RepositoryRulesetLink{HRef: new("https://api.github.com/orgs/o/rulesets/21")}, }, }} if !cmp.Equal(rulesets, want) { @@ -91,7 +91,7 @@ func TestOrganizationsService_ListAllRepositoryRulesets_ListOptions(t *testing.T } want := []*RepositoryRuleset{{ - ID: Ptr(int64(21)), + ID: new(int64(21)), }} if !cmp.Equal(rulesets, want) { t.Errorf("Organizations.ListAllRepositoryRulesets returned %+v, want %+v", rulesets, want) @@ -271,17 +271,17 @@ func TestOrganizationsService_CreateRepositoryRuleset_RepoNames(t *testing.T) { ctx := t.Context() ruleset, _, err := client.Organizations.CreateRepositoryRuleset(ctx, "o", RepositoryRuleset{ Name: "ruleset", - Target: Ptr(RulesetTargetBranch), + Target: new(RulesetTargetBranch), Enforcement: "active", BypassActors: []*BypassActor{ { - ActorID: Ptr(int64(234)), - ActorType: Ptr(BypassActorTypeTeam), + ActorID: new(int64(234)), + ActorType: new(BypassActorTypeTeam), }, { - ActorID: Ptr(int64(345)), - ActorType: Ptr(BypassActorTypeTeam), - BypassMode: Ptr(BypassModeExempt), + ActorID: new(int64(345)), + ActorType: new(BypassActorTypeTeam), + BypassMode: new(BypassModeExempt), }, }, Conditions: &RepositoryRulesetConditions{ @@ -292,7 +292,7 @@ func TestOrganizationsService_CreateRepositoryRuleset_RepoNames(t *testing.T) { RepositoryName: &RepositoryRulesetRepositoryNamesConditionParameters{ Include: []string{"important_repository", "another_important_repository"}, Exclude: []string{"unimportant_repository"}, - Protected: Ptr(true), + Protected: new(true), }, }, Rules: &RepositoryRulesetRules{ @@ -315,19 +315,19 @@ func TestOrganizationsService_CreateRepositoryRuleset_RepoNames(t *testing.T) { RequiredReviewThreadResolution: true, }, RequiredStatusChecks: &RequiredStatusChecksRuleParameters{ - DoNotEnforceOnCreate: Ptr(true), + DoNotEnforceOnCreate: new(true), RequiredStatusChecks: []*RuleStatusCheck{ { Context: "test", - IntegrationID: Ptr(int64(1)), + IntegrationID: new(int64(1)), }, }, StrictRequiredStatusChecksPolicy: true, }, NonFastForward: &EmptyRuleParameters{}, CommitMessagePattern: &PatternRuleParameters{ - Name: Ptr("avoid test commits"), - Negate: Ptr(true), + Name: new("avoid test commits"), + Negate: new(true), Operator: "starts_with", Pattern: "[test]", }, @@ -336,20 +336,20 @@ func TestOrganizationsService_CreateRepositoryRuleset_RepoNames(t *testing.T) { Pattern: "github", }, CommitterEmailPattern: &PatternRuleParameters{ - Name: Ptr("avoid commit emails"), - Negate: Ptr(true), + Name: new("avoid commit emails"), + Negate: new(true), Operator: "ends_with", Pattern: "abc", }, BranchNamePattern: &PatternRuleParameters{ - Name: Ptr("avoid branch names"), - Negate: Ptr(true), + Name: new("avoid branch names"), + Negate: new(true), Operator: "regex", Pattern: "github$", }, TagNamePattern: &PatternRuleParameters{ - Name: Ptr("avoid tag names"), - Negate: Ptr(true), + Name: new("avoid tag names"), + Negate: new(true), Operator: "contains", Pattern: "github", }, @@ -369,21 +369,21 @@ func TestOrganizationsService_CreateRepositoryRuleset_RepoNames(t *testing.T) { } want := &RepositoryRuleset{ - ID: Ptr(int64(21)), + ID: new(int64(21)), Name: "ruleset", - Target: Ptr(RulesetTargetBranch), - SourceType: Ptr(RulesetSourceTypeOrganization), + Target: new(RulesetTargetBranch), + SourceType: new(RulesetSourceTypeOrganization), Source: "o", Enforcement: "active", BypassActors: []*BypassActor{ { - ActorID: Ptr(int64(234)), - ActorType: Ptr(BypassActorTypeTeam), + ActorID: new(int64(234)), + ActorType: new(BypassActorTypeTeam), }, { - ActorID: Ptr(int64(345)), - ActorType: Ptr(BypassActorTypeTeam), - BypassMode: Ptr(BypassModeExempt), + ActorID: new(int64(345)), + ActorType: new(BypassActorTypeTeam), + BypassMode: new(BypassModeExempt), }, }, Conditions: &RepositoryRulesetConditions{ @@ -394,7 +394,7 @@ func TestOrganizationsService_CreateRepositoryRuleset_RepoNames(t *testing.T) { RepositoryName: &RepositoryRulesetRepositoryNamesConditionParameters{ Include: []string{"important_repository", "another_important_repository"}, Exclude: []string{"unimportant_repository"}, - Protected: Ptr(true), + Protected: new(true), }, }, Rules: &RepositoryRulesetRules{ @@ -417,19 +417,19 @@ func TestOrganizationsService_CreateRepositoryRuleset_RepoNames(t *testing.T) { RequiredReviewThreadResolution: true, }, RequiredStatusChecks: &RequiredStatusChecksRuleParameters{ - DoNotEnforceOnCreate: Ptr(true), + DoNotEnforceOnCreate: new(true), RequiredStatusChecks: []*RuleStatusCheck{ { Context: "test", - IntegrationID: Ptr(int64(1)), + IntegrationID: new(int64(1)), }, }, StrictRequiredStatusChecksPolicy: true, }, NonFastForward: &EmptyRuleParameters{}, CommitMessagePattern: &PatternRuleParameters{ - Name: Ptr("avoid test commits"), - Negate: Ptr(true), + Name: new("avoid test commits"), + Negate: new(true), Operator: "starts_with", Pattern: "[test]", }, @@ -438,20 +438,20 @@ func TestOrganizationsService_CreateRepositoryRuleset_RepoNames(t *testing.T) { Pattern: "github", }, CommitterEmailPattern: &PatternRuleParameters{ - Name: Ptr("avoid commit emails"), - Negate: Ptr(true), + Name: new("avoid commit emails"), + Negate: new(true), Operator: "ends_with", Pattern: "abc", }, BranchNamePattern: &PatternRuleParameters{ - Name: Ptr("avoid branch names"), - Negate: Ptr(true), + Name: new("avoid branch names"), + Negate: new(true), Operator: "regex", Pattern: "github$", }, TagNamePattern: &PatternRuleParameters{ - Name: Ptr("avoid tag names"), - Negate: Ptr(true), + Name: new("avoid tag names"), + Negate: new(true), Operator: "contains", Pattern: "github", }, @@ -635,12 +635,12 @@ func TestOrganizationsService_CreateRepositoryRuleset_RepoProperty(t *testing.T) ctx := t.Context() ruleset, _, err := client.Organizations.CreateRepositoryRuleset(ctx, "o", RepositoryRuleset{ Name: "ruleset", - Target: Ptr(RulesetTargetBranch), + Target: new(RulesetTargetBranch), Enforcement: "active", BypassActors: []*BypassActor{ { - ActorID: Ptr(int64(234)), - ActorType: Ptr(BypassActorTypeTeam), + ActorID: new(int64(234)), + ActorType: new(BypassActorTypeTeam), }, }, Conditions: &RepositoryRulesetConditions{ @@ -648,7 +648,7 @@ func TestOrganizationsService_CreateRepositoryRuleset_RepoProperty(t *testing.T) Include: []*RepositoryRulesetRepositoryPropertyTargetParameters{ { Name: "testIncludeProp", - Source: Ptr("custom"), + Source: new("custom"), PropertyValues: []string{"true"}, }, }, @@ -680,19 +680,19 @@ func TestOrganizationsService_CreateRepositoryRuleset_RepoProperty(t *testing.T) RequiredReviewThreadResolution: true, }, RequiredStatusChecks: &RequiredStatusChecksRuleParameters{ - DoNotEnforceOnCreate: Ptr(true), + DoNotEnforceOnCreate: new(true), RequiredStatusChecks: []*RuleStatusCheck{ { Context: "test", - IntegrationID: Ptr(int64(1)), + IntegrationID: new(int64(1)), }, }, StrictRequiredStatusChecksPolicy: true, }, NonFastForward: &EmptyRuleParameters{}, CommitMessagePattern: &PatternRuleParameters{ - Name: Ptr("avoid test commits"), - Negate: Ptr(true), + Name: new("avoid test commits"), + Negate: new(true), Operator: "starts_with", Pattern: "[test]", }, @@ -701,20 +701,20 @@ func TestOrganizationsService_CreateRepositoryRuleset_RepoProperty(t *testing.T) Pattern: "github", }, CommitterEmailPattern: &PatternRuleParameters{ - Name: Ptr("avoid commit emails"), - Negate: Ptr(true), + Name: new("avoid commit emails"), + Negate: new(true), Operator: "ends_with", Pattern: "abc", }, BranchNamePattern: &PatternRuleParameters{ - Name: Ptr("avoid branch names"), - Negate: Ptr(true), + Name: new("avoid branch names"), + Negate: new(true), Operator: "regex", Pattern: "github$", }, TagNamePattern: &PatternRuleParameters{ - Name: Ptr("avoid tag names"), - Negate: Ptr(true), + Name: new("avoid tag names"), + Negate: new(true), Operator: "contains", Pattern: "github", }, @@ -734,16 +734,16 @@ func TestOrganizationsService_CreateRepositoryRuleset_RepoProperty(t *testing.T) } want := &RepositoryRuleset{ - ID: Ptr(int64(21)), + ID: new(int64(21)), Name: "ruleset", - Target: Ptr(RulesetTargetBranch), - SourceType: Ptr(RulesetSourceTypeOrganization), + Target: new(RulesetTargetBranch), + SourceType: new(RulesetSourceTypeOrganization), Source: "o", Enforcement: "active", BypassActors: []*BypassActor{ { - ActorID: Ptr(int64(234)), - ActorType: Ptr(BypassActorTypeTeam), + ActorID: new(int64(234)), + ActorType: new(BypassActorTypeTeam), }, }, Conditions: &RepositoryRulesetConditions{ @@ -751,7 +751,7 @@ func TestOrganizationsService_CreateRepositoryRuleset_RepoProperty(t *testing.T) Include: []*RepositoryRulesetRepositoryPropertyTargetParameters{ { Name: "testIncludeProp", - Source: Ptr("custom"), + Source: new("custom"), PropertyValues: []string{"true"}, }, }, @@ -783,19 +783,19 @@ func TestOrganizationsService_CreateRepositoryRuleset_RepoProperty(t *testing.T) RequiredReviewThreadResolution: true, }, RequiredStatusChecks: &RequiredStatusChecksRuleParameters{ - DoNotEnforceOnCreate: Ptr(true), + DoNotEnforceOnCreate: new(true), RequiredStatusChecks: []*RuleStatusCheck{ { Context: "test", - IntegrationID: Ptr(int64(1)), + IntegrationID: new(int64(1)), }, }, StrictRequiredStatusChecksPolicy: true, }, NonFastForward: &EmptyRuleParameters{}, CommitMessagePattern: &PatternRuleParameters{ - Name: Ptr("avoid test commits"), - Negate: Ptr(true), + Name: new("avoid test commits"), + Negate: new(true), Operator: "starts_with", Pattern: "[test]", }, @@ -804,20 +804,20 @@ func TestOrganizationsService_CreateRepositoryRuleset_RepoProperty(t *testing.T) Pattern: "github", }, CommitterEmailPattern: &PatternRuleParameters{ - Name: Ptr("avoid commit emails"), - Negate: Ptr(true), + Name: new("avoid commit emails"), + Negate: new(true), Operator: "ends_with", Pattern: "abc", }, BranchNamePattern: &PatternRuleParameters{ - Name: Ptr("avoid branch names"), - Negate: Ptr(true), + Name: new("avoid branch names"), + Negate: new(true), Operator: "regex", Pattern: "github$", }, TagNamePattern: &PatternRuleParameters{ - Name: Ptr("avoid tag names"), - Negate: Ptr(true), + Name: new("avoid tag names"), + Negate: new(true), Operator: "contains", Pattern: "github", }, @@ -994,12 +994,12 @@ func TestOrganizationsService_CreateRepositoryRuleset_RepoIDs(t *testing.T) { ctx := t.Context() ruleset, _, err := client.Organizations.CreateRepositoryRuleset(ctx, "o", RepositoryRuleset{ Name: "ruleset", - Target: Ptr(RulesetTargetBranch), + Target: new(RulesetTargetBranch), Enforcement: "active", BypassActors: []*BypassActor{ { - ActorID: Ptr(int64(234)), - ActorType: Ptr(BypassActorTypeTeam), + ActorID: new(int64(234)), + ActorType: new(BypassActorTypeTeam), }, }, Conditions: &RepositoryRulesetConditions{ @@ -1031,19 +1031,19 @@ func TestOrganizationsService_CreateRepositoryRuleset_RepoIDs(t *testing.T) { RequiredReviewThreadResolution: true, }, RequiredStatusChecks: &RequiredStatusChecksRuleParameters{ - DoNotEnforceOnCreate: Ptr(true), + DoNotEnforceOnCreate: new(true), RequiredStatusChecks: []*RuleStatusCheck{ { Context: "test", - IntegrationID: Ptr(int64(1)), + IntegrationID: new(int64(1)), }, }, StrictRequiredStatusChecksPolicy: true, }, NonFastForward: &EmptyRuleParameters{}, CommitMessagePattern: &PatternRuleParameters{ - Name: Ptr("avoid test commits"), - Negate: Ptr(true), + Name: new("avoid test commits"), + Negate: new(true), Operator: "starts_with", Pattern: "[test]", }, @@ -1052,20 +1052,20 @@ func TestOrganizationsService_CreateRepositoryRuleset_RepoIDs(t *testing.T) { Pattern: "github", }, CommitterEmailPattern: &PatternRuleParameters{ - Name: Ptr("avoid commit emails"), - Negate: Ptr(true), + Name: new("avoid commit emails"), + Negate: new(true), Operator: "ends_with", Pattern: "abc", }, BranchNamePattern: &PatternRuleParameters{ - Name: Ptr("avoid branch names"), - Negate: Ptr(true), + Name: new("avoid branch names"), + Negate: new(true), Operator: "regex", Pattern: "github$", }, TagNamePattern: &PatternRuleParameters{ - Name: Ptr("avoid tag names"), - Negate: Ptr(true), + Name: new("avoid tag names"), + Negate: new(true), Operator: "contains", Pattern: "github", }, @@ -1085,16 +1085,16 @@ func TestOrganizationsService_CreateRepositoryRuleset_RepoIDs(t *testing.T) { } want := &RepositoryRuleset{ - ID: Ptr(int64(21)), + ID: new(int64(21)), Name: "ruleset", - Target: Ptr(RulesetTargetBranch), - SourceType: Ptr(RulesetSourceTypeOrganization), + Target: new(RulesetTargetBranch), + SourceType: new(RulesetSourceTypeOrganization), Source: "o", Enforcement: "active", BypassActors: []*BypassActor{ { - ActorID: Ptr(int64(234)), - ActorType: Ptr(BypassActorTypeTeam), + ActorID: new(int64(234)), + ActorType: new(BypassActorTypeTeam), }, }, Conditions: &RepositoryRulesetConditions{ @@ -1126,19 +1126,19 @@ func TestOrganizationsService_CreateRepositoryRuleset_RepoIDs(t *testing.T) { RequiredReviewThreadResolution: true, }, RequiredStatusChecks: &RequiredStatusChecksRuleParameters{ - DoNotEnforceOnCreate: Ptr(true), + DoNotEnforceOnCreate: new(true), RequiredStatusChecks: []*RuleStatusCheck{ { Context: "test", - IntegrationID: Ptr(int64(1)), + IntegrationID: new(int64(1)), }, }, StrictRequiredStatusChecksPolicy: true, }, NonFastForward: &EmptyRuleParameters{}, CommitMessagePattern: &PatternRuleParameters{ - Name: Ptr("avoid test commits"), - Negate: Ptr(true), + Name: new("avoid test commits"), + Negate: new(true), Operator: "starts_with", Pattern: "[test]", }, @@ -1147,20 +1147,20 @@ func TestOrganizationsService_CreateRepositoryRuleset_RepoIDs(t *testing.T) { Pattern: "github", }, CommitterEmailPattern: &PatternRuleParameters{ - Name: Ptr("avoid commit emails"), - Negate: Ptr(true), + Name: new("avoid commit emails"), + Negate: new(true), Operator: "ends_with", Pattern: "abc", }, BranchNamePattern: &PatternRuleParameters{ - Name: Ptr("avoid branch names"), - Negate: Ptr(true), + Name: new("avoid branch names"), + Negate: new(true), Operator: "regex", Pattern: "github$", }, TagNamePattern: &PatternRuleParameters{ - Name: Ptr("avoid tag names"), - Negate: Ptr(true), + Name: new("avoid tag names"), + Negate: new(true), Operator: "contains", Pattern: "github", }, @@ -1246,15 +1246,15 @@ func TestOrganizationsService_GetRepositoryRuleset(t *testing.T) { } want := &RepositoryRuleset{ - ID: Ptr(int64(21)), + ID: new(int64(21)), Name: "test ruleset", - Target: Ptr(RulesetTargetBranch), - SourceType: Ptr(RulesetSourceTypeOrganization), + Target: new(RulesetTargetBranch), + SourceType: new(RulesetSourceTypeOrganization), Source: "o", Enforcement: "active", - NodeID: Ptr("nid"), + NodeID: new("nid"), Links: &RepositoryRulesetLinks{ - Self: &RepositoryRulesetLink{HRef: Ptr("https://api.github.com/orgs/o/rulesets/21")}, + Self: &RepositoryRulesetLink{HRef: new("https://api.github.com/orgs/o/rulesets/21")}, }, Conditions: &RepositoryRulesetConditions{ RefName: &RepositoryRulesetRefConditionParameters{ @@ -1264,7 +1264,7 @@ func TestOrganizationsService_GetRepositoryRuleset(t *testing.T) { RepositoryName: &RepositoryRulesetRepositoryNamesConditionParameters{ Include: []string{"important_repository", "another_important_repository"}, Exclude: []string{"unimportant_repository"}, - Protected: Ptr(true), + Protected: new(true), }, }, Rules: &RepositoryRulesetRules{Creation: &EmptyRuleParameters{}}, @@ -1333,22 +1333,22 @@ func TestOrganizationsService_GetRepositoryRulesetWithRepoPropCondition(t *testi } want := &RepositoryRuleset{ - ID: Ptr(int64(21)), + ID: new(int64(21)), Name: "test ruleset", - Target: Ptr(RulesetTargetBranch), - SourceType: Ptr(RulesetSourceTypeOrganization), + Target: new(RulesetTargetBranch), + SourceType: new(RulesetSourceTypeOrganization), Source: "o", Enforcement: "active", - NodeID: Ptr("nid"), + NodeID: new("nid"), Links: &RepositoryRulesetLinks{ - Self: &RepositoryRulesetLink{HRef: Ptr("https://api.github.com/orgs/o/rulesets/21")}, + Self: &RepositoryRulesetLink{HRef: new("https://api.github.com/orgs/o/rulesets/21")}, }, Conditions: &RepositoryRulesetConditions{ RepositoryProperty: &RepositoryRulesetRepositoryPropertyConditionParameters{ Include: []*RepositoryRulesetRepositoryPropertyTargetParameters{ { Name: "testIncludeProp", - Source: Ptr("custom"), + Source: new("custom"), PropertyValues: []string{"true"}, }, }, @@ -1424,7 +1424,7 @@ func TestOrganizationsService_UpdateRepositoryRuleset(t *testing.T) { ctx := t.Context() rulesets, _, err := client.Organizations.UpdateRepositoryRuleset(ctx, "o", 21, RepositoryRuleset{ Name: "test ruleset", - Target: Ptr(RulesetTargetBranch), + Target: new(RulesetTargetBranch), Enforcement: "active", Conditions: &RepositoryRulesetConditions{ RefName: &RepositoryRulesetRefConditionParameters{ @@ -1434,7 +1434,7 @@ func TestOrganizationsService_UpdateRepositoryRuleset(t *testing.T) { RepositoryName: &RepositoryRulesetRepositoryNamesConditionParameters{ Include: []string{"important_repository", "another_important_repository"}, Exclude: []string{"unimportant_repository"}, - Protected: Ptr(true), + Protected: new(true), }, }, Rules: &RepositoryRulesetRules{Creation: &EmptyRuleParameters{}}, @@ -1444,15 +1444,15 @@ func TestOrganizationsService_UpdateRepositoryRuleset(t *testing.T) { } want := &RepositoryRuleset{ - ID: Ptr(int64(21)), + ID: new(int64(21)), Name: "test ruleset", - Target: Ptr(RulesetTargetBranch), - SourceType: Ptr(RulesetSourceTypeOrganization), + Target: new(RulesetTargetBranch), + SourceType: new(RulesetSourceTypeOrganization), Source: "o", Enforcement: "active", - NodeID: Ptr("nid"), + NodeID: new("nid"), Links: &RepositoryRulesetLinks{ - Self: &RepositoryRulesetLink{HRef: Ptr("https://api.github.com/orgs/o/rulesets/21")}, + Self: &RepositoryRulesetLink{HRef: new("https://api.github.com/orgs/o/rulesets/21")}, }, Conditions: &RepositoryRulesetConditions{ RefName: &RepositoryRulesetRefConditionParameters{ @@ -1462,7 +1462,7 @@ func TestOrganizationsService_UpdateRepositoryRuleset(t *testing.T) { RepositoryName: &RepositoryRulesetRepositoryNamesConditionParameters{ Include: []string{"important_repository", "another_important_repository"}, Exclude: []string{"unimportant_repository"}, - Protected: Ptr(true), + Protected: new(true), }, }, Rules: &RepositoryRulesetRules{Creation: &EmptyRuleParameters{}}, @@ -1527,14 +1527,14 @@ func TestOrganizationsService_UpdateRepositoryRulesetWithRepoProp(t *testing.T) ctx := t.Context() rulesets, _, err := client.Organizations.UpdateRepositoryRuleset(ctx, "o", 21, RepositoryRuleset{ Name: "test ruleset", - Target: Ptr(RulesetTargetBranch), + Target: new(RulesetTargetBranch), Enforcement: "active", Conditions: &RepositoryRulesetConditions{ RepositoryProperty: &RepositoryRulesetRepositoryPropertyConditionParameters{ Include: []*RepositoryRulesetRepositoryPropertyTargetParameters{ { Name: "testIncludeProp", - Source: Ptr("custom"), + Source: new("custom"), PropertyValues: []string{"true"}, }, }, @@ -1548,22 +1548,22 @@ func TestOrganizationsService_UpdateRepositoryRulesetWithRepoProp(t *testing.T) } want := &RepositoryRuleset{ - ID: Ptr(int64(21)), + ID: new(int64(21)), Name: "test ruleset", - Target: Ptr(RulesetTargetBranch), - SourceType: Ptr(RulesetSourceTypeOrganization), + Target: new(RulesetTargetBranch), + SourceType: new(RulesetSourceTypeOrganization), Source: "o", Enforcement: "active", - NodeID: Ptr("nid"), + NodeID: new("nid"), Links: &RepositoryRulesetLinks{ - Self: &RepositoryRulesetLink{HRef: Ptr("https://api.github.com/orgs/o/rulesets/21")}, + Self: &RepositoryRulesetLink{HRef: new("https://api.github.com/orgs/o/rulesets/21")}, }, Conditions: &RepositoryRulesetConditions{ RepositoryProperty: &RepositoryRulesetRepositoryPropertyConditionParameters{ Include: []*RepositoryRulesetRepositoryPropertyTargetParameters{ { Name: "testIncludeProp", - Source: Ptr("custom"), + Source: new("custom"), PropertyValues: []string{"true"}, }, }, diff --git a/github/orgs_security_managers_test.go b/github/orgs_security_managers_test.go index 7ddce4b2951..9b018237c14 100644 --- a/github/orgs_security_managers_test.go +++ b/github/orgs_security_managers_test.go @@ -28,7 +28,7 @@ func TestOrganizationsService_ListSecurityManagerTeams(t *testing.T) { t.Errorf("Organizations.ListSecurityManagerTeams returned error: %v", err) } - want := []*Team{{ID: Ptr(int64(1))}} + want := []*Team{{ID: new(int64(1))}} if !cmp.Equal(teams, want) { t.Errorf("Organizations.ListSecurityManagerTeams returned %+v, want %+v", teams, want) } diff --git a/github/orgs_test.go b/github/orgs_test.go index 2ea5ecf05ef..61f9c5834e8 100644 --- a/github/orgs_test.go +++ b/github/orgs_test.go @@ -30,7 +30,7 @@ func TestOrganizationsService_ListAll(t *testing.T) { t.Errorf("Organizations.ListAll returned error: %v", err) } - want := []*Organization{{ID: Ptr(int64(4314092))}} + want := []*Organization{{ID: new(int64(4314092))}} if !cmp.Equal(orgs, want) { t.Errorf("Organizations.ListAll returned %+v, want %+v", orgs, want) } @@ -60,7 +60,7 @@ func TestOrganizationsService_List_authenticatedUser(t *testing.T) { t.Errorf("Organizations.List returned error: %v", err) } - want := []*Organization{{ID: Ptr(int64(1))}, {ID: Ptr(int64(2))}} + want := []*Organization{{ID: new(int64(1))}, {ID: new(int64(2))}} if !cmp.Equal(orgs, want) { t.Errorf("Organizations.List returned %+v, want %+v", orgs, want) } @@ -97,7 +97,7 @@ func TestOrganizationsService_List_specifiedUser(t *testing.T) { t.Errorf("Organizations.List returned error: %v", err) } - want := []*Organization{{ID: Ptr(int64(1))}, {ID: Ptr(int64(2))}} + want := []*Organization{{ID: new(int64(1))}, {ID: new(int64(2))}} if !cmp.Equal(orgs, want) { t.Errorf("Organizations.List returned %+v, want %+v", orgs, want) } @@ -142,7 +142,7 @@ func TestOrganizationsService_Get(t *testing.T) { t.Errorf("Organizations.Get returned error: %v", err) } - want := &Organization{ID: Ptr(int64(1)), Login: Ptr("l"), URL: Ptr("u"), AvatarURL: Ptr("a"), Location: Ptr("l")} + want := &Organization{ID: new(int64(1)), Login: new("l"), URL: new("u"), AvatarURL: new("a"), Location: new("l")} if !cmp.Equal(org, want) { t.Errorf("Organizations.Get returned %+v, want %+v", org, want) } @@ -186,7 +186,7 @@ func TestOrganizationsService_GetByID(t *testing.T) { t.Fatalf("Organizations.GetByID returned error: %v", err) } - want := &Organization{ID: Ptr(int64(1)), Login: Ptr("l"), URL: Ptr("u"), AvatarURL: Ptr("a"), Location: Ptr("l")} + want := &Organization{ID: new(int64(1)), Login: new("l"), URL: new("u"), AvatarURL: new("a"), Location: new("l")} if !cmp.Equal(org, want) { t.Errorf("Organizations.GetByID returned %+v, want %+v", org, want) } @@ -210,7 +210,7 @@ func TestOrganizationsService_Edit(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - input := &Organization{Login: Ptr("l")} + input := &Organization{Login: new("l")} mux.HandleFunc("/orgs/o", func(w http.ResponseWriter, r *http.Request) { testHeader(t, r, "Accept", mediaTypeMemberAllowedRepoCreationTypePreview) @@ -226,7 +226,7 @@ func TestOrganizationsService_Edit(t *testing.T) { t.Errorf("Organizations.Edit returned error: %v", err) } - want := &Organization{ID: Ptr(int64(1))} + want := &Organization{ID: new(int64(1))} if !cmp.Equal(org, want) { t.Errorf("Organizations.Edit returned %+v, want %+v", org, want) } @@ -295,7 +295,7 @@ func TestOrganizationsService_ListInstallations(t *testing.T) { t.Errorf("Organizations.ListInstallations returned error: %v", err) } - want := &OrganizationInstallations{TotalCount: Ptr(1), Installations: []*Installation{{ID: Ptr(int64(1)), AppID: Ptr(int64(5))}}} + want := &OrganizationInstallations{TotalCount: new(1), Installations: []*Installation{{ID: new(int64(1)), AppID: new(int64(5))}}} if !cmp.Equal(apps, want) { t.Errorf("Organizations.ListInstallations returned %+v, want %+v", apps, want) } @@ -340,7 +340,7 @@ func TestOrganizationsService_ListInstallations_withListOptions(t *testing.T) { t.Errorf("Organizations.ListInstallations returned error: %v", err) } - want := &OrganizationInstallations{TotalCount: Ptr(2), Installations: []*Installation{{ID: Ptr(int64(2)), AppID: Ptr(int64(10))}}} + want := &OrganizationInstallations{TotalCount: new(2), Installations: []*Installation{{ID: new(int64(2)), AppID: new(int64(10))}}} if !cmp.Equal(apps, want) { t.Errorf("Organizations.ListInstallations returned %+v, want %+v", apps, want) } diff --git a/github/orgs_users_blocking_test.go b/github/orgs_users_blocking_test.go index 06165219152..1ac5b6491a1 100644 --- a/github/orgs_users_blocking_test.go +++ b/github/orgs_users_blocking_test.go @@ -33,7 +33,7 @@ func TestOrganizationsService_ListBlockedUsers(t *testing.T) { t.Errorf("Organizations.ListBlockedUsers returned error: %v", err) } - want := []*User{{Login: Ptr("octocat")}} + want := []*User{{Login: new("octocat")}} if !cmp.Equal(blockedUsers, want) { t.Errorf("Organizations.ListBlockedUsers returned %+v, want %+v", blockedUsers, want) } diff --git a/github/packages_test.go b/github/packages_test.go index 3a42ba998a4..67488a56960 100644 --- a/github/packages_test.go +++ b/github/packages_test.go @@ -108,10 +108,10 @@ func TestPackageVersion_GetBodyAsPackageVersionBody(t *testing.T) { }, wantValue: &PackageVersionBody{ Repo: &Repository{ - Name: Ptr("n"), + Name: new("n"), }, Info: &PackageVersionBodyInfo{ - Type: Ptr("t"), + Type: new("t"), }, }, wantOk: true, @@ -168,7 +168,7 @@ func TestPackageVersion_GetMetadata(t *testing.T) { }`), }, wantValue: &PackageMetadata{ - PackageType: Ptr("container"), + PackageType: new("container"), Container: &PackageContainerMetadata{ Tags: []string{"a"}, }, diff --git a/github/private_registries_test.go b/github/private_registries_test.go index ec0500ef7dd..be6081051b8 100644 --- a/github/private_registries_test.go +++ b/github/private_registries_test.go @@ -47,15 +47,15 @@ func TestPrivateRegistriesService_ListOrganizationPrivateRegistries(t *testing.T } want := &PrivateRegistries{ - TotalCount: Ptr(1), + TotalCount: new(1), Configurations: []*PrivateRegistry{ { - Name: Ptr("MAVEN_REPOSITORY_SECRET"), - RegistryType: Ptr(PrivateRegistryTypeMavenRepository), - Username: Ptr("monalisa"), + Name: new("MAVEN_REPOSITORY_SECRET"), + RegistryType: new(PrivateRegistryTypeMavenRepository), + Username: new("monalisa"), CreatedAt: refTimestamp(1136178000), UpdatedAt: refTimestamp(1136178001), - Visibility: Ptr(PrivateRegistryVisibilitySelected), + Visibility: new(PrivateRegistryVisibilitySelected), }, }, } @@ -91,9 +91,9 @@ func TestPrivateRegistriesService_CreateOrganizationPrivateRegistry(t *testing.T input := &CreateOrganizationPrivateRegistry{ RegistryType: PrivateRegistryTypeMavenRepository, URL: "https://example.com/OWNER/REPOSITORY", - Username: Ptr("monalisa"), - EncryptedValue: Ptr("encrypted_value"), - KeyID: Ptr("key_id"), + Username: new("monalisa"), + EncryptedValue: new("encrypted_value"), + KeyID: new("key_id"), Visibility: PrivateRegistryVisibilitySelected, SelectedRepositoryIDs: []int64{1, 2, 3}, } @@ -121,12 +121,12 @@ func TestPrivateRegistriesService_CreateOrganizationPrivateRegistry(t *testing.T } want := &PrivateRegistry{ - Name: Ptr("MAVEN_REPOSITORY_SECRET"), - RegistryType: Ptr(PrivateRegistryTypeMavenRepository), - Username: Ptr("monalisa"), + Name: new("MAVEN_REPOSITORY_SECRET"), + RegistryType: new(PrivateRegistryTypeMavenRepository), + Username: new("monalisa"), CreatedAt: refTimestamp(1136178000), UpdatedAt: refTimestamp(1136178001), - Visibility: Ptr(PrivateRegistryVisibilitySelected), + Visibility: new(PrivateRegistryVisibilitySelected), SelectedRepositoryIDs: []int64{1, 2, 3}, } if diff := cmp.Diff(want, privateRegistry); diff != "" { @@ -155,10 +155,10 @@ func TestPrivateRegistriesService_CreateOrganizationPrivateRegistry_OIDC(t *test input := &CreateOrganizationPrivateRegistry{ RegistryType: PrivateRegistryTypeMavenRepository, URL: "https://example.com/maven", - AuthType: Ptr("oidc_azure"), - TenantID: Ptr("my-tenant-id"), - ClientID: Ptr("my-client-id"), - ReplacesBase: Ptr(true), + AuthType: new("oidc_azure"), + TenantID: new("my-tenant-id"), + ClientID: new("my-client-id"), + ReplacesBase: new(true), Visibility: PrivateRegistryVisibilitySelected, SelectedRepositoryIDs: []int64{1, 2, 3}, } @@ -185,11 +185,11 @@ func TestPrivateRegistriesService_CreateOrganizationPrivateRegistry_OIDC(t *test } want := &PrivateRegistry{ - Name: Ptr("MAVEN_REPOSITORY_SECRET"), - RegistryType: Ptr(PrivateRegistryTypeMavenRepository), + Name: new("MAVEN_REPOSITORY_SECRET"), + RegistryType: new(PrivateRegistryTypeMavenRepository), CreatedAt: refTimestamp(1136178000), UpdatedAt: refTimestamp(1136178001), - Visibility: Ptr(PrivateRegistryVisibilitySelected), + Visibility: new(PrivateRegistryVisibilitySelected), SelectedRepositoryIDs: []int64{1, 2, 3}, } if diff := cmp.Diff(want, privateRegistry); diff != "" { @@ -202,14 +202,14 @@ func TestPrivateRegistries_UpdateOrganizationPrivateRegistry_OIDC(t *testing.T) client, mux, _ := setup(t) input := &UpdateOrganizationPrivateRegistry{ - AuthType: Ptr("oidc_aws"), - AWSRegion: Ptr("us-east-1"), - AccountID: Ptr("123456789012"), - RoleName: Ptr("my-role"), - Domain: Ptr("my-domain"), - DomainOwner: Ptr("123456789012"), - Audience: Ptr("example.com"), - Visibility: Ptr(PrivateRegistryVisibilitySelected), + AuthType: new("oidc_aws"), + AWSRegion: new("us-east-1"), + AccountID: new("123456789012"), + RoleName: new("my-role"), + Domain: new("my-domain"), + DomainOwner: new("123456789012"), + Audience: new("example.com"), + Visibility: new(PrivateRegistryVisibilitySelected), } mux.HandleFunc("/orgs/o/private-registries/AWS_REGISTRY_SECRET", func(w http.ResponseWriter, r *http.Request) { @@ -233,10 +233,10 @@ func TestPrivateRegistriesService_CreateOrganizationPrivateRegistry_OIDCJFrog(t input := &CreateOrganizationPrivateRegistry{ RegistryType: PrivateRegistryTypeNpmRegistry, URL: "https://example.com/npm", - AuthType: Ptr("oidc_jfrog"), - JFrogOIDCProviderName: Ptr("my-jfrog-provider"), - Audience: Ptr("jfrog"), - IdentityMappingName: Ptr("my-identity-mapping"), + AuthType: new("oidc_jfrog"), + JFrogOIDCProviderName: new("my-jfrog-provider"), + Audience: new("jfrog"), + IdentityMappingName: new("my-identity-mapping"), Visibility: PrivateRegistryVisibilityPrivate, } @@ -261,11 +261,11 @@ func TestPrivateRegistriesService_CreateOrganizationPrivateRegistry_OIDCJFrog(t } want := &PrivateRegistry{ - Name: Ptr("NPM_REGISTRY_SECRET"), - RegistryType: Ptr(PrivateRegistryTypeNpmRegistry), + Name: new("NPM_REGISTRY_SECRET"), + RegistryType: new(PrivateRegistryTypeNpmRegistry), CreatedAt: refTimestamp(1136178000), UpdatedAt: refTimestamp(1136178001), - Visibility: Ptr(PrivateRegistryVisibilityPrivate), + Visibility: new(PrivateRegistryVisibilityPrivate), } if diff := cmp.Diff(want, privateRegistry); diff != "" { t.Errorf("PrivateRegistries.CreateOrganizationPrivateRegistry (OIDC JFrog) mismatch (-want +got):\\n%v", diff) @@ -291,8 +291,8 @@ func TestPrivateRegistriesService_GetOrganizationPrivateRegistriesPublicKey(t *t } want := &PublicKey{ - KeyID: Ptr("0123456789"), - Key: Ptr("public_key"), + KeyID: new("0123456789"), + Key: new("public_key"), } if diff := cmp.Diff(want, publicKey); diff != "" { t.Errorf("PrivateRegistries.GetOrganizationPrivateRegistriesPublicKey mismatch (-want +got):\\n%v", diff) @@ -336,12 +336,12 @@ func TestPrivateRegistriesService_GetOrganizationPrivateRegistry(t *testing.T) { } want := &PrivateRegistry{ - Name: Ptr("MAVEN_REPOSITORY_SECRET"), - RegistryType: Ptr(PrivateRegistryTypeMavenRepository), - Username: Ptr("monalisa"), + Name: new("MAVEN_REPOSITORY_SECRET"), + RegistryType: new(PrivateRegistryTypeMavenRepository), + Username: new("monalisa"), CreatedAt: refTimestamp(1136178000), UpdatedAt: refTimestamp(1136178001), - Visibility: Ptr(PrivateRegistryVisibilitySelected), + Visibility: new(PrivateRegistryVisibilitySelected), } if diff := cmp.Diff(want, privateRegistry); diff != "" { t.Errorf("PrivateRegistries.GetOrganizationPrivateRegistry mismatch (-want +got):\\n%v", diff) @@ -366,10 +366,10 @@ func TestPrivateRegistries_UpdateOrganizationPrivateRegistry(t *testing.T) { client, mux, _ := setup(t) input := &UpdateOrganizationPrivateRegistry{ - Username: Ptr("monalisa"), - EncryptedValue: Ptr("encrypted_value"), - KeyID: Ptr("key_id"), - Visibility: Ptr(PrivateRegistryVisibilitySelected), + Username: new("monalisa"), + EncryptedValue: new("encrypted_value"), + KeyID: new("key_id"), + Visibility: new(PrivateRegistryVisibilitySelected), } mux.HandleFunc("/orgs/o/private-registries/MAVEN_REPOSITORY_SECRET", func(w http.ResponseWriter, r *http.Request) { diff --git a/github/projects_test.go b/github/projects_test.go index 129fbfe17f5..80b5b96008a 100644 --- a/github/projects_test.go +++ b/github/projects_test.go @@ -599,7 +599,7 @@ func TestProjectsService_AddOrganizationProjectItem(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - input := &AddProjectItemOptions{Type: Ptr(ProjectV2ItemContentType("Issue")), ID: Ptr(int64(99))} + input := &AddProjectItemOptions{Type: new(ProjectV2ItemContentType("Issue")), ID: new(int64(99))} mux.HandleFunc("/orgs/o/projectsV2/1/items", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "POST") @@ -628,7 +628,7 @@ func TestProjectsService_AddProjectItemForOrg_error(t *testing.T) { ctx := t.Context() const methodName = "AddOrganizationProjectItem" testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { - got, resp, err := client.Projects.AddOrganizationProjectItem(ctx, "o", 1, &AddProjectItemOptions{Type: Ptr(ProjectV2ItemContentType("Issue")), ID: Ptr(int64(1))}) + got, resp, err := client.Projects.AddOrganizationProjectItem(ctx, "o", 1, &AddProjectItemOptions{Type: new(ProjectV2ItemContentType("Issue")), ID: new(int64(1))}) if got != nil { t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got) } @@ -717,7 +717,7 @@ func TestProjectsService_GetOrganizationProjectItem_WithFieldsOption(t *testing. func TestProjectsService_UpdateOrganizationProjectItem(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - input := &UpdateProjectItemOptions{Archived: Ptr(true)} + input := &UpdateProjectItemOptions{Archived: new(true)} mux.HandleFunc("/orgs/o/projectsV2/1/items/17", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "PATCH") testJSONBody(t, r, input) @@ -736,7 +736,7 @@ func TestProjectsService_UpdateOrganizationProjectItem(t *testing.T) { func TestProjectsService_UpdateOrganizationProjectItem_error(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - input := &UpdateProjectItemOptions{Archived: Ptr(true)} + input := &UpdateProjectItemOptions{Archived: new(true)} mux.HandleFunc("/orgs/o/projectsV2/1/items/17", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "PATCH") testJSONBody(t, r, input) @@ -861,7 +861,7 @@ func TestProjectsService_ListUserProjectItems_error(t *testing.T) { func TestProjectsService_AddUserProjectItem(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - input := &AddProjectItemOptions{Type: Ptr(ProjectV2ItemContentType("PullRequest")), ID: Ptr(int64(123))} + input := &AddProjectItemOptions{Type: new(ProjectV2ItemContentType("PullRequest")), ID: new(int64(123))} mux.HandleFunc("/users/u/projectsV2/2/items", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "POST") testJSONBody(t, r, input) @@ -887,7 +887,7 @@ func TestProjectsService_AddUserProjectItem_error(t *testing.T) { ctx := t.Context() const methodName = "AddUserProjectItem" testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { - got, resp, err := client.Projects.AddUserProjectItem(ctx, "u", 2, &AddProjectItemOptions{Type: Ptr(ProjectV2ItemContentType("Issue")), ID: Ptr(int64(5))}) + got, resp, err := client.Projects.AddUserProjectItem(ctx, "u", 2, &AddProjectItemOptions{Type: new(ProjectV2ItemContentType("Issue")), ID: new(int64(5))}) if got != nil { t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got) } @@ -976,7 +976,7 @@ func TestProjectsService_GetUserProjectItem_WithFieldsOption(t *testing.T) { func TestProjectsService_UpdateUserProjectItem(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - input := &UpdateProjectItemOptions{Archived: Ptr(false)} + input := &UpdateProjectItemOptions{Archived: new(false)} mux.HandleFunc("/users/u/projectsV2/2/items/55", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "PATCH") testJSONBody(t, r, input) @@ -1002,7 +1002,7 @@ func TestProjectsService_UpdateUserProjectItem_error(t *testing.T) { ctx := t.Context() const methodName = "UpdateUserProjectItem" testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { - got, resp, err := client.Projects.UpdateUserProjectItem(ctx, "u", 2, 55, &UpdateProjectItemOptions{Archived: Ptr(false)}) + got, resp, err := client.Projects.UpdateUserProjectItem(ctx, "u", 2, 55, &UpdateProjectItemOptions{Archived: new(false)}) if got != nil { t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got) } @@ -1079,19 +1079,19 @@ func TestProjectV2Item_UnmarshalJSON_Issue(t *testing.T) { t.Parallel() item := ProjectV2Item{ - ID: Ptr(int64(123)), - NodeID: Ptr("PVTI_test"), - ContentType: Ptr(ProjectV2ItemContentTypeIssue), + ID: new(int64(123)), + NodeID: new("PVTI_test"), + ContentType: new(ProjectV2ItemContentTypeIssue), Content: &ProjectV2ItemContent{ Issue: &Issue{ - ID: Ptr(int64(456)), - Number: Ptr(10), - Title: Ptr("Test Issue"), - State: Ptr("open"), - Body: Ptr("Issue body"), + ID: new(int64(456)), + Number: new(10), + Title: new("Test Issue"), + State: new("open"), + Body: new("Issue body"), Repository: &Repository{ - ID: Ptr(int64(789)), - Name: Ptr("test-repo"), + ID: new(int64(789)), + Name: new("test-repo"), }, }, }, @@ -1123,24 +1123,24 @@ func TestProjectV2Item_UnmarshalJSON_PullRequest(t *testing.T) { t.Parallel() item := ProjectV2Item{ - ID: Ptr(int64(124)), - NodeID: Ptr("PVTI_pr"), - ContentType: Ptr(ProjectV2ItemContentTypePullRequest), + ID: new(int64(124)), + NodeID: new("PVTI_pr"), + ContentType: new(ProjectV2ItemContentTypePullRequest), Content: &ProjectV2ItemContent{ PullRequest: &PullRequest{ - ID: Ptr(int64(457)), - Number: Ptr(20), - Title: Ptr("Test PR"), - State: Ptr("closed"), - Merged: Ptr(true), - MergeCommitSHA: Ptr("abc123"), + ID: new(int64(457)), + Number: new(20), + Title: new("Test PR"), + State: new("closed"), + Merged: new(true), + MergeCommitSHA: new("abc123"), Head: &PullRequestBranch{ - Ref: Ptr("feature-branch"), - SHA: Ptr("def456"), + Ref: new("feature-branch"), + SHA: new("def456"), }, Base: &PullRequestBranch{ - Ref: Ptr("main"), - SHA: Ptr("ghi789"), + Ref: new("main"), + SHA: new("ghi789"), }, }, }, @@ -1177,15 +1177,15 @@ func TestProjectV2Item_UnmarshalJSON_DraftIssue(t *testing.T) { t.Parallel() item := ProjectV2Item{ - ID: Ptr(int64(125)), - NodeID: Ptr("PVTI_draft"), - ContentType: Ptr(ProjectV2ItemContentTypeDraftIssue), + ID: new(int64(125)), + NodeID: new("PVTI_draft"), + ContentType: new(ProjectV2ItemContentTypeDraftIssue), Content: &ProjectV2ItemContent{ DraftIssue: &ProjectV2DraftIssue{ - ID: Ptr(int64(458)), - NodeID: Ptr("DI_test"), - Title: Ptr("Draft Issue Title"), - Body: Ptr("Draft issue body content"), + ID: new(int64(458)), + NodeID: new("DI_test"), + Title: new("Draft Issue Title"), + Body: new("Draft issue body content"), }, }, CreatedAt: &referenceTimestamp, @@ -1211,9 +1211,9 @@ func TestProjectV2Item_UnmarshalJSON_NullContent(t *testing.T) { t.Parallel() item := ProjectV2Item{ - ID: Ptr(int64(126)), - NodeID: Ptr("PVTI_null"), - ContentType: Ptr(ProjectV2ItemContentTypeIssue), + ID: new(int64(126)), + NodeID: new("PVTI_null"), + ContentType: new(ProjectV2ItemContentTypeIssue), Content: nil, // Content is null } @@ -1240,8 +1240,8 @@ func TestProjectV2Item_UnmarshalJSON_MissingContentType(t *testing.T) { }` item := ProjectV2Item{ - ID: Ptr(int64(127)), - NodeID: Ptr("PVTI_no_type"), + ID: new(int64(127)), + NodeID: new("PVTI_no_type"), Content: nil, } @@ -1271,15 +1271,15 @@ func TestProjectV2Item_Marshal_Issue(t *testing.T) { testJSONMarshal(t, &ProjectV2Item{}, "{}") item := &ProjectV2Item{ - ContentType: Ptr(ProjectV2ItemContentTypeIssue), + ContentType: new(ProjectV2ItemContentTypeIssue), Content: &ProjectV2ItemContent{ Issue: &Issue{ - Number: Ptr(42), - Title: Ptr("Bug report"), - State: Ptr("open"), + Number: new(42), + Title: new("Bug report"), + State: new("open"), }, }, - ID: Ptr(int64(123)), + ID: new(int64(123)), } want := `{ @@ -1300,15 +1300,15 @@ func TestProjectV2Item_Marshal_PullRequest(t *testing.T) { testJSONMarshal(t, ProjectV2Item{}, "{}") item := ProjectV2Item{ - ContentType: Ptr(ProjectV2ItemContentTypePullRequest), + ContentType: new(ProjectV2ItemContentTypePullRequest), Content: &ProjectV2ItemContent{ PullRequest: &PullRequest{ - Number: Ptr(99), - Title: Ptr("Feature addition"), - State: Ptr("closed"), + Number: new(99), + Title: new("Feature addition"), + State: new("closed"), }, }, - ID: Ptr(int64(456)), + ID: new(int64(456)), } want := `{ @@ -1329,14 +1329,14 @@ func TestProjectV2Item_Marshal_DraftIssue(t *testing.T) { testJSONMarshal(t, &ProjectV2Item{}, "{}") item := &ProjectV2Item{ - ContentType: Ptr(ProjectV2ItemContentTypeDraftIssue), + ContentType: new(ProjectV2ItemContentTypeDraftIssue), Content: &ProjectV2ItemContent{ DraftIssue: &ProjectV2DraftIssue{ - Title: Ptr("Draft task"), - Body: Ptr("Work in progress"), + Title: new("Draft task"), + Body: new("Work in progress"), }, }, - ID: Ptr(int64(789)), + ID: new(int64(789)), } want := `{ @@ -1355,9 +1355,9 @@ func TestProjectV2Item_Marshal_MissingContent(t *testing.T) { t.Parallel() item := &ProjectV2Item{ - ContentType: Ptr(ProjectV2ItemContentTypeIssue), + ContentType: new(ProjectV2ItemContentTypeIssue), Content: &ProjectV2ItemContent{}, - ID: Ptr(int64(789)), + ID: new(int64(789)), } want := `{ @@ -1377,9 +1377,9 @@ func TestProjectV2ItemContent_Marshal(t *testing.T) { content := ProjectV2ItemContent{ Issue: &Issue{ - Number: Ptr(42), - Title: Ptr("Bug report"), - State: Ptr("open"), + Number: new(42), + Title: new("Bug report"), + State: new("open"), }, } @@ -1398,9 +1398,9 @@ func TestProjectV2ItemContent_Marshal(t *testing.T) { content := ProjectV2ItemContent{ PullRequest: &PullRequest{ - Number: Ptr(99), - Title: Ptr("Feature addition"), - State: Ptr("closed"), + Number: new(99), + Title: new("Feature addition"), + State: new("closed"), }, } @@ -1419,8 +1419,8 @@ func TestProjectV2ItemContent_Marshal(t *testing.T) { content := ProjectV2ItemContent{ DraftIssue: &ProjectV2DraftIssue{ - Title: Ptr("Draft task"), - Body: Ptr("Work in progress"), + Title: new("Draft task"), + Body: new("Work in progress"), }, } @@ -1438,7 +1438,7 @@ func TestProjectsService_CreateOrganizationProjectDraftItem(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - input := CreateProjectV2DraftItemRequest{Title: "My draft", Body: Ptr("Draft body")} + input := CreateProjectV2DraftItemRequest{Title: "My draft", Body: new("Draft body")} mux.HandleFunc("/orgs/o/projectsV2/1/drafts", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "POST") @@ -1451,7 +1451,7 @@ func TestProjectsService_CreateOrganizationProjectDraftItem(t *testing.T) { if err != nil { t.Fatalf("Projects.CreateOrganizationProjectDraftItem returned error: %v", err) } - want := &ProjectV2Item{ID: Ptr(int64(42)), NodeID: Ptr("PVTI_draft"), ContentType: Ptr(ProjectV2ItemContentTypeDraftIssue)} + want := &ProjectV2Item{ID: new(int64(42)), NodeID: new("PVTI_draft"), ContentType: new(ProjectV2ItemContentTypeDraftIssue)} if diff := cmp.Diff(want, item); diff != "" { t.Errorf("Projects.CreateOrganizationProjectDraftItem mismatch (-want +got):\n%v", diff) } @@ -1487,7 +1487,7 @@ func TestProjectsService_CreateUserProjectDraftItem(t *testing.T) { if err != nil { t.Fatalf("Projects.CreateUserProjectDraftItem returned error: %v", err) } - want := &ProjectV2Item{ID: Ptr(int64(43)), NodeID: Ptr("PVTI_draft_u"), ContentType: Ptr(ProjectV2ItemContentTypeDraftIssue)} + want := &ProjectV2Item{ID: new(int64(43)), NodeID: new("PVTI_draft_u"), ContentType: new(ProjectV2ItemContentTypeDraftIssue)} if diff := cmp.Diff(want, item); diff != "" { t.Errorf("Projects.CreateUserProjectDraftItem mismatch (-want +got):\n%v", diff) } @@ -1507,11 +1507,11 @@ func TestProjectsService_AddOrganizationProjectField(t *testing.T) { client, mux, _ := setup(t) input := AddProjectV2FieldRequest{ - Name: Ptr("Priority"), - DataType: Ptr("single_select"), + Name: new("Priority"), + DataType: new("single_select"), SingleSelectOptions: []*ProjectV2FieldSingleSelectOption{ - {Name: "High", Color: Ptr("RED"), Description: Ptr("Urgent")}, - {Name: "Low", Color: Ptr("GRAY")}, + {Name: "High", Color: new("RED"), Description: new("Urgent")}, + {Name: "Low", Color: new("GRAY")}, }, } @@ -1526,7 +1526,7 @@ func TestProjectsService_AddOrganizationProjectField(t *testing.T) { if err != nil { t.Fatalf("Projects.AddOrganizationProjectField returned error: %v", err) } - want := &ProjectV2Field{ID: Ptr(int64(7)), Name: Ptr("Priority"), DataType: Ptr("single_select")} + want := &ProjectV2Field{ID: new(int64(7)), Name: new("Priority"), DataType: new("single_select")} if diff := cmp.Diff(want, field); diff != "" { t.Errorf("Projects.AddOrganizationProjectField mismatch (-want +got):\n%v", diff) } @@ -1550,13 +1550,13 @@ func TestProjectsService_AddUserProjectField(t *testing.T) { client, mux, _ := setup(t) input := AddProjectV2FieldRequest{ - Name: Ptr("Sprint"), - DataType: Ptr("iteration"), + Name: new("Sprint"), + DataType: new("iteration"), IterationConfiguration: &ProjectV2FieldIterationConfiguration{ - StartDate: Ptr("2026-01-01"), - Duration: Ptr(14), + StartDate: new("2026-01-01"), + Duration: new(14), Iterations: []*ProjectV2FieldIterationConfigurationIteration{ - {Title: Ptr("Sprint 1"), StartDate: Ptr("2026-01-01"), Duration: Ptr(14)}, + {Title: new("Sprint 1"), StartDate: new("2026-01-01"), Duration: new(14)}, }, }, } @@ -1572,7 +1572,7 @@ func TestProjectsService_AddUserProjectField(t *testing.T) { if err != nil { t.Fatalf("Projects.AddUserProjectField returned error: %v", err) } - want := &ProjectV2Field{ID: Ptr(int64(8)), Name: Ptr("Sprint"), DataType: Ptr("iteration")} + want := &ProjectV2Field{ID: new(int64(8)), Name: new("Sprint"), DataType: new("iteration")} if diff := cmp.Diff(want, field); diff != "" { t.Errorf("Projects.AddUserProjectField mismatch (-want +got):\n%v", diff) } @@ -1598,7 +1598,7 @@ func TestProjectsService_CreateOrganizationProjectView(t *testing.T) { input := CreateProjectV2ViewRequest{ Name: "My board", Layout: "board", - Filter: Ptr("is:open"), + Filter: new("is:open"), VisibleFields: []int64{1, 2, 3}, } @@ -1621,8 +1621,8 @@ func TestProjectsService_CreateOrganizationProjectView(t *testing.T) { Name: "My board", Layout: "board", SortBy: []*ProjectV2ViewSortBy{ - {FieldID: Ptr(int64(9007199254740993)), Direction: Ptr("asc")}, - {FieldID: Ptr(int64(456)), Direction: Ptr("desc")}, + {FieldID: new(int64(9007199254740993)), Direction: new("asc")}, + {FieldID: new(int64(456)), Direction: new("desc")}, }, } if diff := cmp.Diff(want, view); diff != "" { @@ -1691,7 +1691,7 @@ func TestProjectsService_ListOrganizationProjectViewItems(t *testing.T) { if err != nil { t.Fatalf("Projects.ListOrganizationProjectViewItems returned error: %v", err) } - want := []*ProjectV2Item{{ID: Ptr(int64(21)), NodeID: Ptr("PVTI_view_item")}} + want := []*ProjectV2Item{{ID: new(int64(21)), NodeID: new("PVTI_view_item")}} if diff := cmp.Diff(want, items); diff != "" { t.Errorf("Projects.ListOrganizationProjectViewItems mismatch (-want +got):\n%v", diff) } @@ -1726,7 +1726,7 @@ func TestProjectsService_ListUserProjectViewItems(t *testing.T) { if err != nil { t.Fatalf("Projects.ListUserProjectViewItems returned error: %v", err) } - want := []*ProjectV2Item{{ID: Ptr(int64(22)), NodeID: Ptr("PVTI_view_item_u")}} + want := []*ProjectV2Item{{ID: new(int64(22)), NodeID: new("PVTI_view_item_u")}} if diff := cmp.Diff(want, items); diff != "" { t.Errorf("Projects.ListUserProjectViewItems mismatch (-want +got):\n%v", diff) } @@ -1753,8 +1753,8 @@ func TestProjectV2ViewSortBy_UnmarshalJSON(t *testing.T) { // The second element uses a string field_id, which the OpenAPI schema // permits. The first exceeds 2^53 to confirm int64 (not float64) decoding. want := []*ProjectV2ViewSortBy{ - {FieldID: Ptr(int64(9007199254740993)), Direction: Ptr("asc")}, - {FieldID: Ptr(int64(456)), Direction: Ptr("desc")}, + {FieldID: new(int64(9007199254740993)), Direction: new("asc")}, + {FieldID: new(int64(456)), Direction: new("desc")}, } testJSONUnmarshalOnly(t, want, `[[9007199254740993,"asc"],["456","desc"]]`) }) @@ -1801,7 +1801,7 @@ func TestProjectV2ViewSortBy_UnmarshalJSON(t *testing.T) { t.Run("round trips through MarshalJSON", func(t *testing.T) { t.Parallel() - in := &ProjectV2ViewSortBy{FieldID: Ptr(int64(9007199254740993)), Direction: Ptr("asc")} + in := &ProjectV2ViewSortBy{FieldID: new(int64(9007199254740993)), Direction: new("asc")} testJSONMarshal(t, in, `[9007199254740993,"asc"]`) }) } diff --git a/github/pulls_comments_test.go b/github/pulls_comments_test.go index 1171b6bf2d7..a8d18ebf590 100644 --- a/github/pulls_comments_test.go +++ b/github/pulls_comments_test.go @@ -43,7 +43,7 @@ func TestPullRequestsService_ListComments_allPulls(t *testing.T) { t.Errorf("PullRequests.ListComments returned error: %v", err) } - want := []*PullRequestComment{{ID: Ptr(int64(1))}} + want := []*PullRequestComment{{ID: new(int64(1))}} if !cmp.Equal(pulls, want) { t.Errorf("PullRequests.ListComments returned %+v, want %+v", pulls, want) } @@ -80,7 +80,7 @@ func TestPullRequestsService_ListComments_specificPull(t *testing.T) { t.Errorf("PullRequests.ListComments returned error: %v", err) } - want := []*PullRequestComment{{ID: Ptr(int64(1)), PullRequestReviewID: Ptr(int64(42))}} + want := []*PullRequestComment{{ID: new(int64(1)), PullRequestReviewID: new(int64(42))}} if !cmp.Equal(pulls, want) { t.Errorf("PullRequests.ListComments returned %+v, want %+v", pulls, want) } @@ -112,7 +112,7 @@ func TestPullRequestsService_GetComment(t *testing.T) { t.Errorf("PullRequests.GetComment returned error: %v", err) } - want := &PullRequestComment{ID: Ptr(int64(1))} + want := &PullRequestComment{ID: new(int64(1))} if !cmp.Equal(comment, want) { t.Errorf("PullRequests.GetComment returned %+v, want %+v", comment, want) } @@ -145,7 +145,7 @@ func TestPullRequestsService_CreateComment(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - input := &PullRequestComment{Body: Ptr("b")} + input := &PullRequestComment{Body: new("b")} wantAcceptHeaders := []string{mediaTypeReactionsPreview, mediaTypeMultiLineCommentsPreview} mux.HandleFunc("/repos/o/r/pulls/1/comments", func(w http.ResponseWriter, r *http.Request) { @@ -161,7 +161,7 @@ func TestPullRequestsService_CreateComment(t *testing.T) { t.Errorf("PullRequests.CreateComment returned error: %v", err) } - want := &PullRequestComment{ID: Ptr(int64(1))} + want := &PullRequestComment{ID: new(int64(1))} if !cmp.Equal(comment, want) { t.Errorf("PullRequests.CreateComment returned %+v, want %+v", comment, want) } @@ -194,7 +194,7 @@ func TestPullRequestsService_CreateCommentInReplyTo(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - input := &PullRequestComment{Body: Ptr("b")} + input := &PullRequestComment{Body: new("b")} mux.HandleFunc("/repos/o/r/pulls/1/comments", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "POST") @@ -208,7 +208,7 @@ func TestPullRequestsService_CreateCommentInReplyTo(t *testing.T) { t.Errorf("PullRequests.CreateCommentInReplyTo returned error: %v", err) } - want := &PullRequestComment{ID: Ptr(int64(1))} + want := &PullRequestComment{ID: new(int64(1))} if !cmp.Equal(comment, want) { t.Errorf("PullRequests.CreateCommentInReplyTo returned %+v, want %+v", comment, want) } @@ -232,7 +232,7 @@ func TestPullRequestsService_EditComment(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - input := &PullRequestComment{Body: Ptr("b")} + input := &PullRequestComment{Body: new("b")} mux.HandleFunc("/repos/o/r/pulls/comments/1", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "PATCH") @@ -246,7 +246,7 @@ func TestPullRequestsService_EditComment(t *testing.T) { t.Errorf("PullRequests.EditComment returned error: %v", err) } - want := &PullRequestComment{ID: Ptr(int64(1))} + want := &PullRequestComment{ID: new(int64(1))} if !cmp.Equal(comment, want) { t.Errorf("PullRequests.EditComment returned %+v, want %+v", comment, want) } diff --git a/github/pulls_reviewers_test.go b/github/pulls_reviewers_test.go index 8feaefd309c..23f05a4acca 100644 --- a/github/pulls_reviewers_test.go +++ b/github/pulls_reviewers_test.go @@ -31,7 +31,7 @@ func TestRequestReviewers(t *testing.T) { if err != nil { t.Errorf("PullRequests.RequestReviewers returned error: %v", err) } - want := &PullRequest{Number: Ptr(1)} + want := &PullRequest{Number: new(1)} if !cmp.Equal(got, want) { t.Errorf("PullRequests.RequestReviewers returned %+v, want %+v", got, want) } @@ -115,14 +115,14 @@ func TestListReviewers(t *testing.T) { want := &Reviewers{ Users: []*User{ { - Login: Ptr("octocat"), - ID: Ptr(int64(1)), + Login: new("octocat"), + ID: new(int64(1)), }, }, Teams: []*Team{ { - ID: Ptr(int64(1)), - Name: Ptr("Justice League"), + ID: new(int64(1)), + Name: new("Justice League"), }, }, } diff --git a/github/pulls_reviews_test.go b/github/pulls_reviews_test.go index 8133bc5ca14..439d7f0f41b 100644 --- a/github/pulls_reviews_test.go +++ b/github/pulls_reviews_test.go @@ -34,8 +34,8 @@ func TestPullRequestsService_ListReviews(t *testing.T) { } want := []*PullRequestReview{ - {ID: Ptr(int64(1))}, - {ID: Ptr(int64(2))}, + {ID: new(int64(1))}, + {ID: new(int64(2))}, } if !cmp.Equal(reviews, want) { t.Errorf("PullRequests.ListReviews returned %+v, want %+v", reviews, want) @@ -80,7 +80,7 @@ func TestPullRequestsService_GetReview(t *testing.T) { t.Errorf("PullRequests.GetReview returned error: %v", err) } - want := &PullRequestReview{ID: Ptr(int64(1))} + want := &PullRequestReview{ID: new(int64(1))} if !cmp.Equal(review, want) { t.Errorf("PullRequests.GetReview returned %+v, want %+v", review, want) } @@ -124,7 +124,7 @@ func TestPullRequestsService_DeletePendingReview(t *testing.T) { t.Errorf("PullRequests.DeletePendingReview returned error: %v", err) } - want := &PullRequestReview{ID: Ptr(int64(1))} + want := &PullRequestReview{ID: new(int64(1))} if !cmp.Equal(review, want) { t.Errorf("PullRequests.DeletePendingReview returned %+v, want %+v", review, want) } @@ -169,8 +169,8 @@ func TestPullRequestsService_ListReviewComments(t *testing.T) { } want := []*PullRequestComment{ - {ID: Ptr(int64(1))}, - {ID: Ptr(int64(2))}, + {ID: new(int64(1))}, + {ID: new(int64(2))}, } if !cmp.Equal(comments, want) { t.Errorf("PullRequests.ListReviewComments returned %+v, want %+v", comments, want) @@ -359,9 +359,9 @@ func TestPullRequestsService_CreateReview(t *testing.T) { client, mux, _ := setup(t) input := &PullRequestReviewRequest{ - CommitID: Ptr("commit_id"), - Body: Ptr("b"), - Event: Ptr("APPROVE"), + CommitID: new("commit_id"), + Body: new("b"), + Event: new("APPROVE"), } mux.HandleFunc("/repos/o/r/pulls/1/reviews", func(w http.ResponseWriter, r *http.Request) { @@ -376,7 +376,7 @@ func TestPullRequestsService_CreateReview(t *testing.T) { t.Errorf("PullRequests.CreateReview returned error: %v", err) } - want := &PullRequestReview{ID: Ptr(int64(1))} + want := &PullRequestReview{ID: new(int64(1))} if !cmp.Equal(review, want) { t.Errorf("PullRequests.CreateReview returned %+v, want %+v", review, want) } @@ -417,12 +417,12 @@ func TestPullRequestsService_CreateReview_badReview(t *testing.T) { Comments: []*DraftReviewComment{{ Path: &path, Body: &body, - Side: Ptr("RIGHT"), - Line: Ptr(11), + Side: new("RIGHT"), + Line: new(11), }, { Path: &path, Body: &body, - Position: Ptr(1), + Position: new(1), }}, } @@ -488,7 +488,7 @@ func TestPullRequestsService_UpdateReview(t *testing.T) { t.Errorf("PullRequests.UpdateReview returned error: %v", err) } - want := &PullRequestReview{ID: Ptr(int64(1))} + want := &PullRequestReview{ID: new(int64(1))} if !cmp.Equal(got, want) { t.Errorf("PullRequests.UpdateReview = %+v, want %+v", got, want) } @@ -513,7 +513,7 @@ func TestPullRequestsService_SubmitReview(t *testing.T) { client, mux, _ := setup(t) input := PullRequestSubmitReviewRequest{ - Body: Ptr("b"), + Body: new("b"), Event: "APPROVE", } @@ -529,7 +529,7 @@ func TestPullRequestsService_SubmitReview(t *testing.T) { t.Errorf("PullRequests.SubmitReview returned error: %v", err) } - want := &PullRequestReview{ID: Ptr(int64(1))} + want := &PullRequestReview{ID: new(int64(1))} if !cmp.Equal(review, want) { t.Errorf("PullRequests.SubmitReview returned %+v, want %+v", review, want) } @@ -562,7 +562,7 @@ func TestPullRequestsService_DismissReview(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - input := PullRequestDismissReviewRequest{Message: "m", Event: Ptr("DISMISS")} + input := PullRequestDismissReviewRequest{Message: "m", Event: new("DISMISS")} mux.HandleFunc("/repos/o/r/pulls/1/reviews/1/dismissals", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "PUT") @@ -576,7 +576,7 @@ func TestPullRequestsService_DismissReview(t *testing.T) { t.Errorf("PullRequests.DismissReview returned error: %v", err) } - want := &PullRequestReview{ID: Ptr(int64(1))} + want := &PullRequestReview{ID: new(int64(1))} if !cmp.Equal(review, want) { t.Errorf("PullRequests.DismissReview returned %+v, want %+v", review, want) } diff --git a/github/pulls_test.go b/github/pulls_test.go index 926e0d17866..824eff8ac61 100644 --- a/github/pulls_test.go +++ b/github/pulls_test.go @@ -39,7 +39,7 @@ func TestPullRequestsService_List(t *testing.T) { t.Errorf("PullRequests.List returned error: %v", err) } - want := []*PullRequest{{Number: Ptr(1)}} + want := []*PullRequest{{Number: new(1)}} if !cmp.Equal(pulls, want) { t.Errorf("PullRequests.List returned %+v, want %+v", pulls, want) } @@ -79,7 +79,7 @@ func TestPullRequestsService_ListPullRequestsWithCommit(t *testing.T) { t.Errorf("PullRequests.ListPullRequestsWithCommit returned error: %v", err) } - want := []*PullRequest{{Number: Ptr(1)}} + want := []*PullRequest{{Number: new(1)}} if !cmp.Equal(pulls, want) { t.Errorf("PullRequests.ListPullRequestsWithCommit returned %+v, want %+v", pulls, want) } @@ -123,7 +123,7 @@ func TestPullRequestsService_Get(t *testing.T) { t.Errorf("PullRequests.Get returned error: %v", err) } - want := &PullRequest{Number: Ptr(1)} + want := &PullRequest{Number: new(1)} if !cmp.Equal(pull, want) { t.Errorf("PullRequests.Get returned %+v, want %+v", pull, want) } @@ -245,24 +245,24 @@ func TestPullRequestsService_Get_links(t *testing.T) { } want := &PullRequest{ - Number: Ptr(1), + Number: new(1), Links: &PRLinks{ Self: &PRLink{ - HRef: Ptr("https://api.github.com/repos/octocat/Hello-World/pulls/1347"), + HRef: new("https://api.github.com/repos/octocat/Hello-World/pulls/1347"), }, HTML: &PRLink{ - HRef: Ptr("https://github.com/octocat/Hello-World/pull/1347"), + HRef: new("https://github.com/octocat/Hello-World/pull/1347"), }, Issue: &PRLink{ - HRef: Ptr("https://api.github.com/repos/octocat/Hello-World/issues/1347"), + HRef: new("https://api.github.com/repos/octocat/Hello-World/issues/1347"), }, Comments: &PRLink{ - HRef: Ptr("https://api.github.com/repos/octocat/Hello-World/issues/1347/comments"), + HRef: new("https://api.github.com/repos/octocat/Hello-World/issues/1347/comments"), }, ReviewComments: &PRLink{ - HRef: Ptr("https://api.github.com/repos/octocat/Hello-World/pulls/1347/comments"), + HRef: new("https://api.github.com/repos/octocat/Hello-World/pulls/1347/comments"), }, ReviewComment: &PRLink{ - HRef: Ptr("https://api.github.com/repos/octocat/Hello-World/pulls/comments{/number}"), + HRef: new("https://api.github.com/repos/octocat/Hello-World/pulls/comments{/number}"), }, Commits: &PRLink{ - HRef: Ptr("https://api.github.com/repos/octocat/Hello-World/pulls/1347/commits"), + HRef: new("https://api.github.com/repos/octocat/Hello-World/pulls/1347/commits"), }, Statuses: &PRLink{ - HRef: Ptr("https://api.github.com/repos/octocat/Hello-World/statuses/6dcb09b5b57875f334f61aebed695e2e4193db5e"), + HRef: new("https://api.github.com/repos/octocat/Hello-World/statuses/6dcb09b5b57875f334f61aebed695e2e4193db5e"), }, }, } @@ -287,14 +287,14 @@ func TestPullRequestsService_Get_headAndBase(t *testing.T) { } want := &PullRequest{ - Number: Ptr(1), + Number: new(1), Head: &PullRequestBranch{ - Ref: Ptr("r2"), - Repo: &Repository{ID: Ptr(int64(2))}, + Ref: new("r2"), + Repo: &Repository{ID: new(int64(2))}, }, Base: &PullRequestBranch{ - Ref: Ptr("r1"), - Repo: &Repository{ID: Ptr(int64(1))}, + Ref: new("r1"), + Repo: &Repository{ID: new(int64(1))}, }, } if !cmp.Equal(pull, want) { @@ -326,15 +326,15 @@ func TestPullRequestsService_Get_urlFields(t *testing.T) { } want := &PullRequest{ - Number: Ptr(1), - URL: Ptr("https://api.github.com/repos/octocat/Hello-World/pulls/1347"), - HTMLURL: Ptr("https://github.com/octocat/Hello-World/pull/1347"), - IssueURL: Ptr("https://api.github.com/repos/octocat/Hello-World/issues/1347"), - StatusesURL: Ptr("https://api.github.com/repos/octocat/Hello-World/statuses/6dcb09b5b57875f334f61aebed695e2e4193db5e"), - DiffURL: Ptr("https://github.com/octocat/Hello-World/pull/1347.diff"), - PatchURL: Ptr("https://github.com/octocat/Hello-World/pull/1347.patch"), - ReviewCommentsURL: Ptr("https://api.github.com/repos/octocat/Hello-World/pulls/1347/comments"), - ReviewCommentURL: Ptr("https://api.github.com/repos/octocat/Hello-World/pulls/comments{/number}"), + Number: new(1), + URL: new("https://api.github.com/repos/octocat/Hello-World/pulls/1347"), + HTMLURL: new("https://github.com/octocat/Hello-World/pull/1347"), + IssueURL: new("https://api.github.com/repos/octocat/Hello-World/issues/1347"), + StatusesURL: new("https://api.github.com/repos/octocat/Hello-World/statuses/6dcb09b5b57875f334f61aebed695e2e4193db5e"), + DiffURL: new("https://github.com/octocat/Hello-World/pull/1347.diff"), + PatchURL: new("https://github.com/octocat/Hello-World/pull/1347.patch"), + ReviewCommentsURL: new("https://api.github.com/repos/octocat/Hello-World/pulls/1347/comments"), + ReviewCommentURL: new("https://api.github.com/repos/octocat/Hello-World/pulls/comments{/number}"), } if !cmp.Equal(pull, want) { @@ -355,7 +355,7 @@ func TestPullRequestsService_Create(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - input := CreatePullRequest{Title: Ptr("t")} + input := CreatePullRequest{Title: new("t")} mux.HandleFunc("/repos/o/r/pulls", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "POST") @@ -370,7 +370,7 @@ func TestPullRequestsService_Create(t *testing.T) { t.Errorf("PullRequests.Create returned error: %v", err) } - want := &PullRequest{Number: Ptr(1)} + want := &PullRequest{Number: new(1)} if !cmp.Equal(pull, want) { t.Errorf("PullRequests.Create returned %+v, want %+v", pull, want) } @@ -414,7 +414,7 @@ func TestPullRequestsService_UpdateBranch(t *testing.T) { }) opts := &PullRequestBranchUpdateOptions{ - ExpectedHeadSHA: Ptr("s"), + ExpectedHeadSHA: new("s"), } ctx := t.Context() @@ -424,8 +424,8 @@ func TestPullRequestsService_UpdateBranch(t *testing.T) { } want := &PullRequestBranchUpdateResponse{ - Message: Ptr("Updating pull request branch."), - URL: Ptr("https://github.com/repos/o/r/pulls/1"), + Message: new("Updating pull request branch."), + URL: new("https://github.com/repos/o/r/pulls/1"), } if !cmp.Equal(pull, want) { @@ -458,23 +458,23 @@ func TestPullRequestsService_Edit(t *testing.T) { wantUpdate *pullRequestUpdate }{ { - input: &PullRequest{Title: Ptr("t")}, + input: &PullRequest{Title: new("t")}, sendResponse: `{"number":1}`, - want: &PullRequest{Number: Ptr(1)}, + want: &PullRequest{Number: new(1)}, wantUpdate: &pullRequestUpdate{ - Title: Ptr("t"), + Title: new("t"), }, }, { // base update - input: &PullRequest{Base: &PullRequestBranch{Ref: Ptr("master")}}, + input: &PullRequest{Base: &PullRequestBranch{Ref: new("master")}}, sendResponse: `{"number":1,"base":{"ref":"master"}}`, want: &PullRequest{ - Number: Ptr(1), - Base: &PullRequestBranch{Ref: Ptr("master")}, + Number: new(1), + Base: &PullRequestBranch{Ref: new("master")}, }, wantUpdate: &pullRequestUpdate{ - Base: Ptr("master"), + Base: new("master"), }, }, } @@ -564,18 +564,18 @@ func TestPullRequestsService_ListCommits(t *testing.T) { want := []*RepositoryCommit{ { - SHA: Ptr("3"), + SHA: new("3"), Parents: []*Commit{ { - SHA: Ptr("2"), + SHA: new("2"), }, }, }, { - SHA: Ptr("2"), + SHA: new("2"), Parents: []*Commit{ { - SHA: Ptr("1"), + SHA: new("1"), }, }, }, @@ -638,22 +638,22 @@ func TestPullRequestsService_ListFiles(t *testing.T) { want := []*CommitFile{ { - SHA: Ptr("6dcb09b5b57875f334f61aebed695e2e4193db5e"), - Filename: Ptr("file1.txt"), - Additions: Ptr(103), - Deletions: Ptr(21), - Changes: Ptr(124), - Status: Ptr("added"), - Patch: Ptr("@@ -132,7 +132,7 @@ module Test @@ -1000,7 +1000,7 @@ module Test"), + SHA: new("6dcb09b5b57875f334f61aebed695e2e4193db5e"), + Filename: new("file1.txt"), + Additions: new(103), + Deletions: new(21), + Changes: new(124), + Status: new("added"), + Patch: new("@@ -132,7 +132,7 @@ module Test @@ -1000,7 +1000,7 @@ module Test"), }, { - SHA: Ptr("f61aebed695e2e4193db5e6dcb09b5b57875f334"), - Filename: Ptr("file2.txt"), - Additions: Ptr(5), - Deletions: Ptr(3), - Changes: Ptr(103), - Status: Ptr("modified"), - Patch: Ptr("@@ -132,7 +132,7 @@ module Test @@ -1000,7 +1000,7 @@ module Test"), + SHA: new("f61aebed695e2e4193db5e6dcb09b5b57875f334"), + Filename: new("file2.txt"), + Additions: new(5), + Deletions: new(3), + Changes: new(103), + Status: new("modified"), + Patch: new("@@ -132,7 +132,7 @@ module Test @@ -1000,7 +1000,7 @@ module Test"), }, } @@ -733,9 +733,9 @@ func TestPullRequestsService_Merge(t *testing.T) { } want := &PullRequestMergeResult{ - SHA: Ptr("6dcb09b5b57875f334f61aebed695e2e4193db5e"), - Merged: Ptr(true), - Message: Ptr("Pull Request successfully merged"), + SHA: new("6dcb09b5b57875f334f61aebed695e2e4193db5e"), + Merged: new(true), + Message: new("Pull Request successfully merged"), } if !cmp.Equal(merge, want) { t.Errorf("PullRequests.Merge returned %+v, want %+v", merge, want) @@ -768,26 +768,26 @@ func TestPullRequestsService_Merge_options(t *testing.T) { { options: nil, want: pullRequestMergeRequest{ - CommitMessage: Ptr("merging pull request"), + CommitMessage: new("merging pull request"), }, }, { options: &PullRequestOptions{}, want: pullRequestMergeRequest{ - CommitMessage: Ptr("merging pull request"), + CommitMessage: new("merging pull request"), }, }, { options: &PullRequestOptions{MergeMethod: "rebase"}, want: pullRequestMergeRequest{ - CommitMessage: Ptr("merging pull request"), + CommitMessage: new("merging pull request"), MergeMethod: "rebase", }, }, { options: &PullRequestOptions{SHA: "6dcb09b5b57875f334f61aebed695e2e4193db5e"}, want: pullRequestMergeRequest{ - CommitMessage: Ptr("merging pull request"), + CommitMessage: new("merging pull request"), SHA: "6dcb09b5b57875f334f61aebed695e2e4193db5e", }, }, @@ -798,7 +798,7 @@ func TestPullRequestsService_Merge_options(t *testing.T) { MergeMethod: "squash", }, want: pullRequestMergeRequest{ - CommitMessage: Ptr("merging pull request"), + CommitMessage: new("merging pull request"), SHA: "6dcb09b5b57875f334f61aebed695e2e4193db5e", CommitTitle: "Extra detail", MergeMethod: "squash", @@ -809,7 +809,7 @@ func TestPullRequestsService_Merge_options(t *testing.T) { DontDefaultIfBlank: true, }, want: pullRequestMergeRequest{ - CommitMessage: Ptr("merging pull request"), + CommitMessage: new("merging pull request"), }, }, } @@ -852,7 +852,7 @@ func TestPullRequestsService_Merge_Blank_Message(t *testing.T) { DontDefaultIfBlank: true, } want = &pullRequestMergeRequest{ - CommitMessage: Ptr(""), + CommitMessage: new(""), } _, _, _ = client.PullRequests.Merge(ctx, "o", "r", 1, "", &opts) if !madeRequest { diff --git a/github/reactions_test.go b/github/reactions_test.go index cd3a32b8d35..15f7fea9b21 100644 --- a/github/reactions_test.go +++ b/github/reactions_test.go @@ -31,7 +31,7 @@ func TestReactionsService_ListCommentReactions(t *testing.T) { if err != nil { t.Errorf("ListCommentReactions returned error: %v", err) } - want := []*Reaction{{ID: Ptr(int64(1)), User: &User{Login: Ptr("l"), ID: Ptr(int64(2))}, Content: Ptr("+1")}} + want := []*Reaction{{ID: new(int64(1)), User: &User{Login: new("l"), ID: new(int64(2))}, Content: new("+1")}} if !cmp.Equal(reactions, want) { t.Errorf("ListCommentReactions = %+v, want %+v", reactions, want) } @@ -68,7 +68,7 @@ func TestReactionsService_CreateCommentReaction(t *testing.T) { if err != nil { t.Errorf("CreateCommentReaction returned error: %v", err) } - want := &Reaction{ID: Ptr(int64(1)), User: &User{Login: Ptr("l"), ID: Ptr(int64(2))}, Content: Ptr("+1")} + want := &Reaction{ID: new(int64(1)), User: &User{Login: new("l"), ID: new(int64(2))}, Content: new("+1")} if !cmp.Equal(got, want) { t.Errorf("CreateCommentReaction = %+v, want %+v", got, want) } @@ -107,7 +107,7 @@ func TestReactionsService_ListIssueReactions(t *testing.T) { if err != nil { t.Errorf("ListIssueReactions returned error: %v", err) } - want := []*Reaction{{ID: Ptr(int64(1)), User: &User{Login: Ptr("l"), ID: Ptr(int64(2))}, Content: Ptr("+1")}} + want := []*Reaction{{ID: new(int64(1)), User: &User{Login: new("l"), ID: new(int64(2))}, Content: new("+1")}} if !cmp.Equal(got, want) { t.Errorf("ListIssueReactions = %+v, want %+v", got, want) } @@ -151,7 +151,7 @@ func TestReactionsService_CreateIssueReaction(t *testing.T) { if err != nil { t.Errorf("CreateIssueReaction returned error: %v", err) } - want := &Reaction{ID: Ptr(int64(1)), User: &User{Login: Ptr("l"), ID: Ptr(int64(2))}, Content: Ptr("+1")} + want := &Reaction{ID: new(int64(1)), User: &User{Login: new("l"), ID: new(int64(2))}, Content: new("+1")} if !cmp.Equal(got, want) { t.Errorf("CreateIssueReaction = %+v, want %+v", got, want) } @@ -190,7 +190,7 @@ func TestReactionsService_ListIssueCommentReactions(t *testing.T) { if err != nil { t.Errorf("ListIssueCommentReactions returned error: %v", err) } - want := []*Reaction{{ID: Ptr(int64(1)), User: &User{Login: Ptr("l"), ID: Ptr(int64(2))}, Content: Ptr("+1")}} + want := []*Reaction{{ID: new(int64(1)), User: &User{Login: new("l"), ID: new(int64(2))}, Content: new("+1")}} if !cmp.Equal(got, want) { t.Errorf("ListIssueCommentReactions = %+v, want %+v", got, want) } @@ -234,7 +234,7 @@ func TestReactionsService_CreateIssueCommentReaction(t *testing.T) { if err != nil { t.Errorf("CreateIssueCommentReaction returned error: %v", err) } - want := &Reaction{ID: Ptr(int64(1)), User: &User{Login: Ptr("l"), ID: Ptr(int64(2))}, Content: Ptr("+1")} + want := &Reaction{ID: new(int64(1)), User: &User{Login: new("l"), ID: new(int64(2))}, Content: new("+1")} if !cmp.Equal(got, want) { t.Errorf("CreateIssueCommentReaction = %+v, want %+v", got, want) } @@ -273,7 +273,7 @@ func TestReactionsService_ListPullRequestCommentReactions(t *testing.T) { if err != nil { t.Errorf("ListPullRequestCommentReactions returned error: %v", err) } - want := []*Reaction{{ID: Ptr(int64(1)), User: &User{Login: Ptr("l"), ID: Ptr(int64(2))}, Content: Ptr("+1")}} + want := []*Reaction{{ID: new(int64(1)), User: &User{Login: new("l"), ID: new(int64(2))}, Content: new("+1")}} if !cmp.Equal(got, want) { t.Errorf("ListPullRequestCommentReactions = %+v, want %+v", got, want) } @@ -317,7 +317,7 @@ func TestReactionsService_CreatePullRequestCommentReaction(t *testing.T) { if err != nil { t.Errorf("CreatePullRequestCommentReaction returned error: %v", err) } - want := &Reaction{ID: Ptr(int64(1)), User: &User{Login: Ptr("l"), ID: Ptr(int64(2))}, Content: Ptr("+1")} + want := &Reaction{ID: new(int64(1)), User: &User{Login: new("l"), ID: new(int64(2))}, Content: new("+1")} if !cmp.Equal(got, want) { t.Errorf("CreatePullRequestCommentReaction = %+v, want %+v", got, want) } @@ -356,7 +356,7 @@ func TestReactionsService_ListTeamDiscussionReactions(t *testing.T) { if err != nil { t.Errorf("ListTeamDiscussionReactions returned error: %v", err) } - want := []*Reaction{{ID: Ptr(int64(1)), User: &User{Login: Ptr("l"), ID: Ptr(int64(2))}, Content: Ptr("+1")}} + want := []*Reaction{{ID: new(int64(1)), User: &User{Login: new("l"), ID: new(int64(2))}, Content: new("+1")}} if !cmp.Equal(got, want) { t.Errorf("ListTeamDiscussionReactions = %+v, want %+v", got, want) } @@ -400,7 +400,7 @@ func TestReactionsService_CreateTeamDiscussionReaction(t *testing.T) { if err != nil { t.Errorf("CreateTeamDiscussionReaction returned error: %v", err) } - want := &Reaction{ID: Ptr(int64(1)), User: &User{Login: Ptr("l"), ID: Ptr(int64(2))}, Content: Ptr("+1")} + want := &Reaction{ID: new(int64(1)), User: &User{Login: new("l"), ID: new(int64(2))}, Content: new("+1")} if !cmp.Equal(got, want) { t.Errorf("CreateTeamDiscussionReaction = %+v, want %+v", got, want) } @@ -439,7 +439,7 @@ func TestReactionService_ListTeamDiscussionCommentReactions(t *testing.T) { if err != nil { t.Errorf("ListTeamDiscussionCommentReactions returned error: %v", err) } - want := []*Reaction{{ID: Ptr(int64(1)), User: &User{Login: Ptr("l"), ID: Ptr(int64(2))}, Content: Ptr("+1")}} + want := []*Reaction{{ID: new(int64(1)), User: &User{Login: new("l"), ID: new(int64(2))}, Content: new("+1")}} if !cmp.Equal(got, want) { t.Errorf("ListTeamDiscussionCommentReactions = %+v, want %+v", got, want) } @@ -483,7 +483,7 @@ func TestReactionService_CreateTeamDiscussionCommentReaction(t *testing.T) { if err != nil { t.Errorf("CreateTeamDiscussionCommentReaction returned error: %v", err) } - want := &Reaction{ID: Ptr(int64(1)), User: &User{Login: Ptr("l"), ID: Ptr(int64(2))}, Content: Ptr("+1")} + want := &Reaction{ID: new(int64(1)), User: &User{Login: new("l"), ID: new(int64(2))}, Content: new("+1")} if !cmp.Equal(got, want) { t.Errorf("CreateTeamDiscussionCommentReaction = %+v, want %+v", got, want) } @@ -846,7 +846,7 @@ func TestReactionService_CreateReleaseReaction(t *testing.T) { t.Errorf("%v returned error: %v", methodName, err) } - want := &Reaction{ID: Ptr(int64(1)), User: &User{Login: Ptr("l"), ID: Ptr(int64(2))}, Content: Ptr("rocket")} + want := &Reaction{ID: new(int64(1)), User: &User{Login: new("l"), ID: new(int64(2))}, Content: new("rocket")} if !cmp.Equal(got, want) { t.Errorf("%v = %+v, want %+v", methodName, got, want) } @@ -884,7 +884,7 @@ func TestReactionsService_ListReleaseReactions(t *testing.T) { if err != nil { t.Errorf("ListReleaseReactions returned error: %v", err) } - want := []*Reaction{{ID: Ptr(int64(1)), User: &User{Login: Ptr("l"), ID: Ptr(int64(2))}, Content: Ptr("+1")}} + want := []*Reaction{{ID: new(int64(1)), User: &User{Login: new("l"), ID: new(int64(2))}, Content: new("+1")}} if !cmp.Equal(got, want) { t.Errorf("ListReleaseReactions = %+v, want %+v", got, want) } diff --git a/github/repos_actions_access_test.go b/github/repos_actions_access_test.go index 7f35de5188f..63c408d711f 100644 --- a/github/repos_actions_access_test.go +++ b/github/repos_actions_access_test.go @@ -27,7 +27,7 @@ func TestRepositoriesService_GetActionsAccessLevel(t *testing.T) { if err != nil { t.Errorf("Repositories.GetActionsAccessLevel returned error: %v", err) } - want := &RepositoryActionsAccessLevel{AccessLevel: Ptr("none")} + want := &RepositoryActionsAccessLevel{AccessLevel: new("none")} if !cmp.Equal(org, want) { t.Errorf("Repositories.GetActionsAccessLevel returned %+v, want %+v", org, want) } @@ -51,7 +51,7 @@ func TestRepositoriesService_EditActionsAccessLevel(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - input := &RepositoryActionsAccessLevel{AccessLevel: Ptr("organization")} + input := &RepositoryActionsAccessLevel{AccessLevel: new("organization")} mux.HandleFunc("/repos/o/r/actions/permissions/access", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "PUT") diff --git a/github/repos_actions_allowed_test.go b/github/repos_actions_allowed_test.go index 0882ea95335..76484211e6a 100644 --- a/github/repos_actions_allowed_test.go +++ b/github/repos_actions_allowed_test.go @@ -27,7 +27,7 @@ func TestRepositoryService_GetActionsAllowed(t *testing.T) { if err != nil { t.Errorf("Repositories.GetActionsAllowed returned error: %v", err) } - want := &ActionsAllowed{GithubOwnedAllowed: Ptr(true), VerifiedAllowed: Ptr(false), PatternsAllowed: []string{"a/b"}} + want := &ActionsAllowed{GithubOwnedAllowed: new(true), VerifiedAllowed: new(false), PatternsAllowed: []string{"a/b"}} if !cmp.Equal(org, want) { t.Errorf("Repositories.GetActionsAllowed returned %+v, want %+v", org, want) } @@ -51,7 +51,7 @@ func TestRepositoriesService_EditActionsAllowed(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - input := &ActionsAllowed{GithubOwnedAllowed: Ptr(true), VerifiedAllowed: Ptr(false), PatternsAllowed: []string{"a/b"}} + input := &ActionsAllowed{GithubOwnedAllowed: new(true), VerifiedAllowed: new(false), PatternsAllowed: []string{"a/b"}} mux.HandleFunc("/repos/o/r/actions/permissions/selected-actions", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "PUT") @@ -65,7 +65,7 @@ func TestRepositoriesService_EditActionsAllowed(t *testing.T) { t.Errorf("Repositories.EditActionsAllowed returned error: %v", err) } - want := &ActionsAllowed{GithubOwnedAllowed: Ptr(true), VerifiedAllowed: Ptr(false), PatternsAllowed: []string{"a/b"}} + want := &ActionsAllowed{GithubOwnedAllowed: new(true), VerifiedAllowed: new(false), PatternsAllowed: []string{"a/b"}} if !cmp.Equal(org, want) { t.Errorf("Repositories.EditActionsAllowed returned %+v, want %+v", org, want) } diff --git a/github/repos_actions_permissions_test.go b/github/repos_actions_permissions_test.go index f32ed1dd2b3..8d8d3aa7b36 100644 --- a/github/repos_actions_permissions_test.go +++ b/github/repos_actions_permissions_test.go @@ -27,7 +27,7 @@ func TestRepositoriesService_GetActionsPermissions(t *testing.T) { if err != nil { t.Errorf("Repositories.GetActionsPermissions returned error: %v", err) } - want := &ActionsPermissionsRepository{Enabled: Ptr(true), AllowedActions: Ptr("all"), SHAPinningRequired: Ptr(true)} + want := &ActionsPermissionsRepository{Enabled: new(true), AllowedActions: new("all"), SHAPinningRequired: new(true)} if !cmp.Equal(org, want) { t.Errorf("Repositories.GetActionsPermissions returned %+v, want %+v", org, want) } @@ -51,7 +51,7 @@ func TestRepositoriesService_UpdateActionsPermissions(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - input := &ActionsPermissionsRepository{Enabled: Ptr(true), AllowedActions: Ptr("selected"), SHAPinningRequired: Ptr(true)} + input := &ActionsPermissionsRepository{Enabled: new(true), AllowedActions: new("selected"), SHAPinningRequired: new(true)} mux.HandleFunc("/repos/o/r/actions/permissions", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "PUT") @@ -65,7 +65,7 @@ func TestRepositoriesService_UpdateActionsPermissions(t *testing.T) { t.Errorf("Repositories.UpdateActionsPermissions returned error: %v", err) } - want := &ActionsPermissionsRepository{Enabled: Ptr(true), AllowedActions: Ptr("selected"), SHAPinningRequired: Ptr(true)} + want := &ActionsPermissionsRepository{Enabled: new(true), AllowedActions: new("selected"), SHAPinningRequired: new(true)} if !cmp.Equal(org, want) { t.Errorf("Repositories.UpdateActionsPermissions returned %+v, want %+v", org, want) } @@ -99,7 +99,7 @@ func TestRepositoriesService_GetDefaultWorkflowPermissions(t *testing.T) { if err != nil { t.Errorf("Repositories.GetDefaultWorkflowPermissions returned error: %v", err) } - want := &DefaultWorkflowPermissionRepository{DefaultWorkflowPermissions: Ptr("read"), CanApprovePullRequestReviews: Ptr(true)} + want := &DefaultWorkflowPermissionRepository{DefaultWorkflowPermissions: new("read"), CanApprovePullRequestReviews: new(true)} if !cmp.Equal(org, want) { t.Errorf("Repositories.GetDefaultWorkflowPermissions returned %+v, want %+v", org, want) } @@ -123,7 +123,7 @@ func TestRepositoriesService_UpdateDefaultWorkflowPermissions(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - input := &DefaultWorkflowPermissionRepository{DefaultWorkflowPermissions: Ptr("read"), CanApprovePullRequestReviews: Ptr(true)} + input := &DefaultWorkflowPermissionRepository{DefaultWorkflowPermissions: new("read"), CanApprovePullRequestReviews: new(true)} mux.HandleFunc("/repos/o/r/actions/permissions/workflow", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "PUT") @@ -137,7 +137,7 @@ func TestRepositoriesService_UpdateDefaultWorkflowPermissions(t *testing.T) { t.Errorf("Repositories.UpdateDefaultWorkflowPermissions returned error: %v", err) } - want := &DefaultWorkflowPermissionRepository{DefaultWorkflowPermissions: Ptr("read"), CanApprovePullRequestReviews: Ptr(true)} + want := &DefaultWorkflowPermissionRepository{DefaultWorkflowPermissions: new("read"), CanApprovePullRequestReviews: new(true)} if !cmp.Equal(org, want) { t.Errorf("Repositories.UpdateDefaultWorkflowPermissions returned %+v, want %+v", org, want) } @@ -173,8 +173,8 @@ func TestRepositoriesService_GetArtifactAndLogRetentionPeriod(t *testing.T) { } want := &ArtifactPeriod{ - Days: Ptr(90), - MaximumAllowedDays: Ptr(365), + Days: new(90), + MaximumAllowedDays: new(365), } if !cmp.Equal(period, want) { t.Errorf("Repositories.GetArtifactAndLogRetentionPeriod = %+v, want %+v", period, want) @@ -199,7 +199,7 @@ func TestRepositoriesService_UpdateArtifactAndLogRetentionPeriod(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - input := &ArtifactPeriodOpt{Days: Ptr(90)} + input := &ArtifactPeriodOpt{Days: new(90)} mux.HandleFunc("/repos/o/r/actions/permissions/artifact-and-log-retention", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "PUT") @@ -243,10 +243,10 @@ func TestRepositoriesService_GetPrivateRepoForkPRWorkflowSettings(t *testing.T) t.Errorf("Repositories.GetPrivateRepoForkPRWorkflowSettings returned error: %v", err) } want := &WorkflowsPermissions{ - RunWorkflowsFromForkPullRequests: Ptr(true), - SendWriteTokensToWorkflows: Ptr(false), - SendSecretsAndVariables: Ptr(true), - RequireApprovalForForkPRWorkflows: Ptr(false), + RunWorkflowsFromForkPullRequests: new(true), + SendWriteTokensToWorkflows: new(false), + SendSecretsAndVariables: new(true), + RequireApprovalForForkPRWorkflows: new(false), } if !cmp.Equal(permissions, want) { t.Errorf("Repositories.GetPrivateRepoForkPRWorkflowSettings returned %+v, want %+v", permissions, want) @@ -273,8 +273,8 @@ func TestRepositoriesService_UpdatePrivateRepoForkPRWorkflowSettings(t *testing. input := &WorkflowsPermissionsOpt{ RunWorkflowsFromForkPullRequests: true, - SendWriteTokensToWorkflows: Ptr(false), - SendSecretsAndVariables: Ptr(true), + SendWriteTokensToWorkflows: new(false), + SendSecretsAndVariables: new(true), } mux.HandleFunc("/repos/o/r/actions/permissions/fork-pr-workflows-private-repos", func(w http.ResponseWriter, r *http.Request) { diff --git a/github/repos_autolinks_test.go b/github/repos_autolinks_test.go index a5fb2b12a80..2d419ad3000 100644 --- a/github/repos_autolinks_test.go +++ b/github/repos_autolinks_test.go @@ -29,8 +29,8 @@ func TestRepositoriesService_ListAutolinks(t *testing.T) { } want := []*Autolink{ - {ID: Ptr(int64(1)), KeyPrefix: Ptr("TICKET-"), URLTemplate: Ptr("https://example.com/TICKET?query=")}, - {ID: Ptr(int64(2)), KeyPrefix: Ptr("STORY-"), URLTemplate: Ptr("https://example.com/STORY?query=")}, + {ID: new(int64(1)), KeyPrefix: new("TICKET-"), URLTemplate: new("https://example.com/TICKET?query=")}, + {ID: new(int64(2)), KeyPrefix: new("STORY-"), URLTemplate: new("https://example.com/STORY?query=")}, } if !cmp.Equal(autolinks, want) { @@ -59,7 +59,7 @@ func TestRepositoriesService_CreateAutolink(t *testing.T) { body := CreateAutolinkRequest{ KeyPrefix: "TICKET-", URLTemplate: "https://example.com/TICKET?query=", - IsAlphanumeric: Ptr(true), + IsAlphanumeric: new(true), } mux.HandleFunc("/repos/o/r/autolinks", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "POST") @@ -79,9 +79,9 @@ func TestRepositoriesService_CreateAutolink(t *testing.T) { t.Errorf("Repositories.CreateAutolink returned error: %v", err) } want := &Autolink{ - KeyPrefix: Ptr("TICKET-"), - URLTemplate: Ptr("https://example.com/TICKET?query="), - IsAlphanumeric: Ptr(true), + KeyPrefix: new("TICKET-"), + URLTemplate: new("https://example.com/TICKET?query="), + IsAlphanumeric: new(true), } if !cmp.Equal(autolink, want) { @@ -118,7 +118,7 @@ func TestRepositoriesService_GetAutolink(t *testing.T) { t.Errorf("Repositories.GetAutolink returned error: %v", err) } - want := &Autolink{ID: Ptr(int64(1)), KeyPrefix: Ptr("TICKET-"), URLTemplate: Ptr("https://example.com/TICKET?query=")} + want := &Autolink{ID: new(int64(1)), KeyPrefix: new("TICKET-"), URLTemplate: new("https://example.com/TICKET?query=")} if !cmp.Equal(autolink, want) { t.Errorf("Repositories.GetAutolink returned %+v, want %+v", autolink, want) } diff --git a/github/repos_codeowners_test.go b/github/repos_codeowners_test.go index 87b2a7a12aa..0927cf4281c 100644 --- a/github/repos_codeowners_test.go +++ b/github/repos_codeowners_test.go @@ -49,7 +49,7 @@ func TestRepositoriesService_GetCodeownersErrors_noRef(t *testing.T) { Column: 1, Kind: "Invalid pattern", Source: "***/*.rb @monalisa", - Suggestion: Ptr("Did you mean **/*.rb?"), + Suggestion: new("Did you mean **/*.rb?"), Message: "Invalid pattern on line 3: Did you mean **/*.rb?\n\n ***/*.rb @monalisa\n ^", Path: ".github/CODEOWNERS", }, @@ -112,7 +112,7 @@ func TestRepositoriesService_GetCodeownersErrors_specificRef(t *testing.T) { Column: 1, Kind: "Invalid pattern", Source: "***/*.rb @monalisa", - Suggestion: Ptr("Did you mean **/*.rb?"), + Suggestion: new("Did you mean **/*.rb?"), Message: "Invalid pattern on line 3: Did you mean **/*.rb?\n\n ***/*.rb @monalisa\n ^", Path: ".github/CODEOWNERS", }, diff --git a/github/repos_collaborators_test.go b/github/repos_collaborators_test.go index 7c3d9cab0dd..d69929da266 100644 --- a/github/repos_collaborators_test.go +++ b/github/repos_collaborators_test.go @@ -32,7 +32,7 @@ func TestRepositoriesService_ListCollaborators(t *testing.T) { t.Errorf("Repositories.ListCollaborators returned error: %v", err) } - want := []*User{{ID: Ptr(int64(1))}, {ID: Ptr(int64(2))}} + want := []*User{{ID: new(int64(1))}, {ID: new(int64(2))}} if !cmp.Equal(users, want) { t.Errorf("Repositories.ListCollaborators returned %+v, want %+v", users, want) } @@ -72,7 +72,7 @@ func TestRepositoriesService_ListCollaborators_withAffiliation(t *testing.T) { t.Errorf("Repositories.ListCollaborators returned error: %v", err) } - want := []*User{{ID: Ptr(int64(1))}, {ID: Ptr(int64(2))}} + want := []*User{{ID: new(int64(1))}, {ID: new(int64(2))}} if !cmp.Equal(users, want) { t.Errorf("Repositories.ListCollaborators returned %+v, want %+v", users, want) } @@ -112,7 +112,7 @@ func TestRepositoriesService_ListCollaborators_withPermission(t *testing.T) { t.Errorf("Repositories.ListCollaborators returned error: %v", err) } - want := []*User{{ID: Ptr(int64(1))}, {ID: Ptr(int64(2))}} + want := []*User{{ID: new(int64(1))}, {ID: new(int64(2))}} if !cmp.Equal(users, want) { t.Errorf("Repositories.ListCollaborators returned %+v, want %+v", users, want) } @@ -234,9 +234,9 @@ func TestRepositoryService_GetPermissionLevel(t *testing.T) { } want := &RepositoryPermissionLevel{ - Permission: Ptr("admin"), + Permission: new("admin"), User: &User{ - Login: Ptr("u"), + Login: new("u"), }, } @@ -276,21 +276,21 @@ func TestRepositoriesService_AddCollaborator(t *testing.T) { t.Errorf("Repositories.AddCollaborator returned error: %v", err) } want := &CollaboratorInvitation{ - ID: Ptr(int64(1)), + ID: new(int64(1)), Repo: &Repository{ - ID: Ptr(int64(1)), - URL: Ptr("s"), - Name: Ptr("r"), + ID: new(int64(1)), + URL: new("s"), + Name: new("r"), }, Invitee: &User{ - Login: Ptr("u"), + Login: new("u"), }, Inviter: &User{ - Login: Ptr("o"), + Login: new("o"), }, - Permissions: Ptr("write"), - URL: Ptr("https://api.github.com/user/repository_invitations/1296269"), - HTMLURL: Ptr("https://github.com/octocat/Hello-World/invitations"), + Permissions: new("write"), + URL: new("https://api.github.com/user/repository_invitations/1296269"), + HTMLURL: new("https://github.com/octocat/Hello-World/invitations"), } if !cmp.Equal(collaboratorInvitation, want) { diff --git a/github/repos_comments_test.go b/github/repos_comments_test.go index 7cebb99dad9..aaf63a9279a 100644 --- a/github/repos_comments_test.go +++ b/github/repos_comments_test.go @@ -31,7 +31,7 @@ func TestRepositoriesService_ListComments(t *testing.T) { t.Errorf("Repositories.ListComments returned error: %v", err) } - want := []*RepositoryComment{{ID: Ptr(int64(1))}, {ID: Ptr(int64(2))}} + want := []*RepositoryComment{{ID: new(int64(1))}, {ID: new(int64(2))}} if !cmp.Equal(comments, want) { t.Errorf("Repositories.ListComments returned %+v, want %+v", comments, want) } @@ -78,7 +78,7 @@ func TestRepositoriesService_ListCommitComments(t *testing.T) { t.Errorf("Repositories.ListCommitComments returned error: %v", err) } - want := []*RepositoryComment{{ID: Ptr(int64(1))}, {ID: Ptr(int64(2))}} + want := []*RepositoryComment{{ID: new(int64(1))}, {ID: new(int64(2))}} if !cmp.Equal(comments, want) { t.Errorf("Repositories.ListCommitComments returned %+v, want %+v", comments, want) } @@ -111,7 +111,7 @@ func TestRepositoriesService_CreateComment(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - input := &RepositoryComment{Body: Ptr("b")} + input := &RepositoryComment{Body: new("b")} mux.HandleFunc("/repos/o/r/commits/s/comments", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "POST") @@ -125,7 +125,7 @@ func TestRepositoriesService_CreateComment(t *testing.T) { t.Errorf("Repositories.CreateComment returned error: %v", err) } - want := &RepositoryComment{ID: Ptr(int64(1))} + want := &RepositoryComment{ID: new(int64(1))} if !cmp.Equal(comment, want) { t.Errorf("Repositories.CreateComment returned %+v, want %+v", comment, want) } @@ -170,7 +170,7 @@ func TestRepositoriesService_GetComment(t *testing.T) { t.Errorf("Repositories.GetComment returned error: %v", err) } - want := &RepositoryComment{ID: Ptr(int64(1))} + want := &RepositoryComment{ID: new(int64(1))} if !cmp.Equal(comment, want) { t.Errorf("Repositories.GetComment returned %+v, want %+v", comment, want) } @@ -203,7 +203,7 @@ func TestRepositoriesService_UpdateComment(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - input := &RepositoryComment{Body: Ptr("b")} + input := &RepositoryComment{Body: new("b")} mux.HandleFunc("/repos/o/r/comments/1", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "PATCH") @@ -218,7 +218,7 @@ func TestRepositoriesService_UpdateComment(t *testing.T) { t.Errorf("Repositories.UpdateComment returned error: %v", err) } - want := &RepositoryComment{ID: Ptr(int64(1))} + want := &RepositoryComment{ID: new(int64(1))} if !cmp.Equal(comment, want) { t.Errorf("Repositories.UpdateComment returned %+v, want %+v", comment, want) } diff --git a/github/repos_commits_test.go b/github/repos_commits_test.go index 1ca3c1f4338..2d5997e577a 100644 --- a/github/repos_commits_test.go +++ b/github/repos_commits_test.go @@ -47,7 +47,7 @@ func TestRepositoriesService_ListCommits(t *testing.T) { t.Errorf("Repositories.ListCommits returned error: %v", err) } - want := []*RepositoryCommit{{SHA: Ptr("s")}} + want := []*RepositoryCommit{{SHA: new("s")}} if !cmp.Equal(commits, want) { t.Errorf("Repositories.ListCommits returned %+v, want %+v", commits, want) } @@ -105,37 +105,37 @@ func TestRepositoriesService_GetCommit(t *testing.T) { } want := &RepositoryCommit{ - SHA: Ptr("s"), + SHA: new("s"), Commit: &Commit{ - Message: Ptr("m"), + Message: new("m"), }, Author: &User{ - Login: Ptr("l"), + Login: new("l"), }, Committer: &User{ - Login: Ptr("l"), + Login: new("l"), }, Parents: []*Commit{ { - SHA: Ptr("s"), + SHA: new("s"), }, }, Stats: &CommitStats{ - Additions: Ptr(104), - Deletions: Ptr(4), - Total: Ptr(108), + Additions: new(104), + Deletions: new(4), + Total: new(108), }, Files: []*CommitFile{ { - Filename: Ptr("f"), - Additions: Ptr(10), - Deletions: Ptr(2), - Changes: Ptr(12), - Status: Ptr("s"), - Patch: Ptr("p"), - BlobURL: Ptr("b"), - RawURL: Ptr("r"), - ContentsURL: Ptr("c"), + Filename: new("f"), + Additions: new(10), + Deletions: new(2), + Changes: new(12), + Status: new("s"), + Patch: new("p"), + BlobURL: new("b"), + RawURL: new("r"), + ContentsURL: new("c"), }, }, } @@ -445,50 +445,50 @@ func TestRepositoriesService_CompareCommits(t *testing.T) { want := &CommitsComparison{ BaseCommit: &RepositoryCommit{ - SHA: Ptr("s"), + SHA: new("s"), Commit: &Commit{ - Author: &CommitAuthor{Name: Ptr("n")}, - Committer: &CommitAuthor{Name: Ptr("n")}, - Message: Ptr("m"), - Tree: &Tree{SHA: Ptr("t")}, + Author: &CommitAuthor{Name: new("n")}, + Committer: &CommitAuthor{Name: new("n")}, + Message: new("m"), + Tree: &Tree{SHA: new("t")}, }, - Author: &User{Login: Ptr("l")}, - Committer: &User{Login: Ptr("l")}, + Author: &User{Login: new("l")}, + Committer: &User{Login: new("l")}, Parents: []*Commit{ { - SHA: Ptr("s"), + SHA: new("s"), }, }, }, - Status: Ptr("s"), - AheadBy: Ptr(1), - BehindBy: Ptr(2), - TotalCommits: Ptr(1), + Status: new("s"), + AheadBy: new(1), + BehindBy: new(2), + TotalCommits: new(1), Commits: []*RepositoryCommit{ { - SHA: Ptr("s"), + SHA: new("s"), Commit: &Commit{ - Author: &CommitAuthor{Name: Ptr("n")}, + Author: &CommitAuthor{Name: new("n")}, }, - Author: &User{Login: Ptr("l")}, - Committer: &User{Login: Ptr("l")}, + Author: &User{Login: new("l")}, + Committer: &User{Login: new("l")}, Parents: []*Commit{ { - SHA: Ptr("s"), + SHA: new("s"), }, }, }, }, Files: []*CommitFile{ { - Filename: Ptr("f"), + Filename: new("f"), }, }, - HTMLURL: Ptr(fmt.Sprintf("https://github.com/o/r/compare/%v...%v", escapedBase, escapedHead)), - PermalinkURL: Ptr("https://github.com/o/r/compare/o:bbcd538c8e72b8c175046e27cc8f907076331401...o:0328041d1152db8ae77652d1618a02e57f745f17"), - DiffURL: Ptr(fmt.Sprintf("https://github.com/o/r/compare/%v...%v.diff", escapedBase, escapedHead)), - PatchURL: Ptr(fmt.Sprintf("https://github.com/o/r/compare/%v...%v.patch", escapedBase, escapedHead)), - URL: Ptr(fmt.Sprintf("https://api.github.com/repos/o/r/compare/%v...%v", escapedBase, escapedHead)), + HTMLURL: new(fmt.Sprintf("https://github.com/o/r/compare/%v...%v", escapedBase, escapedHead)), + PermalinkURL: new("https://github.com/o/r/compare/o:bbcd538c8e72b8c175046e27cc8f907076331401...o:0328041d1152db8ae77652d1618a02e57f745f17"), + DiffURL: new(fmt.Sprintf("https://github.com/o/r/compare/%v...%v.diff", escapedBase, escapedHead)), + PatchURL: new(fmt.Sprintf("https://github.com/o/r/compare/%v...%v.patch", escapedBase, escapedHead)), + URL: new(fmt.Sprintf("https://api.github.com/repos/o/r/compare/%v...%v", escapedBase, escapedHead)), } if !cmp.Equal(got, want) { @@ -659,12 +659,12 @@ func TestRepositoriesService_ListBranchesHeadCommit(t *testing.T) { want := []*BranchCommit{ { - Name: Ptr("b"), + Name: new("b"), Commit: &Commit{ - SHA: Ptr("2e90302801c870f17b6152327d9b9a03c8eca0e2"), - URL: Ptr("https://api.github.com/repos/google/go-github/commits/2e90302801c870f17b6152327d9b9a03c8eca0e2"), + SHA: new("2e90302801c870f17b6152327d9b9a03c8eca0e2"), + URL: new("https://api.github.com/repos/google/go-github/commits/2e90302801c870f17b6152327d9b9a03c8eca0e2"), }, - Protected: Ptr(true), + Protected: new(true), }, } if !cmp.Equal(branches, want) { diff --git a/github/repos_community_health_test.go b/github/repos_community_health_test.go index 19705d5ee6c..219ef482cdf 100644 --- a/github/repos_community_health_test.go +++ b/github/repos_community_health_test.go @@ -71,43 +71,43 @@ func TestRepositoriesService_GetCommunityHealthMetrics(t *testing.T) { } want := &CommunityHealthMetrics{ - HealthPercentage: Ptr(100), - Description: Ptr("My first repository on GitHub!"), + HealthPercentage: new(100), + Description: new("My first repository on GitHub!"), UpdatedAt: &referenceTimestamp, - ContentReportsEnabled: Ptr(true), + ContentReportsEnabled: new(true), Files: &CommunityHealthFiles{ CodeOfConduct: &Metric{ - Name: Ptr("Contributor Covenant"), - Key: Ptr("contributor_covenant"), - HTMLURL: Ptr("https://github.com/octocat/Hello-World/blob/master/CODE_OF_CONDUCT.md"), + Name: new("Contributor Covenant"), + Key: new("contributor_covenant"), + HTMLURL: new("https://github.com/octocat/Hello-World/blob/master/CODE_OF_CONDUCT.md"), }, CodeOfConductFile: &Metric{ - URL: Ptr("https://api.github.com/repos/octocat/Hello-World/contents/CODE_OF_CONDUCT.md"), - HTMLURL: Ptr("https://github.com/octocat/Hello-World/blob/master/CODE_OF_CONDUCT.md"), + URL: new("https://api.github.com/repos/octocat/Hello-World/contents/CODE_OF_CONDUCT.md"), + HTMLURL: new("https://github.com/octocat/Hello-World/blob/master/CODE_OF_CONDUCT.md"), }, Contributing: &Metric{ - URL: Ptr("https://api.github.com/repos/octocat/Hello-World/contents/CONTRIBUTING"), - HTMLURL: Ptr("https://github.com/octocat/Hello-World/blob/master/CONTRIBUTING"), + URL: new("https://api.github.com/repos/octocat/Hello-World/contents/CONTRIBUTING"), + HTMLURL: new("https://github.com/octocat/Hello-World/blob/master/CONTRIBUTING"), }, IssueTemplate: &Metric{ - URL: Ptr("https://api.github.com/repos/octocat/Hello-World/contents/ISSUE_TEMPLATE"), - HTMLURL: Ptr("https://github.com/octocat/Hello-World/blob/master/ISSUE_TEMPLATE"), + URL: new("https://api.github.com/repos/octocat/Hello-World/contents/ISSUE_TEMPLATE"), + HTMLURL: new("https://github.com/octocat/Hello-World/blob/master/ISSUE_TEMPLATE"), }, PullRequestTemplate: &Metric{ - URL: Ptr("https://api.github.com/repos/octocat/Hello-World/contents/PULL_REQUEST_TEMPLATE"), - HTMLURL: Ptr("https://github.com/octocat/Hello-World/blob/master/PULL_REQUEST_TEMPLATE"), + URL: new("https://api.github.com/repos/octocat/Hello-World/contents/PULL_REQUEST_TEMPLATE"), + HTMLURL: new("https://github.com/octocat/Hello-World/blob/master/PULL_REQUEST_TEMPLATE"), }, License: &Metric{ - Name: Ptr("MIT License"), - Key: Ptr("mit"), - SPDXID: Ptr("MIT"), - URL: Ptr("https://api.github.com/licenses/mit"), - HTMLURL: Ptr("https://github.com/octocat/Hello-World/blob/master/LICENSE"), - NodeID: Ptr("MDc6TGljZW5zZW1pdA=="), + Name: new("MIT License"), + Key: new("mit"), + SPDXID: new("MIT"), + URL: new("https://api.github.com/licenses/mit"), + HTMLURL: new("https://github.com/octocat/Hello-World/blob/master/LICENSE"), + NodeID: new("MDc6TGljZW5zZW1pdA=="), }, Readme: &Metric{ - URL: Ptr("https://api.github.com/repos/octocat/Hello-World/contents/README.md"), - HTMLURL: Ptr("https://github.com/octocat/Hello-World/blob/master/README.md"), + URL: new("https://api.github.com/repos/octocat/Hello-World/contents/README.md"), + HTMLURL: new("https://github.com/octocat/Hello-World/blob/master/README.md"), }, }, } diff --git a/github/repos_contents_test.go b/github/repos_contents_test.go index b2890684a4d..e59dff65310 100644 --- a/github/repos_contents_test.go +++ b/github/repos_contents_test.go @@ -24,14 +24,14 @@ func TestRepositoryContent_GetContent(t *testing.T) { wantErr bool // whether an error is expected }{ { - encoding: Ptr(""), - content: Ptr("hello"), + encoding: new(""), + content: new("hello"), want: "hello", wantErr: false, }, { encoding: nil, - content: Ptr("hello"), + content: new("hello"), want: "hello", wantErr: false, }, @@ -42,19 +42,19 @@ func TestRepositoryContent_GetContent(t *testing.T) { wantErr: false, }, { - encoding: Ptr("base64"), - content: Ptr("aGVsbG8="), + encoding: new("base64"), + content: new("aGVsbG8="), want: "hello", wantErr: false, }, { - encoding: Ptr("bad"), - content: Ptr("aGVsbG8="), + encoding: new("bad"), + content: new("aGVsbG8="), want: "", wantErr: true, }, { - encoding: Ptr("none"), + encoding: new("none"), content: nil, want: "", wantErr: true, @@ -106,7 +106,7 @@ func TestRepositoriesService_GetReadme(t *testing.T) { if err != nil { t.Errorf("Repositories.GetReadme returned error: %v", err) } - want := &RepositoryContent{Type: Ptr("file"), Name: Ptr("README.md"), Size: Ptr(5362), Encoding: Ptr("base64"), Path: Ptr("README.md")} + want := &RepositoryContent{Type: new("file"), Name: new("README.md"), Size: new(5362), Encoding: new("base64"), Path: new("README.md")} if !cmp.Equal(readme, want) { t.Errorf("Repositories.GetReadme returned %+v, want %+v", readme, want) } @@ -678,7 +678,7 @@ func TestRepositoriesService_GetContents_File(t *testing.T) { if err != nil { t.Errorf("Repositories.GetContents returned error: %v", err) } - want := &RepositoryContent{Type: Ptr("file"), Name: Ptr("LICENSE"), Size: Ptr(20678), Encoding: Ptr("base64"), Path: Ptr("LICENSE")} + want := &RepositoryContent{Type: new("file"), Name: new("LICENSE"), Size: new(20678), Encoding: new("base64"), Path: new("LICENSE")} if !cmp.Equal(fileContents, want) { t.Errorf("Repositories.GetContents returned %+v, want %+v", fileContents, want) } @@ -782,8 +782,8 @@ func TestRepositoriesService_GetContents_Directory(t *testing.T) { 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")}, + {Type: new("dir"), Name: new("lib"), Path: new("lib")}, + {Type: new("file"), Name: new("LICENSE"), Size: new(20678), Path: new("LICENSE")}, } if !cmp.Equal(directoryContents, want) { t.Errorf("Repositories.GetContents_Directory returned %+v, want %+v", directoryContents, want) @@ -807,9 +807,9 @@ func TestRepositoriesService_CreateFile(t *testing.T) { }`) }) repositoryContentsOptions := &RepositoryContentFileOptions{ - Message: Ptr("m"), + Message: new("m"), Content: []byte("c"), - Committer: &CommitAuthor{Name: Ptr("n"), Email: Ptr("e")}, + Committer: &CommitAuthor{Name: new("n"), Email: new("e")}, } ctx := t.Context() createResponse, _, err := client.Repositories.CreateFile(ctx, "o", "r", "p", repositoryContentsOptions) @@ -817,10 +817,10 @@ func TestRepositoriesService_CreateFile(t *testing.T) { t.Errorf("Repositories.CreateFile returned error: %v", err) } want := &RepositoryContentResponse{ - Content: &RepositoryContent{Name: Ptr("p")}, + Content: &RepositoryContent{Name: new("p")}, Commit: Commit{ - Message: Ptr("m"), - SHA: Ptr("f5f369044773ff9c6383c087466d12adb6fa0828"), + Message: new("m"), + SHA: new("f5f369044773ff9c6383c087466d12adb6fa0828"), }, } if !cmp.Equal(createResponse, want) { @@ -859,10 +859,10 @@ func TestRepositoriesService_UpdateFile(t *testing.T) { }`) }) repositoryContentsOptions := &RepositoryContentFileOptions{ - Message: Ptr("m"), + Message: new("m"), Content: []byte("c"), - SHA: Ptr("f5f369044773ff9c6383c087466d12adb6fa0828"), - Committer: &CommitAuthor{Name: Ptr("n"), Email: Ptr("e")}, + SHA: new("f5f369044773ff9c6383c087466d12adb6fa0828"), + Committer: &CommitAuthor{Name: new("n"), Email: new("e")}, } ctx := t.Context() updateResponse, _, err := client.Repositories.UpdateFile(ctx, "o", "r", "p", repositoryContentsOptions) @@ -870,10 +870,10 @@ func TestRepositoriesService_UpdateFile(t *testing.T) { t.Errorf("Repositories.UpdateFile returned error: %v", err) } want := &RepositoryContentResponse{ - Content: &RepositoryContent{Name: Ptr("p")}, + Content: &RepositoryContent{Name: new("p")}, Commit: Commit{ - Message: Ptr("m"), - SHA: Ptr("f5f369044773ff9c6383c087466d12adb6fa0828"), + Message: new("m"), + SHA: new("f5f369044773ff9c6383c087466d12adb6fa0828"), }, } if !cmp.Equal(updateResponse, want) { @@ -910,9 +910,9 @@ func TestRepositoriesService_DeleteFile(t *testing.T) { }`) }) repositoryContentsOptions := &RepositoryContentFileOptions{ - Message: Ptr("m"), - SHA: Ptr("f5f369044773ff9c6383c087466d12adb6fa0828"), - Committer: &CommitAuthor{Name: Ptr("n"), Email: Ptr("e")}, + Message: new("m"), + SHA: new("f5f369044773ff9c6383c087466d12adb6fa0828"), + Committer: &CommitAuthor{Name: new("n"), Email: new("e")}, } ctx := t.Context() deleteResponse, _, err := client.Repositories.DeleteFile(ctx, "o", "r", "p", repositoryContentsOptions) @@ -922,8 +922,8 @@ func TestRepositoriesService_DeleteFile(t *testing.T) { want := &RepositoryContentResponse{ Content: nil, Commit: Commit{ - Message: Ptr("m"), - SHA: Ptr("f5f369044773ff9c6383c087466d12adb6fa0828"), + Message: new("m"), + SHA: new("f5f369044773ff9c6383c087466d12adb6fa0828"), }, } if !cmp.Equal(deleteResponse, want) { diff --git a/github/repos_deployment_branch_policies_test.go b/github/repos_deployment_branch_policies_test.go index 2da27aa5b42..cf4b3898f30 100644 --- a/github/repos_deployment_branch_policies_test.go +++ b/github/repos_deployment_branch_policies_test.go @@ -34,10 +34,10 @@ func TestRepositoriesService_ListDeploymentBranchPolicies(t *testing.T) { want := &DeploymentBranchPolicyResponse{ BranchPolicies: []*DeploymentBranchPolicy{ - {ID: Ptr(int64(1))}, - {ID: Ptr(int64(2))}, + {ID: new(int64(1))}, + {ID: new(int64(2))}, }, - TotalCount: Ptr(2), + TotalCount: new(2), } if !cmp.Equal(got, want) { t.Errorf("Repositories.ListDeploymentBranchPolicies = %+v, want %+v", got, want) @@ -72,7 +72,7 @@ func TestRepositoriesService_GetDeploymentBranchPolicy(t *testing.T) { t.Errorf("Repositories.GetDeploymentBranchPolicy returned error: %v", err) } - want := &DeploymentBranchPolicy{ID: Ptr(int64(1))} + want := &DeploymentBranchPolicy{ID: new(int64(1))} if !cmp.Equal(got, want) { t.Errorf("Repositories.GetDeploymentBranchPolicy = %+v, want %+v", got, want) } @@ -97,12 +97,12 @@ func TestRepositoriesService_CreateDeploymentBranchPolicy(t *testing.T) { }) ctx := t.Context() - got, _, err := client.Repositories.CreateDeploymentBranchPolicy(ctx, "o", "r", "e", CreateDeploymentBranchPolicyRequest{Name: "n", Type: Ptr("branch")}) + got, _, err := client.Repositories.CreateDeploymentBranchPolicy(ctx, "o", "r", "e", CreateDeploymentBranchPolicyRequest{Name: "n", Type: new("branch")}) if err != nil { t.Errorf("Repositories.CreateDeploymentBranchPolicy returned error: %v", err) } - want := &DeploymentBranchPolicy{ID: Ptr(int64(1)), Type: Ptr("branch")} + want := &DeploymentBranchPolicy{ID: new(int64(1)), Type: new("branch")} if !cmp.Equal(got, want) { t.Errorf("Repositories.CreateDeploymentBranchPolicy = %+v, want %+v", got, want) } @@ -132,7 +132,7 @@ func TestRepositoriesService_UpdateDeploymentBranchPolicy(t *testing.T) { t.Errorf("Repositories.UpdateDeploymentBranchPolicy returned error: %v", err) } - want := &DeploymentBranchPolicy{ID: Ptr(int64(1))} + want := &DeploymentBranchPolicy{ID: new(int64(1))} if !cmp.Equal(got, want) { t.Errorf("Repositories.UpdateDeploymentBranchPolicy = %+v, want %+v", got, want) } diff --git a/github/repos_deployment_protection_rules_test.go b/github/repos_deployment_protection_rules_test.go index d3179bc69df..adee3357f80 100644 --- a/github/repos_deployment_protection_rules_test.go +++ b/github/repos_deployment_protection_rules_test.go @@ -30,10 +30,10 @@ func TestRepositoriesService_GetAllDeploymentProtectionRules(t *testing.T) { want := &ListDeploymentProtectionRuleResponse{ ProtectionRules: []*CustomDeploymentProtectionRule{ - {ID: Ptr(int64(3)), NodeID: Ptr("IEH37kRlcGxveW1lbnRTdGF0ddiv"), Enabled: Ptr(true), App: &CustomDeploymentProtectionRuleApp{ID: Ptr(int64(1)), NodeID: Ptr("GHT58kRlcGxveW1lbnRTdTY!bbcy"), Slug: Ptr("a-custom-app"), IntegrationURL: Ptr("https://api.github.com/apps/a-custom-app")}}, - {ID: Ptr(int64(4)), NodeID: Ptr("MDE2OkRlcGxveW1lbnRTdHJ41128"), Enabled: Ptr(true), App: &CustomDeploymentProtectionRuleApp{ID: Ptr(int64(1)), NodeID: Ptr("UHVE67RlcGxveW1lbnRTdTY!jfeuy"), Slug: Ptr("another-custom-app"), IntegrationURL: Ptr("https://api.github.com/apps/another-custom-app")}}, + {ID: new(int64(3)), NodeID: new("IEH37kRlcGxveW1lbnRTdGF0ddiv"), Enabled: new(true), App: &CustomDeploymentProtectionRuleApp{ID: new(int64(1)), NodeID: new("GHT58kRlcGxveW1lbnRTdTY!bbcy"), Slug: new("a-custom-app"), IntegrationURL: new("https://api.github.com/apps/a-custom-app")}}, + {ID: new(int64(4)), NodeID: new("MDE2OkRlcGxveW1lbnRTdHJ41128"), Enabled: new(true), App: &CustomDeploymentProtectionRuleApp{ID: new(int64(1)), NodeID: new("UHVE67RlcGxveW1lbnRTdTY!jfeuy"), Slug: new("another-custom-app"), IntegrationURL: new("https://api.github.com/apps/another-custom-app")}}, }, - TotalCount: Ptr(2), + TotalCount: new(2), } if !cmp.Equal(got, want) { t.Errorf("Repositories.GetAllDeploymentProtectionRules = %+v, want %+v", got, want) @@ -54,7 +54,7 @@ func TestRepositoriesService_CreateCustomDeploymentProtectionRule(t *testing.T) client, mux, _ := setup(t) input := &CustomDeploymentProtectionRuleRequest{ - IntegrationID: Ptr(int64(5)), + IntegrationID: new(int64(5)), } mux.HandleFunc("/repos/o/r/environments/e/deployment_protection_rules", func(w http.ResponseWriter, r *http.Request) { @@ -70,14 +70,14 @@ func TestRepositoriesService_CreateCustomDeploymentProtectionRule(t *testing.T) } want := &CustomDeploymentProtectionRule{ - ID: Ptr(int64(3)), - NodeID: Ptr("IEH37kRlcGxveW1lbnRTdGF0ddiv"), - Enabled: Ptr(true), + ID: new(int64(3)), + NodeID: new("IEH37kRlcGxveW1lbnRTdGF0ddiv"), + Enabled: new(true), App: &CustomDeploymentProtectionRuleApp{ - ID: Ptr(int64(1)), - NodeID: Ptr("GHT58kRlcGxveW1lbnRTdTY!bbcy"), - Slug: Ptr("a-custom-app"), - IntegrationURL: Ptr("https://api.github.com/apps/a-custom-app"), + ID: new(int64(1)), + NodeID: new("GHT58kRlcGxveW1lbnRTdTY!bbcy"), + Slug: new("a-custom-app"), + IntegrationURL: new("https://api.github.com/apps/a-custom-app"), }, } if !cmp.Equal(got, want) { @@ -120,10 +120,10 @@ func TestRepositoriesService_ListCustomDeploymentRuleIntegrations(t *testing.T) } want := &ListCustomDeploymentRuleIntegrationsResponse{ - TotalCount: Ptr(2), + TotalCount: new(2), AvailableIntegrations: []*CustomDeploymentProtectionRuleApp{ - {ID: Ptr(int64(1)), NodeID: Ptr("GHT58kRlcGxveW1lbnRTdTY!bbcy"), Slug: Ptr("a-custom-app"), IntegrationURL: Ptr("https://api.github.com/apps/a-custom-app")}, - {ID: Ptr(int64(2)), NodeID: Ptr("UHVE67RlcGxveW1lbnRTdTY!jfeuy"), Slug: Ptr("another-custom-app"), IntegrationURL: Ptr("https://api.github.com/apps/another-custom-app")}, + {ID: new(int64(1)), NodeID: new("GHT58kRlcGxveW1lbnRTdTY!bbcy"), Slug: new("a-custom-app"), IntegrationURL: new("https://api.github.com/apps/a-custom-app")}, + {ID: new(int64(2)), NodeID: new("UHVE67RlcGxveW1lbnRTdTY!jfeuy"), Slug: new("another-custom-app"), IntegrationURL: new("https://api.github.com/apps/another-custom-app")}, }, } if !cmp.Equal(got, want) { @@ -160,14 +160,14 @@ func TestRepositoriesService_GetCustomDeploymentProtectionRule(t *testing.T) { } want := &CustomDeploymentProtectionRule{ - ID: Ptr(int64(1)), - NodeID: Ptr("IEH37kRlcGxveW1lbnRTdGF0ddiv"), - Enabled: Ptr(true), + ID: new(int64(1)), + NodeID: new("IEH37kRlcGxveW1lbnRTdGF0ddiv"), + Enabled: new(true), App: &CustomDeploymentProtectionRuleApp{ - ID: Ptr(int64(1)), - NodeID: Ptr("GHT58kRlcGxveW1lbnRTdTY!bbcy"), - Slug: Ptr("a-custom-app"), - IntegrationURL: Ptr("https://api.github.com/apps/a-custom-app"), + ID: new(int64(1)), + NodeID: new("GHT58kRlcGxveW1lbnRTdTY!bbcy"), + Slug: new("a-custom-app"), + IntegrationURL: new("https://api.github.com/apps/a-custom-app"), }, } diff --git a/github/repos_deployments_test.go b/github/repos_deployments_test.go index f1fda8c9258..8d11d3e1d3e 100644 --- a/github/repos_deployments_test.go +++ b/github/repos_deployments_test.go @@ -31,7 +31,7 @@ func TestRepositoriesService_ListDeployments(t *testing.T) { t.Errorf("Repositories.ListDeployments returned error: %v", err) } - want := []*Deployment{{ID: Ptr(int64(1))}, {ID: Ptr(int64(2))}} + want := []*Deployment{{ID: new(int64(1))}, {ID: new(int64(2))}} if !cmp.Equal(deployments, want) { t.Errorf("Repositories.ListDeployments returned %+v, want %+v", deployments, want) } @@ -66,7 +66,7 @@ func TestRepositoriesService_GetDeployment(t *testing.T) { t.Errorf("Repositories.GetDeployment returned error: %v", err) } - want := &Deployment{ID: Ptr(int64(3))} + want := &Deployment{ID: new(int64(3))} if !cmp.Equal(deployment, want) { t.Errorf("Repositories.GetDeployment returned %+v, want %+v", deployment, want) @@ -91,7 +91,7 @@ func TestRepositoriesService_CreateDeployment(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - input := DeploymentRequest{Ref: "1111", Task: Ptr("deploy"), TransientEnvironment: Ptr(true)} + input := DeploymentRequest{Ref: "1111", Task: new("deploy"), TransientEnvironment: new(true)} mux.HandleFunc("/repos/o/r/deployments", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "POST") @@ -107,7 +107,7 @@ func TestRepositoriesService_CreateDeployment(t *testing.T) { t.Errorf("Repositories.CreateDeployment returned error: %v", err) } - want := &Deployment{Ref: Ptr("1111"), Task: Ptr("deploy")} + want := &Deployment{Ref: new("1111"), Task: new("deploy")} if !cmp.Equal(deployment, want) { t.Errorf("Repositories.CreateDeployment returned %+v, want %+v", deployment, want) } @@ -183,7 +183,7 @@ func TestRepositoriesService_ListDeploymentStatuses(t *testing.T) { t.Errorf("Repositories.ListDeploymentStatuses returned error: %v", err) } - want := []*DeploymentStatus{{ID: Ptr(int64(1))}, {ID: Ptr(int64(2))}} + want := []*DeploymentStatus{{ID: new(int64(1))}, {ID: new(int64(2))}} if !cmp.Equal(statuses, want) { t.Errorf("Repositories.ListDeploymentStatuses returned %+v, want %+v", statuses, want) } @@ -220,7 +220,7 @@ func TestRepositoriesService_GetDeploymentStatus(t *testing.T) { t.Errorf("Repositories.GetDeploymentStatus returned error: %v", err) } - want := &DeploymentStatus{ID: Ptr(int64(4))} + want := &DeploymentStatus{ID: new(int64(4))} if !cmp.Equal(deploymentStatus, want) { t.Errorf("Repositories.GetDeploymentStatus returned %+v, want %+v", deploymentStatus, want) } @@ -244,7 +244,7 @@ func TestRepositoriesService_CreateDeploymentStatus(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - input := DeploymentStatusRequest{State: "inactive", Description: Ptr("deploy"), AutoInactive: Ptr(false)} + input := DeploymentStatusRequest{State: "inactive", Description: new("deploy"), AutoInactive: new(false)} mux.HandleFunc("/repos/o/r/deployments/1/statuses", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "POST") @@ -260,7 +260,7 @@ func TestRepositoriesService_CreateDeploymentStatus(t *testing.T) { t.Errorf("Repositories.CreateDeploymentStatus returned error: %v", err) } - want := &DeploymentStatus{State: Ptr("inactive"), Description: Ptr("deploy")} + want := &DeploymentStatus{State: new("inactive"), Description: new("deploy")} if !cmp.Equal(deploymentStatus, want) { t.Errorf("Repositories.CreateDeploymentStatus returned %+v, want %+v", deploymentStatus, want) } diff --git a/github/repos_environments.go b/github/repos_environments.go index 5e892e5f59c..59b749d7c81 100644 --- a/github/repos_environments.go +++ b/github/repos_environments.go @@ -161,10 +161,10 @@ func (s *RepositoriesService) GetEnvironment(ctx context.Context, owner, repo, n func (c CreateUpdateEnvironment) MarshalJSON() ([]byte, error) { type alias CreateUpdateEnvironment if c.WaitTimer == nil { - c.WaitTimer = Ptr(0) + c.WaitTimer = new(0) } if c.CanAdminsBypass == nil { - c.CanAdminsBypass = Ptr(true) + c.CanAdminsBypass = new(true) } return json.Marshal(&struct { alias diff --git a/github/repos_environments_test.go b/github/repos_environments_test.go index 2dddb226bad..0ee2ef38bea 100644 --- a/github/repos_environments_test.go +++ b/github/repos_environments_test.go @@ -23,17 +23,17 @@ func TestRequiredReviewer_UnmarshalJSON(t *testing.T) { }{ "User Reviewer": { data: []byte(`[{"type": "User", "reviewer": {"id": 1,"login": "octocat"}}]`), - wantRule: []*RequiredReviewer{{Type: Ptr("User"), Reviewer: &User{ID: Ptr(int64(1)), Login: Ptr("octocat")}}}, + wantRule: []*RequiredReviewer{{Type: new("User"), Reviewer: &User{ID: new(int64(1)), Login: new("octocat")}}}, wantError: false, }, "Team Reviewer": { data: []byte(`[{"type": "Team", "reviewer": {"id": 1, "name": "Justice League"}}]`), - wantRule: []*RequiredReviewer{{Type: Ptr("Team"), Reviewer: &Team{ID: Ptr(int64(1)), Name: Ptr("Justice League")}}}, + wantRule: []*RequiredReviewer{{Type: new("Team"), Reviewer: &Team{ID: new(int64(1)), Name: new("Justice League")}}}, wantError: false, }, "Both Types Reviewer": { data: []byte(`[{"type": "User", "reviewer": {"id": 1,"login": "octocat"}},{"type": "Team", "reviewer": {"id": 1, "name": "Justice League"}}]`), - wantRule: []*RequiredReviewer{{Type: Ptr("User"), Reviewer: &User{ID: Ptr(int64(1)), Login: Ptr("octocat")}}, {Type: Ptr("Team"), Reviewer: &Team{ID: Ptr(int64(1)), Name: Ptr("Justice League")}}}, + wantRule: []*RequiredReviewer{{Type: new("User"), Reviewer: &User{ID: new(int64(1)), Login: new("octocat")}}, {Type: new("Team"), Reviewer: &Team{ID: new(int64(1)), Name: new("Justice League")}}}, wantError: false, }, "Empty JSON Object": { @@ -63,12 +63,12 @@ func TestRequiredReviewer_UnmarshalJSON(t *testing.T) { }, "Wrong ID Type in User Object": { data: []byte(`[{"type": "User", "reviewer": {"id": "string"}}]`), - wantRule: []*RequiredReviewer{{Type: Ptr("User"), Reviewer: nil}}, + wantRule: []*RequiredReviewer{{Type: new("User"), Reviewer: nil}}, wantError: true, }, "Wrong ID Type in Team Object": { data: []byte(`[{"type": "Team", "reviewer": {"id": "string"}}]`), - wantRule: []*RequiredReviewer{{Type: Ptr("Team"), Reviewer: nil}}, + wantRule: []*RequiredReviewer{{Type: new("Team"), Reviewer: nil}}, wantError: true, }, "Wrong Type of Reviewer": { @@ -125,7 +125,7 @@ func TestRepositoriesService_ListEnvironments(t *testing.T) { if err != nil { t.Errorf("Repositories.ListEnvironments returned error: %v", err) } - want := &EnvResponse{TotalCount: Ptr(1), Environments: []*Environment{{ID: Ptr(int64(1))}, {ID: Ptr(int64(2))}}} + want := &EnvResponse{TotalCount: new(1), Environments: []*Environment{{ID: new(int64(1))}, {ID: new(int64(2))}}} if !cmp.Equal(environments, want) { t.Errorf("Repositories.ListEnvironments returned %+v, want %+v", environments, want) } @@ -160,7 +160,7 @@ func TestRepositoriesService_GetEnvironment(t *testing.T) { t.Errorf("Repositories.GetEnvironment returned error: %v\n%v", err, resp.Body) } - want := &Environment{ID: Ptr(int64(1)), Name: Ptr("staging"), DeploymentBranchPolicy: &BranchPolicy{ProtectedBranches: Ptr(true), CustomBranchPolicies: Ptr(false)}, CanAdminsBypass: Ptr(false)} + want := &Environment{ID: new(int64(1)), Name: new("staging"), DeploymentBranchPolicy: &BranchPolicy{ProtectedBranches: new(true), CustomBranchPolicies: new(false)}, CanAdminsBypass: new(false)} if !cmp.Equal(release, want) { t.Errorf("Repositories.GetEnvironment returned %+v, want %+v", release, want) } @@ -185,12 +185,12 @@ func TestRepositoriesService_CreateEnvironment(t *testing.T) { client, mux, _ := setup(t) input := &CreateUpdateEnvironment{ - WaitTimer: Ptr(30), + WaitTimer: new(30), } mux.HandleFunc("/repos/o/r/environments/e", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "PUT") - want := &CreateUpdateEnvironment{WaitTimer: Ptr(30), CanAdminsBypass: Ptr(true)} + want := &CreateUpdateEnvironment{WaitTimer: new(30), CanAdminsBypass: new(true)} testJSONBody(t, r, want) fmt.Fprint(w, `{"id": 1, "name": "staging", "protection_rules": [{"id": 1, "type": "wait_timer", "wait_timer": 30}]}`) }) @@ -201,7 +201,7 @@ func TestRepositoriesService_CreateEnvironment(t *testing.T) { t.Errorf("Repositories.CreateUpdateEnvironment returned error: %v", err) } - want := &Environment{ID: Ptr(int64(1)), Name: Ptr("staging"), ProtectionRules: []*ProtectionRule{{ID: Ptr(int64(1)), Type: Ptr("wait_timer"), WaitTimer: Ptr(30)}}} + want := &Environment{ID: new(int64(1)), Name: new("staging"), ProtectionRules: []*ProtectionRule{{ID: new(int64(1)), Type: new("wait_timer"), WaitTimer: new(30)}}} if !cmp.Equal(release, want) { t.Errorf("Repositories.CreateUpdateEnvironment returned %+v, want %+v", release, want) } @@ -246,7 +246,7 @@ func TestRepositoriesService_CreateEnvironment_noEnterprise(t *testing.T) { t.Errorf("Repositories.CreateUpdateEnvironment returned error: %v", err) } - want := &Environment{ID: Ptr(int64(1)), Name: Ptr("staging"), ProtectionRules: []*ProtectionRule{}} + want := &Environment{ID: new(int64(1)), Name: new("staging"), ProtectionRules: []*ProtectionRule{}} if !cmp.Equal(release, want) { t.Errorf("Repositories.CreateUpdateEnvironment returned %+v, want %+v", release, want) } @@ -258,8 +258,8 @@ func TestRepositoriesService_createNewEnvNoEnterprise(t *testing.T) { input := &CreateUpdateEnvironment{ DeploymentBranchPolicy: &BranchPolicy{ - ProtectedBranches: Ptr(true), - CustomBranchPolicies: Ptr(false), + ProtectedBranches: new(true), + CustomBranchPolicies: new(false), }, } @@ -276,18 +276,18 @@ func TestRepositoriesService_createNewEnvNoEnterprise(t *testing.T) { } want := &Environment{ - ID: Ptr(int64(1)), - Name: Ptr("staging"), + ID: new(int64(1)), + Name: new("staging"), ProtectionRules: []*ProtectionRule{ { - ID: Ptr(int64(1)), - NodeID: Ptr("id"), - Type: Ptr("branch_policy"), + ID: new(int64(1)), + NodeID: new("id"), + Type: new("branch_policy"), }, }, DeploymentBranchPolicy: &BranchPolicy{ - ProtectedBranches: Ptr(true), - CustomBranchPolicies: Ptr(false), + ProtectedBranches: new(true), + CustomBranchPolicies: new(false), }, } if !cmp.Equal(release, want) { diff --git a/github/repos_forks_test.go b/github/repos_forks_test.go index 393e4d669b6..bfcb9cdaada 100644 --- a/github/repos_forks_test.go +++ b/github/repos_forks_test.go @@ -38,7 +38,7 @@ func TestRepositoriesService_ListForks(t *testing.T) { t.Errorf("Repositories.ListForks returned error: %v", err) } - want := []*Repository{{ID: Ptr(int64(1))}, {ID: Ptr(int64(2))}} + want := []*Repository{{ID: new(int64(1))}, {ID: new(int64(2))}} if !cmp.Equal(repos, want) { t.Errorf("Repositories.ListForks returned %+v, want %+v", repos, want) } @@ -85,7 +85,7 @@ func TestRepositoriesService_CreateFork(t *testing.T) { t.Errorf("Repositories.CreateFork returned error: %v", err) } - want := &Repository{ID: Ptr(int64(1))} + want := &Repository{ID: new(int64(1))} if !cmp.Equal(repo, want) { t.Errorf("Repositories.CreateFork returned %+v, want %+v", repo, want) } @@ -125,7 +125,7 @@ func TestRepositoriesService_CreateFork_deferred(t *testing.T) { t.Errorf("Repositories.CreateFork returned error: %v (want AcceptedError)", err) } - want := &Repository{ID: Ptr(int64(1))} + want := &Repository{ID: new(int64(1))} if !cmp.Equal(repo, want) { t.Errorf("Repositories.CreateFork returned %+v, want %+v", repo, want) } diff --git a/github/repos_hooks_configuration_test.go b/github/repos_hooks_configuration_test.go index 81bae011c3b..abd7baf9c88 100644 --- a/github/repos_hooks_configuration_test.go +++ b/github/repos_hooks_configuration_test.go @@ -29,10 +29,10 @@ func TestRepositoriesService_GetHookConfiguration(t *testing.T) { } want := &HookConfig{ - ContentType: Ptr("json"), - InsecureSSL: Ptr("0"), - Secret: Ptr("********"), - URL: Ptr("https://example.com/webhook"), + ContentType: new("json"), + InsecureSSL: new("0"), + Secret: new("********"), + URL: new("https://example.com/webhook"), } if !cmp.Equal(config, want) { t.Errorf("Repositories.GetHookConfiguration returned %+v, want %+v", config, want) @@ -81,10 +81,10 @@ func TestRepositoriesService_UpdateHookConfiguration(t *testing.T) { } want := &HookConfig{ - ContentType: Ptr("json"), - InsecureSSL: Ptr("0"), - Secret: Ptr("********"), - URL: Ptr("https://example.com/webhook"), + ContentType: new("json"), + InsecureSSL: new("0"), + Secret: new("********"), + URL: new("https://example.com/webhook"), } if !cmp.Equal(config, want) { t.Errorf("Repositories.UpdateHookConfiguration returned %+v, want %+v", config, want) diff --git a/github/repos_hooks_deliveries_test.go b/github/repos_hooks_deliveries_test.go index df72de213f3..4e8853d8808 100644 --- a/github/repos_hooks_deliveries_test.go +++ b/github/repos_hooks_deliveries_test.go @@ -33,7 +33,7 @@ func TestRepositoriesService_ListHookDeliveries(t *testing.T) { t.Errorf("Repositories.ListHookDeliveries returned error: %v", err) } - want := []*HookDelivery{{ID: Ptr(int64(1))}, {ID: Ptr(int64(2))}} + want := []*HookDelivery{{ID: new(int64(1))}, {ID: new(int64(2))}} if d := cmp.Diff(hooks, want); d != "" { t.Errorf("Repositories.ListHooks want (-), got (+):\n%v", d) } @@ -77,7 +77,7 @@ func TestRepositoriesService_GetHookDelivery(t *testing.T) { t.Errorf("Repositories.GetHookDelivery returned error: %v", err) } - want := &HookDelivery{ID: Ptr(int64(1))} + want := &HookDelivery{ID: new(int64(1))} if !cmp.Equal(hook, want) { t.Errorf("Repositories.GetHookDelivery returned %+v, want %+v", hook, want) } @@ -121,7 +121,7 @@ func TestRepositoriesService_RedeliverHookDelivery(t *testing.T) { t.Errorf("Repositories.RedeliverHookDelivery returned error: %v", err) } - want := &HookDelivery{ID: Ptr(int64(1))} + want := &HookDelivery{ID: new(int64(1))} if !cmp.Equal(hook, want) { t.Errorf("Repositories.RedeliverHookDelivery returned %+v, want %+v", hook, want) } @@ -238,7 +238,7 @@ func TestHookDelivery_ParsePayload_invalidEvent(t *testing.T) { p := json.RawMessage(nil) d := &HookDelivery{ - Event: Ptr("some_invalid_event"), + Event: new("some_invalid_event"), Request: &HookRequest{ RawPayload: &p, }, @@ -255,7 +255,7 @@ func TestHookDelivery_ParsePayload_invalidPayload(t *testing.T) { p := json.RawMessage([]byte(`{"check_run":{"id":"invalid"}}`)) d := &HookDelivery{ - Event: Ptr("check_run"), + Event: new("check_run"), Request: &HookRequest{ RawPayload: &p, }, diff --git a/github/repos_hooks_test.go b/github/repos_hooks_test.go index b35294fb5dc..29ec04efe3c 100644 --- a/github/repos_hooks_test.go +++ b/github/repos_hooks_test.go @@ -32,7 +32,7 @@ func TestRepositoriesService_CreateHook(t *testing.T) { t.Errorf("Repositories.CreateHook returned error: %v", err) } - want := &Hook{ID: Ptr(int64(1))} + want := &Hook{ID: new(int64(1))} if !cmp.Equal(hook, want) { t.Errorf("Repositories.CreateHook returned %+v, want %+v", hook, want) } @@ -74,7 +74,7 @@ func TestRepositoriesService_ListHooks(t *testing.T) { t.Errorf("Repositories.ListHooks returned error: %v", err) } - want := []*Hook{{ID: Ptr(int64(1))}, {ID: Ptr(int64(2))}} + want := []*Hook{{ID: new(int64(1))}, {ID: new(int64(2))}} if !cmp.Equal(hooks, want) { t.Errorf("Repositories.ListHooks returned %+v, want %+v", hooks, want) } @@ -128,7 +128,7 @@ func TestRepositoriesService_GetHook(t *testing.T) { t.Errorf("Repositories.GetHook returned error: %v", err) } - want := &Hook{ID: Ptr(int64(1))} + want := &Hook{ID: new(int64(1))} if !cmp.Equal(hook, want) { t.Errorf("Repositories.GetHook returned %+v, want %+v", hook, want) } @@ -176,7 +176,7 @@ func TestRepositoriesService_EditHook(t *testing.T) { t.Errorf("Repositories.EditHook returned error: %v", err) } - want := &Hook{ID: Ptr(int64(1))} + want := &Hook{ID: new(int64(1))} if !cmp.Equal(hook, want) { t.Errorf("Repositories.EditHook returned %+v, want %+v", hook, want) } diff --git a/github/repos_immutable_releases_test.go b/github/repos_immutable_releases_test.go index 9a5d352ba88..a6a23fa494e 100644 --- a/github/repos_immutable_releases_test.go +++ b/github/repos_immutable_releases_test.go @@ -79,7 +79,7 @@ func TestRepositoriesService_AreImmutableReleasesEnabled(t *testing.T) { if err != nil { t.Errorf("Repositories.AreImmutableReleasesEnabled returned error: %v", err) } - want := &RepoImmutableReleasesStatus{Enabled: Ptr(true), EnforcedByOwner: Ptr(false)} + want := &RepoImmutableReleasesStatus{Enabled: new(true), EnforcedByOwner: new(false)} if !cmp.Equal(status, want) { t.Errorf("Repositories.AreImmutableReleasesEnabled returned %+v, want %+v", status, want) } diff --git a/github/repos_invitations_test.go b/github/repos_invitations_test.go index 07d022a1f5c..6c78a8124c9 100644 --- a/github/repos_invitations_test.go +++ b/github/repos_invitations_test.go @@ -30,7 +30,7 @@ func TestRepositoriesService_ListInvitations(t *testing.T) { t.Errorf("Repositories.ListInvitations returned error: %v", err) } - want := []*RepositoryInvitation{{ID: Ptr(int64(1))}, {ID: Ptr(int64(2))}} + want := []*RepositoryInvitation{{ID: new(int64(1))}, {ID: new(int64(2))}} if !cmp.Equal(got, want) { t.Errorf("Repositories.ListInvitations = %+v, want %+v", got, want) } @@ -91,7 +91,7 @@ func TestRepositoriesService_UpdateInvitation(t *testing.T) { t.Errorf("Repositories.UpdateInvitation returned error: %v", err) } - want := &RepositoryInvitation{ID: Ptr(int64(1))} + want := &RepositoryInvitation{ID: new(int64(1))} if !cmp.Equal(got, want) { t.Errorf("Repositories.UpdateInvitation = %+v, want %+v", got, want) } diff --git a/github/repos_keys_test.go b/github/repos_keys_test.go index cee855a828e..c340113a235 100644 --- a/github/repos_keys_test.go +++ b/github/repos_keys_test.go @@ -30,7 +30,7 @@ func TestRepositoriesService_ListKeys(t *testing.T) { t.Errorf("Repositories.ListKeys returned error: %v", err) } - want := []*Key{{ID: Ptr(int64(1))}} + want := []*Key{{ID: new(int64(1))}} if !cmp.Equal(keys, want) { t.Errorf("Repositories.ListKeys returned %+v, want %+v", keys, want) } @@ -74,7 +74,7 @@ func TestRepositoriesService_GetKey(t *testing.T) { t.Errorf("Repositories.GetKey returned error: %v", err) } - want := &Key{ID: Ptr(int64(1))} + want := &Key{ID: new(int64(1))} if !cmp.Equal(key, want) { t.Errorf("Repositories.GetKey returned %+v, want %+v", key, want) } @@ -107,7 +107,7 @@ func TestRepositoriesService_CreateKey(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - input := &Key{Key: Ptr("k"), Title: Ptr("t")} + input := &Key{Key: new("k"), Title: new("t")} mux.HandleFunc("/repos/o/r/keys", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "POST") @@ -121,7 +121,7 @@ func TestRepositoriesService_CreateKey(t *testing.T) { t.Errorf("Repositories.CreateKey returned error: %v", err) } - want := &Key{ID: Ptr(int64(1))} + want := &Key{ID: new(int64(1))} if !cmp.Equal(key, want) { t.Errorf("Repositories.CreateKey returned %+v, want %+v", key, want) } diff --git a/github/repos_merging_test.go b/github/repos_merging_test.go index f71a65741d6..09c1e2d0dd8 100644 --- a/github/repos_merging_test.go +++ b/github/repos_merging_test.go @@ -20,7 +20,7 @@ func TestRepositoriesService_Merge(t *testing.T) { input := RepositoryMergeRequest{ Base: "b", Head: "h", - CommitMessage: Ptr("c"), + CommitMessage: new("c"), } mux.HandleFunc("/repos/o/r/merges", func(w http.ResponseWriter, r *http.Request) { @@ -35,7 +35,7 @@ func TestRepositoriesService_Merge(t *testing.T) { t.Errorf("Repositories.Merge returned error: %v", err) } - want := &RepositoryCommit{SHA: Ptr("s")} + want := &RepositoryCommit{SHA: new("s")} if !cmp.Equal(commit, want) { t.Errorf("Repositories.Merge returned %+v, want %+v", commit, want) } @@ -75,7 +75,7 @@ func TestRepositoriesService_MergeUpstream(t *testing.T) { t.Errorf("Repositories.MergeUpstream returned error: %v", err) } - want := &RepoMergeUpstreamResult{MergeType: Ptr("m")} + want := &RepoMergeUpstreamResult{MergeType: new("m")} if !cmp.Equal(result, want) { t.Errorf("Repositories.MergeUpstream returned %+v, want %+v", result, want) } diff --git a/github/repos_pages_test.go b/github/repos_pages_test.go index 227cbcb688b..2b404ff5d35 100644 --- a/github/repos_pages_test.go +++ b/github/repos_pages_test.go @@ -18,18 +18,18 @@ func TestRepositoriesService_EnablePagesLegacy(t *testing.T) { client, mux, _ := setup(t) input := &Pages{ - BuildType: Ptr("legacy"), + BuildType: new("legacy"), Source: &PagesSource{ - Branch: Ptr("master"), - Path: Ptr("/"), + Branch: new("master"), + Path: new("/"), }, - CNAME: Ptr("www.example.com"), // not passed along. + CNAME: new("www.example.com"), // not passed along. } mux.HandleFunc("/repos/o/r/pages", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "POST") testHeader(t, r, "Accept", mediaTypeEnablePagesAPIPreview) - want := &createPagesRequest{BuildType: Ptr("legacy"), Source: &PagesSource{Branch: Ptr("master"), Path: Ptr("/")}} + want := &createPagesRequest{BuildType: new("legacy"), Source: &PagesSource{Branch: new("master"), Path: new("/")}} testJSONBody(t, r, want) fmt.Fprint(w, `{"url":"u","status":"s","cname":"c","custom_404":false,"html_url":"h","build_type": "legacy","source": {"branch":"master", "path":"/"}}`) @@ -41,7 +41,7 @@ func TestRepositoriesService_EnablePagesLegacy(t *testing.T) { t.Errorf("Repositories.EnablePages returned error: %v", err) } - want := &Pages{URL: Ptr("u"), Status: Ptr("s"), CNAME: Ptr("c"), Custom404: Ptr(false), HTMLURL: Ptr("h"), BuildType: Ptr("legacy"), Source: &PagesSource{Branch: Ptr("master"), Path: Ptr("/")}} + want := &Pages{URL: new("u"), Status: new("s"), CNAME: new("c"), Custom404: new(false), HTMLURL: new("h"), BuildType: new("legacy"), Source: &PagesSource{Branch: new("master"), Path: new("/")}} if !cmp.Equal(page, want) { t.Errorf("Repositories.EnablePages returned %v, want %v", page, want) @@ -71,14 +71,14 @@ func TestRepositoriesService_EnablePagesWorkflow(t *testing.T) { client, mux, _ := setup(t) input := &Pages{ - BuildType: Ptr("workflow"), - CNAME: Ptr("www.example.com"), // not passed along. + BuildType: new("workflow"), + CNAME: new("www.example.com"), // not passed along. } mux.HandleFunc("/repos/o/r/pages", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "POST") testHeader(t, r, "Accept", mediaTypeEnablePagesAPIPreview) - want := &createPagesRequest{BuildType: Ptr("workflow")} + want := &createPagesRequest{BuildType: new("workflow")} testJSONBody(t, r, want) fmt.Fprint(w, `{"url":"u","status":"s","cname":"c","custom_404":false,"html_url":"h","build_type": "workflow"}`) }) @@ -89,7 +89,7 @@ func TestRepositoriesService_EnablePagesWorkflow(t *testing.T) { t.Errorf("Repositories.EnablePages returned error: %v", err) } - want := &Pages{URL: Ptr("u"), Status: Ptr("s"), CNAME: Ptr("c"), Custom404: Ptr(false), HTMLURL: Ptr("h"), BuildType: Ptr("workflow")} + want := &Pages{URL: new("u"), Status: new("s"), CNAME: new("c"), Custom404: new(false), HTMLURL: new("h"), BuildType: new("workflow")} if !cmp.Equal(page, want) { t.Errorf("Repositories.EnablePages returned %v, want %v", page, want) @@ -115,9 +115,9 @@ func TestRepositoriesService_UpdatePagesLegacy(t *testing.T) { client, mux, _ := setup(t) input := &PagesUpdate{ - CNAME: Ptr("www.example.com"), - BuildType: Ptr("legacy"), - Source: &PagesSource{Branch: Ptr("gh-pages")}, + CNAME: new("www.example.com"), + BuildType: new("legacy"), + Source: &PagesSource{Branch: new("gh-pages")}, } mux.HandleFunc("/repos/o/r/pages", func(w http.ResponseWriter, r *http.Request) { @@ -148,8 +148,8 @@ func TestRepositoriesService_UpdatePagesWorkflow(t *testing.T) { client, mux, _ := setup(t) input := &PagesUpdate{ - CNAME: Ptr("www.example.com"), - BuildType: Ptr("workflow"), + CNAME: new("www.example.com"), + BuildType: new("workflow"), } mux.HandleFunc("/repos/o/r/pages", func(w http.ResponseWriter, r *http.Request) { @@ -180,7 +180,7 @@ func TestRepositoriesService_UpdatePagesGHES(t *testing.T) { client, mux, _ := setup(t) input := &PagesUpdateWithoutCNAME{ - BuildType: Ptr("workflow"), + BuildType: new("workflow"), } mux.HandleFunc("/repos/o/r/pages", func(w http.ResponseWriter, r *http.Request) { @@ -211,7 +211,7 @@ func TestRepositoriesService_UpdatePages_NullCNAME(t *testing.T) { client, mux, _ := setup(t) input := &PagesUpdate{ - Source: &PagesSource{Branch: Ptr("gh-pages")}, + Source: &PagesSource{Branch: new("gh-pages")}, } mux.HandleFunc("/repos/o/r/pages", func(w http.ResponseWriter, r *http.Request) { @@ -268,7 +268,7 @@ func TestRepositoriesService_GetPagesInfo(t *testing.T) { t.Errorf("Repositories.GetPagesInfo returned error: %v", err) } - want := &Pages{URL: Ptr("u"), Status: Ptr("s"), CNAME: Ptr("c"), Custom404: Ptr(false), HTMLURL: Ptr("h"), Public: Ptr(true), HTTPSCertificate: &PagesHTTPSCertificate{State: Ptr("approved"), Description: Ptr("Certificate is approved"), Domains: []string{"developer.github.com"}, ExpiresAt: Ptr("2021-05-22")}, HTTPSEnforced: Ptr(true)} + want := &Pages{URL: new("u"), Status: new("s"), CNAME: new("c"), Custom404: new(false), HTMLURL: new("h"), Public: new(true), HTTPSCertificate: &PagesHTTPSCertificate{State: new("approved"), Description: new("Certificate is approved"), Domains: []string{"developer.github.com"}, ExpiresAt: new("2021-05-22")}, HTTPSEnforced: new(true)} if !cmp.Equal(page, want) { t.Errorf("Repositories.GetPagesInfo returned %+v, want %+v", page, want) } @@ -303,7 +303,7 @@ func TestRepositoriesService_ListPagesBuilds(t *testing.T) { t.Errorf("Repositories.ListPagesBuilds returned error: %v", err) } - want := []*PagesBuild{{URL: Ptr("u"), Status: Ptr("s"), Commit: Ptr("c")}} + want := []*PagesBuild{{URL: new("u"), Status: new("s"), Commit: new("c")}} if !cmp.Equal(pages, want) { t.Errorf("Repositories.ListPagesBuilds returned %+v, want %+v", pages, want) } @@ -357,7 +357,7 @@ func TestRepositoriesService_GetLatestPagesBuild(t *testing.T) { t.Errorf("Repositories.GetLatestPagesBuild returned error: %v", err) } - want := &PagesBuild{URL: Ptr("u"), Status: Ptr("s"), Commit: Ptr("c")} + want := &PagesBuild{URL: new("u"), Status: new("s"), Commit: new("c")} if !cmp.Equal(build, want) { t.Errorf("Repositories.GetLatestPagesBuild returned %+v, want %+v", build, want) } @@ -392,7 +392,7 @@ func TestRepositoriesService_GetPageBuild(t *testing.T) { t.Errorf("Repositories.GetPageBuild returned error: %v", err) } - want := &PagesBuild{URL: Ptr("u"), Status: Ptr("s"), Commit: Ptr("c")} + want := &PagesBuild{URL: new("u"), Status: new("s"), Commit: new("c")} if !cmp.Equal(build, want) { t.Errorf("Repositories.GetPageBuild returned %+v, want %+v", build, want) } @@ -427,7 +427,7 @@ func TestRepositoriesService_RequestPageBuild(t *testing.T) { t.Errorf("Repositories.RequestPageBuild returned error: %v", err) } - want := &PagesBuild{URL: Ptr("u"), Status: Ptr("s")} + want := &PagesBuild{URL: new("u"), Status: new("s")} if !cmp.Equal(build, want) { t.Errorf("Repositories.RequestPageBuild returned %+v, want %+v", build, want) } @@ -464,16 +464,16 @@ func TestRepositoriesService_GetPageHealthCheck(t *testing.T) { want := &PagesHealthCheckResponse{ Domain: &PagesDomain{ - Host: Ptr("example.com"), - URI: Ptr("http://example.com/"), - Nameservers: Ptr("default"), - DNSResolves: Ptr(true), + Host: new("example.com"), + URI: new("http://example.com/"), + Nameservers: new("default"), + DNSResolves: new(true), }, AltDomain: &PagesDomain{ - Host: Ptr("www.example.com"), - URI: Ptr("http://www.example.com/"), - Nameservers: Ptr("default"), - DNSResolves: Ptr(true), + Host: new("www.example.com"), + URI: new("http://www.example.com/"), + Nameservers: new("default"), + DNSResolves: new(true), }, } if !cmp.Equal(healthCheckResponse, want) { diff --git a/github/repos_prereceive_hooks_test.go b/github/repos_prereceive_hooks_test.go index 15ee94702aa..9b34b67aa7e 100644 --- a/github/repos_prereceive_hooks_test.go +++ b/github/repos_prereceive_hooks_test.go @@ -32,7 +32,7 @@ func TestRepositoriesService_ListPreReceiveHooks(t *testing.T) { t.Errorf("Repositories.ListPreReceiveHooks returned error: %v", err) } - want := []*PreReceiveHook{{ID: Ptr(int64(1))}, {ID: Ptr(int64(2))}} + want := []*PreReceiveHook{{ID: new(int64(1))}, {ID: new(int64(2))}} if !cmp.Equal(hooks, want) { t.Errorf("Repositories.ListPreReceiveHooks returned %+v, want %+v", hooks, want) } @@ -77,7 +77,7 @@ func TestRepositoriesService_GetPreReceiveHook(t *testing.T) { t.Errorf("Repositories.GetPreReceiveHook returned error: %v", err) } - want := &PreReceiveHook{ID: Ptr(int64(1))} + want := &PreReceiveHook{ID: new(int64(1))} if !cmp.Equal(hook, want) { t.Errorf("Repositories.GetPreReceiveHook returned %+v, want %+v", hook, want) } @@ -110,7 +110,7 @@ func TestRepositoriesService_UpdatePreReceiveHook(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - input := UpdatePreReceiveHookRequest{Enforcement: Ptr("enabled")} + input := UpdatePreReceiveHookRequest{Enforcement: new("enabled")} mux.HandleFunc("/repos/o/r/pre-receive-hooks/1", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "PATCH") @@ -124,7 +124,7 @@ func TestRepositoriesService_UpdatePreReceiveHook(t *testing.T) { t.Errorf("Repositories.UpdatePreReceiveHook returned error: %v", err) } - want := &PreReceiveHook{ID: Ptr(int64(1))} + want := &PreReceiveHook{ID: new(int64(1))} if !cmp.Equal(hook, want) { t.Errorf("Repositories.UpdatePreReceiveHook returned %+v, want %+v", hook, want) } diff --git a/github/repos_releases_test.go b/github/repos_releases_test.go index 1a0b9d3aabd..9363aaa081f 100644 --- a/github/repos_releases_test.go +++ b/github/repos_releases_test.go @@ -109,7 +109,7 @@ func TestRepositoriesService_GetRelease(t *testing.T) { t.Errorf("Repositories.GetRelease returned error: %v\n%v", err, resp.Body) } - want := &RepositoryRelease{ID: 1, Author: &User{Login: Ptr("l")}} + want := &RepositoryRelease{ID: 1, Author: &User{Login: new("l")}} if !cmp.Equal(release, want) { t.Errorf("Repositories.GetRelease returned %+v, want %+v", release, want) } @@ -205,9 +205,9 @@ func TestRepositoriesService_CreateRelease(t *testing.T) { input := CreateReleaseRequest{ TagName: "v1.0", - Name: Ptr("v1.0"), - DiscussionCategoryName: Ptr("General"), - GenerateReleaseNotes: Ptr(true), + Name: new("v1.0"), + DiscussionCategoryName: new("General"), + GenerateReleaseNotes: new(true), } mux.HandleFunc("/repos/o/r/releases", func(w http.ResponseWriter, r *http.Request) { @@ -247,8 +247,8 @@ func TestRepositoriesService_UpdateRelease(t *testing.T) { client, mux, _ := setup(t) input := UpdateReleaseRequest{ - Name: Ptr("n"), - DiscussionCategoryName: Ptr("General"), + Name: new("n"), + DiscussionCategoryName: new("General"), } mux.HandleFunc("/repos/o/r/releases/1", func(w http.ResponseWriter, r *http.Request) { @@ -323,7 +323,7 @@ func TestRepositoriesService_ListReleaseAssets(t *testing.T) { if err != nil { t.Errorf("Repositories.ListReleaseAssets returned error: %v", err) } - want := []*ReleaseAsset{{ID: Ptr(int64(1))}} + want := []*ReleaseAsset{{ID: new(int64(1))}} if !cmp.Equal(assets, want) { t.Errorf("Repositories.ListReleaseAssets returned %+v, want %+v", assets, want) } @@ -357,7 +357,7 @@ func TestRepositoriesService_GetReleaseAsset(t *testing.T) { if err != nil { t.Errorf("Repositories.GetReleaseAsset returned error: %v", err) } - want := &ReleaseAsset{ID: Ptr(int64(1))} + want := &ReleaseAsset{ID: new(int64(1))} if !cmp.Equal(asset, want) { t.Errorf("Repositories.GetReleaseAsset returned %+v, want %+v", asset, want) } @@ -568,7 +568,7 @@ func TestRepositoriesService_UpdateReleaseAsset(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - input := UpdateReleaseAssetRequest{Name: Ptr("n")} + input := UpdateReleaseAssetRequest{Name: new("n")} mux.HandleFunc("/repos/o/r/releases/assets/1", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "PATCH") @@ -581,7 +581,7 @@ func TestRepositoriesService_UpdateReleaseAsset(t *testing.T) { if err != nil { t.Errorf("Repositories.UpdateReleaseAsset returned error: %v", err) } - want := &ReleaseAsset{ID: Ptr(int64(1))} + want := &ReleaseAsset{ID: new(int64(1))} if !cmp.Equal(asset, want) { t.Errorf("Repositories.UpdateReleaseAsset returned = %+v, want %+v", asset, want) } @@ -704,7 +704,7 @@ func TestRepositoriesService_UploadReleaseAsset(t *testing.T) { if err != nil { t.Errorf("Repositories.UploadReleaseAsset returned error: %v", err) } - want := &ReleaseAsset{ID: Ptr(int64(1))} + want := &ReleaseAsset{ID: new(int64(1))} if !cmp.Equal(asset, want) { t.Errorf("Repositories.UploadReleaseAsset returned %+v, want %+v", asset, want) } @@ -764,7 +764,7 @@ func TestRepositoriesService_UploadReleaseAssetFromRelease(t *testing.T) { if err != nil { t.Fatalf("Repositories.UploadReleaseAssetFromRelease returned error: %v", err) } - want := &ReleaseAsset{ID: Ptr(int64(1))} + want := &ReleaseAsset{ID: new(int64(1))} if !cmp.Equal(asset, want) { t.Fatalf("Repositories.UploadReleaseAssetFromRelease returned %+v, want %+v", asset, want) } @@ -794,7 +794,7 @@ func TestRepositoriesService_UploadReleaseAssetFromRelease_AbsoluteTemplate(t *t if err != nil { t.Fatalf("UploadReleaseAssetFromRelease returned error: %v", err) } - want := &ReleaseAsset{ID: Ptr(int64(1))} + want := &ReleaseAsset{ID: new(int64(1))} if !cmp.Equal(asset, want) { t.Fatalf("UploadReleaseAssetFromRelease returned %+v, want %+v", asset, want) } @@ -878,7 +878,7 @@ func TestRepositoriesService_UploadReleaseAssetFromRelease_NoOpts(t *testing.T) if err != nil { t.Fatalf("unexpected error: %v", err) } - want := &ReleaseAsset{ID: Ptr(int64(1))} + want := &ReleaseAsset{ID: new(int64(1))} if !cmp.Equal(asset, want) { t.Fatalf("Repositories.UploadReleaseAssetFromRelease returned %+v, want %+v", asset, want) } @@ -917,7 +917,7 @@ func TestRepositoriesService_UploadReleaseAssetFromRelease_WithMediaType(t *test if err != nil { t.Fatalf("unexpected error: %v", err) } - want := &ReleaseAsset{ID: Ptr(int64(1))} + want := &ReleaseAsset{ID: new(int64(1))} if !cmp.Equal(asset, want) { t.Fatalf("UploadReleaseAssetFromRelease returned %+v, want %+v", asset, want) } diff --git a/github/repos_rules.go b/github/repos_rules.go index 3baf0f64992..22c555313ef 100644 --- a/github/repos_rules.go +++ b/github/repos_rules.go @@ -49,7 +49,7 @@ func (s *RepositoriesService) ListRulesForBranchIter(ctx context.Context, owner, if opts == nil { opts = &ListOptions{} } else { - opts = Ptr(*opts) + opts = new(*opts) } for { diff --git a/github/repos_rules_test.go b/github/repos_rules_test.go index 33df6ab4857..bae001a69f7 100644 --- a/github/repos_rules_test.go +++ b/github/repos_rules_test.go @@ -278,18 +278,18 @@ func TestRepositoriesService_GetAllRulesets(t *testing.T) { want := []*RepositoryRuleset{ { - ID: Ptr(int64(42)), + ID: new(int64(42)), Name: "ruleset", - SourceType: Ptr(RulesetSourceTypeRepository), + SourceType: new(RulesetSourceTypeRepository), Source: "o/repo", Enforcement: RulesetEnforcementActive, CreatedAt: &Timestamp{referenceTime}, UpdatedAt: &Timestamp{referenceTime}, }, { - ID: Ptr(int64(314)), + ID: new(int64(314)), Name: "Another ruleset", - SourceType: Ptr(RulesetSourceTypeRepository), + SourceType: new(RulesetSourceTypeRepository), Source: "o/repo", Enforcement: RulesetEnforcementActive, CreatedAt: &Timestamp{referenceTime}, @@ -329,7 +329,7 @@ func TestRepositoriesService_GetAllRulesets_ListOptions(t *testing.T) { }) opts := &RepositoryListRulesetsOptions{ - IncludesParents: Ptr(false), + IncludesParents: new(false), ListOptions: ListOptions{ Page: 2, PerPage: 35, @@ -343,7 +343,7 @@ func TestRepositoriesService_GetAllRulesets_ListOptions(t *testing.T) { want := []*RepositoryRuleset{ { - ID: Ptr(int64(42)), + ID: new(int64(42)), }, } if !cmp.Equal(ruleSet, want) { @@ -390,9 +390,9 @@ func TestRepositoriesService_CreateRuleset(t *testing.T) { } want := &RepositoryRuleset{ - ID: Ptr(int64(42)), + ID: new(int64(42)), Name: "ruleset", - SourceType: Ptr(RulesetSourceTypeRepository), + SourceType: new(RulesetSourceTypeRepository), Source: "o/repo", Enforcement: RulesetEnforcementActive, } @@ -463,11 +463,11 @@ func TestRepositoriesService_CreateRulesetWithPushRules(t *testing.T) { } want := &RepositoryRuleset{ - ID: Ptr(int64(42)), + ID: new(int64(42)), Name: "ruleset", - SourceType: Ptr(RulesetSourceTypeRepository), + SourceType: new(RulesetSourceTypeRepository), Source: "o/repo", - Target: Ptr(RulesetTargetPush), + Target: new(RulesetTargetPush), Enforcement: RulesetEnforcementActive, Rules: &RepositoryRulesetRules{ FilePathRestriction: &FilePathRestrictionRuleParameters{RestrictedFilePaths: []string{"/a/file"}}, @@ -515,9 +515,9 @@ func TestRepositoriesService_GetRuleset(t *testing.T) { } want := &RepositoryRuleset{ - ID: Ptr(int64(42)), + ID: new(int64(42)), Name: "ruleset", - SourceType: Ptr(RulesetSourceTypeOrganization), + SourceType: new(RulesetSourceTypeOrganization), Source: "o", Enforcement: RulesetEnforcementActive, CreatedAt: &Timestamp{referenceTime}, @@ -563,9 +563,9 @@ func TestRepositoriesService_UpdateRuleset(t *testing.T) { } want := &RepositoryRuleset{ - ID: Ptr(int64(42)), + ID: new(int64(42)), Name: "ruleset", - SourceType: Ptr(RulesetSourceTypeRepository), + SourceType: new(RulesetSourceTypeRepository), Source: "o/repo", Enforcement: "active", } diff --git a/github/repos_stats.go b/github/repos_stats.go index 8234886f0ad..32156a34c56 100644 --- a/github/repos_stats.go +++ b/github/repos_stats.go @@ -139,8 +139,8 @@ func (s *RepositoriesService) ListCodeFrequency(ctx context.Context, owner, repo } stat := &WeeklyStats{ Week: &Timestamp{time.Unix(int64(week[0]), 0)}, - Additions: Ptr(week[1]), - Deletions: Ptr(week[2]), + Additions: new(week[1]), + Deletions: new(week[2]), } stats = append(stats, stat) } @@ -231,9 +231,9 @@ func (s *RepositoriesService) ListPunchCard(ctx context.Context, owner, repo str continue } card := &PunchCard{ - Day: Ptr(result[0]), - Hour: Ptr(result[1]), - Commits: Ptr(result[2]), + Day: new(result[0]), + Hour: new(result[1]), + Commits: new(result[2]), } cards = append(cards, card) } diff --git a/github/repos_stats_test.go b/github/repos_stats_test.go index 77eb5e23d2b..525ca868a27 100644 --- a/github/repos_stats_test.go +++ b/github/repos_stats_test.go @@ -51,16 +51,16 @@ func TestRepositoriesService_ListContributorsStats(t *testing.T) { want := []*ContributorStats{ { Author: &Contributor{ - ID: Ptr(int64(1)), - NodeID: Ptr("nodeid-1"), + ID: new(int64(1)), + NodeID: new("nodeid-1"), }, - Total: Ptr(135), + Total: new(135), Weeks: []*WeeklyStats{ { Week: &referenceTimestamp, - Additions: Ptr(6898), - Deletions: Ptr(77), - Commits: Ptr(10), + Additions: new(6898), + Deletions: new(77), + Commits: new(10), }, }, }, @@ -112,7 +112,7 @@ func TestRepositoriesService_ListCommitActivity(t *testing.T) { want := []*WeeklyCommitActivity{ { Days: []int{0, 3, 26, 20, 39, 1, 0}, - Total: Ptr(89), + Total: new(89), Week: &referenceTimestamp, }, } @@ -154,8 +154,8 @@ func TestRepositoriesService_ListCodeFrequency(t *testing.T) { want := []*WeeklyStats{{ Week: &referenceTimestamp, - Additions: Ptr(1124), - Deletions: Ptr(-435), + Additions: new(1124), + Deletions: new(-435), }} if !cmp.Equal(code, want) { @@ -263,9 +263,9 @@ func TestRepositoriesService_ListPunchCard(t *testing.T) { } want := []*PunchCard{ - {Day: Ptr(0), Hour: Ptr(0), Commits: Ptr(5)}, - {Day: Ptr(0), Hour: Ptr(1), Commits: Ptr(43)}, - {Day: Ptr(0), Hour: Ptr(2), Commits: Ptr(21)}, + {Day: new(0), Hour: new(0), Commits: new(5)}, + {Day: new(0), Hour: new(1), Commits: new(43)}, + {Day: new(0), Hour: new(2), Commits: new(21)}, } if !cmp.Equal(card, want) { diff --git a/github/repos_statuses_test.go b/github/repos_statuses_test.go index a48e5229d2d..25dc44496c8 100644 --- a/github/repos_statuses_test.go +++ b/github/repos_statuses_test.go @@ -30,7 +30,7 @@ func TestRepositoriesService_ListStatuses(t *testing.T) { t.Errorf("Repositories.ListStatuses returned error: %v", err) } - want := []*RepoStatus{{ID: Ptr(int64(1))}} + want := []*RepoStatus{{ID: new(int64(1))}} if !cmp.Equal(statuses, want) { t.Errorf("Repositories.ListStatuses returned %+v, want %+v", statuses, want) } @@ -63,7 +63,7 @@ func TestRepositoriesService_CreateStatus(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - input := RepoStatus{State: Ptr("s"), TargetURL: Ptr("t"), Description: Ptr("d")} + input := RepoStatus{State: new("s"), TargetURL: new("t"), Description: new("d")} mux.HandleFunc("/repos/o/r/statuses/r", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "POST") @@ -77,7 +77,7 @@ func TestRepositoriesService_CreateStatus(t *testing.T) { t.Errorf("Repositories.CreateStatus returned error: %v", err) } - want := &RepoStatus{ID: Ptr(int64(1))} + want := &RepoStatus{ID: new(int64(1))} if !cmp.Equal(status, want) { t.Errorf("Repositories.CreateStatus returned %+v, want %+v", status, want) } @@ -123,7 +123,7 @@ func TestRepositoriesService_GetCombinedStatus(t *testing.T) { t.Errorf("Repositories.GetCombinedStatus returned error: %v", err) } - want := &CombinedStatus{State: Ptr("success"), Statuses: []*RepoStatus{{ID: Ptr(int64(1))}}} + want := &CombinedStatus{State: new("success"), Statuses: []*RepoStatus{{ID: new(int64(1))}}} if !cmp.Equal(status, want) { t.Errorf("Repositories.GetCombinedStatus returned %+v, want %+v", status, want) } diff --git a/github/repos_tags_test.go b/github/repos_tags_test.go index c92f3ff3c9d..fa6316fd1a3 100644 --- a/github/repos_tags_test.go +++ b/github/repos_tags_test.go @@ -29,7 +29,7 @@ func TestRepositoriesService_ListTagProtection(t *testing.T) { t.Errorf("Repositories.ListTagProtection returned error: %v", err) } - want := []*TagProtection{{ID: Ptr(int64(1)), Pattern: Ptr("tag1")}, {ID: Ptr(int64(2)), Pattern: Ptr("tag2")}} + want := []*TagProtection{{ID: new(int64(1)), Pattern: new("tag1")}, {ID: new(int64(2)), Pattern: new("tag2")}} if !cmp.Equal(tagProtections, want) { t.Errorf("Repositories.ListTagProtection returned %+v, want %+v", tagProtections, want) } @@ -77,7 +77,7 @@ func TestRepositoriesService_CreateTagProtection(t *testing.T) { t.Errorf("Repositories.CreateTagProtection returned error: %v", err) } - want := &TagProtection{ID: Ptr(int64(1)), Pattern: Ptr("tag*")} + want := &TagProtection{ID: new(int64(1)), Pattern: new("tag*")} if !cmp.Equal(got, want) { t.Errorf("Repositories.CreateTagProtection returned %+v, want %+v", got, want) } diff --git a/github/repos_test.go b/github/repos_test.go index 8b4c558a0a5..7d66533bfa1 100644 --- a/github/repos_test.go +++ b/github/repos_test.go @@ -32,7 +32,7 @@ func TestRepositoriesService_ListByAuthenticatedUser(t *testing.T) { t.Errorf("Repositories.ListByAuthenticatedUser returned error: %v", err) } - want := []*Repository{{ID: Ptr(int64(1))}, {ID: Ptr(int64(2))}} + want := []*Repository{{ID: new(int64(1))}, {ID: new(int64(2))}} if !cmp.Equal(got, want) { t.Errorf("Repositories.ListByAuthenticatedUser returned %+v, want %+v", got, want) } @@ -73,7 +73,7 @@ func TestRepositoriesService_ListByUser(t *testing.T) { t.Errorf("Repositories.ListByUser returned error: %v", err) } - want := []*Repository{{ID: Ptr(int64(1))}} + want := []*Repository{{ID: new(int64(1))}} if !cmp.Equal(repos, want) { t.Errorf("Repositories.ListByUser returned %+v, want %+v", repos, want) } @@ -114,7 +114,7 @@ func TestRepositoriesService_ListByUser_type(t *testing.T) { t.Errorf("Repositories.ListByUser returned error: %v", err) } - want := []*Repository{{ID: Ptr(int64(1))}} + want := []*Repository{{ID: new(int64(1))}} if !cmp.Equal(repos, want) { t.Errorf("Repositories.ListByUser returned %+v, want %+v", repos, want) } @@ -154,7 +154,7 @@ func TestRepositoriesService_ListByOrg(t *testing.T) { t.Errorf("Repositories.ListByOrg returned error: %v", err) } - want := []*Repository{{ID: Ptr(int64(1))}} + want := []*Repository{{ID: new(int64(1))}} if !cmp.Equal(got, want) { t.Errorf("Repositories.ListByOrg returned %+v, want %+v", got, want) } @@ -202,7 +202,7 @@ func TestRepositoriesService_ListAll(t *testing.T) { t.Errorf("Repositories.ListAll returned error: %v", err) } - want := []*Repository{{ID: Ptr(int64(1))}} + want := []*Repository{{ID: new(int64(1))}} if !cmp.Equal(got, want) { t.Errorf("Repositories.ListAll returned %+v, want %+v", got, want) } @@ -222,15 +222,15 @@ func TestRepositoriesService_Create_user(t *testing.T) { client, mux, _ := setup(t) input := &Repository{ - Name: Ptr("n"), - Archived: Ptr(true), // not passed along. + Name: new("n"), + Archived: new(true), // not passed along. } wantAcceptHeaders := []string{mediaTypeRepositoryTemplatePreview, mediaTypeRepositoryVisibilityPreview} mux.HandleFunc("/user/repos", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "POST") testHeader(t, r, "Accept", strings.Join(wantAcceptHeaders, ", ")) - want := &createRepoRequest{Name: Ptr("n")} + want := &createRepoRequest{Name: new("n")} testJSONBody(t, r, want) fmt.Fprint(w, `{"id":1}`) @@ -242,7 +242,7 @@ func TestRepositoriesService_Create_user(t *testing.T) { t.Errorf("Repositories.Create returned error: %v", err) } - want := &Repository{ID: Ptr(int64(1))} + want := &Repository{ID: new(int64(1))} if !cmp.Equal(got, want) { t.Errorf("Repositories.Create returned %+v, want %+v", got, want) } @@ -271,15 +271,15 @@ func TestRepositoriesService_Create_org(t *testing.T) { client, mux, _ := setup(t) input := &Repository{ - Name: Ptr("n"), - Archived: Ptr(true), // not passed along. + Name: new("n"), + Archived: new(true), // not passed along. } wantAcceptHeaders := []string{mediaTypeRepositoryTemplatePreview, mediaTypeRepositoryVisibilityPreview} mux.HandleFunc("/orgs/o/repos", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "POST") testHeader(t, r, "Accept", strings.Join(wantAcceptHeaders, ", ")) - want := &createRepoRequest{Name: Ptr("n")} + want := &createRepoRequest{Name: new("n")} testJSONBody(t, r, want) fmt.Fprint(w, `{"id":1}`) }) @@ -290,7 +290,7 @@ func TestRepositoriesService_Create_org(t *testing.T) { t.Errorf("Repositories.Create returned error: %v", err) } - want := &Repository{ID: Ptr(int64(1))} + want := &Repository{ID: new(int64(1))} if !cmp.Equal(repo, want) { t.Errorf("Repositories.Create returned %+v, want %+v", repo, want) } @@ -301,7 +301,7 @@ func TestRepositoriesService_Create_withCustomProperties(t *testing.T) { client, mux, _ := setup(t) input := &Repository{ - Name: Ptr("n"), + Name: new("n"), CustomProperties: map[string]any{ "environment": "production", "team": "backend", @@ -314,7 +314,7 @@ func TestRepositoriesService_Create_withCustomProperties(t *testing.T) { testMethod(t, r, "POST") testHeader(t, r, "Accept", strings.Join(wantAcceptHeaders, ", ")) want := &createRepoRequest{ - Name: Ptr("n"), + Name: new("n"), CustomProperties: map[string]any{ "environment": "production", "team": "backend", @@ -331,7 +331,7 @@ func TestRepositoriesService_Create_withCustomProperties(t *testing.T) { t.Errorf("Repositories.Create returned error: %v", err) } - want := &Repository{ID: Ptr(int64(1))} + want := &Repository{ID: new(int64(1))} if !cmp.Equal(repo, want) { t.Errorf("Repositories.Create returned %+v, want %+v", repo, want) } @@ -358,7 +358,7 @@ func TestRepositoriesService_CreateFromTemplate(t *testing.T) { t.Errorf("Repositories.CreateFromTemplate returned error: %v", err) } - want := &Repository{ID: Ptr(int64(1)), Name: Ptr("n")} + want := &Repository{ID: new(int64(1)), Name: new("n")} if !cmp.Equal(got, want) { t.Errorf("Repositories.CreateFromTemplate returned %+v, want %+v", got, want) } @@ -395,7 +395,7 @@ func TestRepositoriesService_Get(t *testing.T) { t.Errorf("Repositories.Get returned error: %v", err) } - want := &Repository{ID: Ptr(int64(1)), Name: Ptr("n"), Description: Ptr("d"), Owner: &User{Login: Ptr("l")}, License: &License{Key: Ptr("mit")}, SecurityAndAnalysis: &SecurityAndAnalysis{AdvancedSecurity: &AdvancedSecurity{Status: Ptr("enabled")}, SecretScanning: &SecretScanning{Ptr("enabled")}, SecretScanningPushProtection: &SecretScanningPushProtection{Ptr("enabled")}, DependabotSecurityUpdates: &DependabotSecurityUpdates{Ptr("enabled")}, SecretScanningValidityChecks: &SecretScanningValidityChecks{Ptr("enabled")}, CodeSecurity: &CodeSecurity{Ptr("enabled")}}} + want := &Repository{ID: new(int64(1)), Name: new("n"), Description: new("d"), Owner: &User{Login: new("l")}, License: &License{Key: new("mit")}, SecurityAndAnalysis: &SecurityAndAnalysis{AdvancedSecurity: &AdvancedSecurity{Status: new("enabled")}, SecretScanning: &SecretScanning{new("enabled")}, SecretScanningPushProtection: &SecretScanningPushProtection{new("enabled")}, DependabotSecurityUpdates: &DependabotSecurityUpdates{new("enabled")}, SecretScanningValidityChecks: &SecretScanningValidityChecks{new("enabled")}, CodeSecurity: &CodeSecurity{new("enabled")}}} if !cmp.Equal(got, want) { t.Errorf("Repositories.Get returned %+v, want %+v", got, want) } @@ -439,10 +439,10 @@ func TestRepositoriesService_GetCodeOfConduct(t *testing.T) { } want := &CodeOfConduct{ - Key: Ptr("key"), - Name: Ptr("name"), - URL: Ptr("url"), - Body: Ptr("body"), + Key: new("key"), + Name: new("name"), + URL: new("url"), + Body: new("body"), } if !cmp.Equal(got, want) { @@ -479,7 +479,7 @@ func TestRepositoriesService_GetByID(t *testing.T) { t.Fatalf("Repositories.GetByID returned error: %v", err) } - want := &Repository{ID: Ptr(int64(1)), Name: Ptr("n"), Description: Ptr("d"), Owner: &User{Login: Ptr("l")}, License: &License{Key: Ptr("mit")}} + want := &Repository{ID: new(int64(1)), Name: new("n"), Description: new("d"), Owner: &User{Login: new("l")}, License: &License{Key: new("mit")}} if !cmp.Equal(got, want) { t.Errorf("Repositories.GetByID returned %+v, want %+v", got, want) } @@ -498,7 +498,7 @@ func TestRepositoriesService_Edit(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - input := &Repository{HasIssues: Ptr(true)} + input := &Repository{HasIssues: new(true)} wantAcceptHeaders := []string{mediaTypeRepositoryTemplatePreview, mediaTypeRepositoryVisibilityPreview} mux.HandleFunc("/repos/o/r", func(w http.ResponseWriter, r *http.Request) { @@ -514,7 +514,7 @@ func TestRepositoriesService_Edit(t *testing.T) { t.Errorf("Repositories.Edit returned error: %v", err) } - want := &Repository{ID: Ptr(int64(1))} + want := &Repository{ID: new(int64(1))} if !cmp.Equal(got, want) { t.Errorf("Repositories.Edit returned %+v, want %+v", got, want) } @@ -699,8 +699,8 @@ func TestRepositoriesService_GetAutomatedSecurityFixes(t *testing.T) { } want := &AutomatedSecurityFixes{ - Enabled: Ptr(true), - Paused: Ptr(false), + Enabled: new(true), + Paused: new(false), } if !cmp.Equal(fixes, want) { t.Errorf("Repositories.GetAutomatedSecurityFixes returned %#v, want %#v", fixes, want) @@ -756,7 +756,7 @@ func TestRepositoriesService_ListContributors(t *testing.T) { t.Errorf("Repositories.ListContributors returned error: %v", err) } - want := []*Contributor{{Contributions: Ptr(42)}} + want := []*Contributor{{Contributions: new(42)}} if !cmp.Equal(contributors, want) { t.Errorf("Repositories.ListContributors returned %+v, want %+v", contributors, want) } @@ -828,7 +828,7 @@ func TestRepositoriesService_ListTeams(t *testing.T) { t.Errorf("Repositories.ListTeams returned error: %v", err) } - want := []*Team{{ID: Ptr(int64(1))}} + want := []*Team{{ID: new(int64(1))}} if !cmp.Equal(teams, want) { t.Errorf("Repositories.ListTeams returned %+v, want %+v", teams, want) } @@ -867,13 +867,13 @@ func TestRepositoriesService_ListTags(t *testing.T) { want := []*RepositoryTag{ { - Name: Ptr("n"), + Name: new("n"), Commit: &Commit{ - SHA: Ptr("s"), - URL: Ptr("u"), + SHA: new("s"), + URL: new("u"), }, - ZipballURL: Ptr("z"), - TarballURL: Ptr("t"), + ZipballURL: new("z"), + TarballURL: new("t"), }, } if !cmp.Equal(tags, want) { @@ -915,7 +915,7 @@ func TestRepositoriesService_ListBranches(t *testing.T) { t.Errorf("Repositories.ListBranches returned error: %v", err) } - want := []*Branch{{Name: Ptr("master"), Commit: &RepositoryCommit{SHA: Ptr("a57781"), URL: Ptr("https://api.github.com/repos/o/r/commits/a57781")}}} + want := []*Branch{{Name: new("master"), Commit: &RepositoryCommit{SHA: new("a57781"), URL: new("https://api.github.com/repos/o/r/commits/a57781")}}} if !cmp.Equal(branches, want) { t.Errorf("Repositories.ListBranches returned %+v, want %+v", branches, want) } @@ -960,14 +960,14 @@ func TestRepositoriesService_GetBranch(t *testing.T) { } want := &Branch{ - Name: Ptr("n"), + Name: new("n"), Commit: &RepositoryCommit{ - SHA: Ptr("s"), + SHA: new("s"), Commit: &Commit{ - Message: Ptr("m"), + Message: new("m"), }, }, - Protected: Ptr(true), + Protected: new(true), Protection: &Protection{ RequiredStatusChecks: &RequiredStatusChecks{ Contexts: &[]string{"c"}, @@ -1038,14 +1038,14 @@ func TestRepositoriesService_GetBranch_StatusMovedPermanently_followRedirects(t } want := &Branch{ - Name: Ptr("n"), + Name: new("n"), Commit: &RepositoryCommit{ - SHA: Ptr("s"), + SHA: new("s"), Commit: &Commit{ - Message: Ptr("m"), + Message: new("m"), }, }, - Protected: Ptr(true), + Protected: new(true), Protection: &Protection{ RequiredStatusChecks: &RequiredStatusChecks{ Contexts: &[]string{"c"}, @@ -1129,7 +1129,7 @@ func TestRepositoriesService_RenameBranch(t *testing.T) { t.Errorf("Repositories.RenameBranch returned error: %v", err) } - want := &Branch{Name: Ptr("nn"), Protected: Ptr(true)} + want := &Branch{Name: new("nn"), Protected: new(true)} if !cmp.Equal(got, want) { t.Errorf("Repositories.RenameBranch returned %+v, want %+v", got, want) } @@ -1245,13 +1245,13 @@ func TestRepositoriesService_GetBranchProtection(t *testing.T) { DismissStaleReviews: true, DismissalRestrictions: &DismissalRestrictions{ Users: []*User{ - {Login: Ptr("u"), ID: Ptr(int64(3))}, + {Login: new("u"), ID: new(int64(3))}, }, Teams: []*Team{ - {Slug: Ptr("t"), ID: Ptr(int64(4))}, + {Slug: new("t"), ID: new(int64(4))}, }, Apps: []*App{ - {Slug: Ptr("a"), ID: Ptr(int64(5))}, + {Slug: new("a"), ID: new(int64(5))}, }, }, RequireCodeOwnerReviews: true, @@ -1264,26 +1264,26 @@ func TestRepositoriesService_GetBranchProtection(t *testing.T) { }, Restrictions: &BranchRestrictions{ Users: []*User{ - {Login: Ptr("u"), ID: Ptr(int64(1))}, + {Login: new("u"), ID: new(int64(1))}, }, Teams: []*Team{ - {Slug: Ptr("t"), ID: Ptr(int64(2))}, + {Slug: new("t"), ID: new(int64(2))}, }, Apps: []*App{ - {Slug: Ptr("a"), ID: Ptr(int64(3))}, + {Slug: new("a"), ID: new(int64(3))}, }, }, RequiredConversationResolution: &RequiredConversationResolution{ Enabled: true, }, BlockCreations: &BlockCreations{ - Enabled: Ptr(false), + Enabled: new(false), }, LockBranch: &LockBranch{ - Enabled: Ptr(false), + Enabled: new(false), }, AllowForkSyncing: &AllowForkSyncing{ - Enabled: Ptr(false), + Enabled: new(false), }, } if !cmp.Equal(protection, want) { @@ -1379,10 +1379,10 @@ func TestRepositoriesService_GetBranchProtection_noDismissalRestrictions(t *test }, Restrictions: &BranchRestrictions{ Users: []*User{ - {Login: Ptr("u"), ID: Ptr(int64(1))}, + {Login: new("u"), ID: new(int64(1))}, }, Teams: []*Team{ - {Slug: Ptr("t"), ID: Ptr(int64(2))}, + {Slug: new("t"), ID: new(int64(2))}, }, }, } @@ -1469,9 +1469,9 @@ func TestRepositoriesService_UpdateBranchProtection_Contexts(t *testing.T) { Teams: []string{"t"}, Apps: []string{"a"}, }, - BlockCreations: Ptr(true), - LockBranch: Ptr(true), - AllowForkSyncing: Ptr(true), + BlockCreations: new(true), + LockBranch: new(true), + AllowForkSyncing: new(true), } mux.HandleFunc(test.urlPath, func(w http.ResponseWriter, r *http.Request) { @@ -1550,47 +1550,47 @@ func TestRepositoriesService_UpdateBranchProtection_Contexts(t *testing.T) { DismissStaleReviews: true, DismissalRestrictions: &DismissalRestrictions{ Users: []*User{ - {Login: Ptr("uu"), ID: Ptr(int64(3))}, + {Login: new("uu"), ID: new(int64(3))}, }, Teams: []*Team{ - {Slug: Ptr("tt"), ID: Ptr(int64(4))}, + {Slug: new("tt"), ID: new(int64(4))}, }, Apps: []*App{ - {Slug: Ptr("aa"), ID: Ptr(int64(5))}, + {Slug: new("aa"), ID: new(int64(5))}, }, }, RequireCodeOwnerReviews: true, BypassPullRequestAllowances: &BypassPullRequestAllowances{ Users: []*User{ - {Login: Ptr("uuu"), ID: Ptr(int64(10))}, + {Login: new("uuu"), ID: new(int64(10))}, }, Teams: []*Team{ - {Slug: Ptr("ttt"), ID: Ptr(int64(20))}, + {Slug: new("ttt"), ID: new(int64(20))}, }, Apps: []*App{ - {Slug: Ptr("aaa"), ID: Ptr(int64(30))}, + {Slug: new("aaa"), ID: new(int64(30))}, }, }, }, Restrictions: &BranchRestrictions{ Users: []*User{ - {Login: Ptr("u"), ID: Ptr(int64(1))}, + {Login: new("u"), ID: new(int64(1))}, }, Teams: []*Team{ - {Slug: Ptr("t"), ID: Ptr(int64(2))}, + {Slug: new("t"), ID: new(int64(2))}, }, Apps: []*App{ - {Slug: Ptr("a"), ID: Ptr(int64(3))}, + {Slug: new("a"), ID: new(int64(3))}, }, }, BlockCreations: &BlockCreations{ - Enabled: Ptr(true), + Enabled: new(true), }, LockBranch: &LockBranch{ - Enabled: Ptr(true), + Enabled: new(true), }, AllowForkSyncing: &AllowForkSyncing{ - Enabled: Ptr(true), + Enabled: new(true), }, } if !cmp.Equal(protection, want) { @@ -1652,9 +1652,9 @@ func TestRepositoriesService_UpdateBranchProtection_EmptyContexts(t *testing.T) Teams: []string{"t"}, Apps: []string{"a"}, }, - BlockCreations: Ptr(true), - LockBranch: Ptr(true), - AllowForkSyncing: Ptr(true), + BlockCreations: new(true), + LockBranch: new(true), + AllowForkSyncing: new(true), } mux.HandleFunc(test.urlPath, func(w http.ResponseWriter, r *http.Request) { @@ -1723,47 +1723,47 @@ func TestRepositoriesService_UpdateBranchProtection_EmptyContexts(t *testing.T) DismissStaleReviews: true, DismissalRestrictions: &DismissalRestrictions{ Users: []*User{ - {Login: Ptr("uu"), ID: Ptr(int64(3))}, + {Login: new("uu"), ID: new(int64(3))}, }, Teams: []*Team{ - {Slug: Ptr("tt"), ID: Ptr(int64(4))}, + {Slug: new("tt"), ID: new(int64(4))}, }, Apps: []*App{ - {Slug: Ptr("aa"), ID: Ptr(int64(5))}, + {Slug: new("aa"), ID: new(int64(5))}, }, }, RequireCodeOwnerReviews: true, BypassPullRequestAllowances: &BypassPullRequestAllowances{ Users: []*User{ - {Login: Ptr("uuu"), ID: Ptr(int64(10))}, + {Login: new("uuu"), ID: new(int64(10))}, }, Teams: []*Team{ - {Slug: Ptr("ttt"), ID: Ptr(int64(20))}, + {Slug: new("ttt"), ID: new(int64(20))}, }, Apps: []*App{ - {Slug: Ptr("aaa"), ID: Ptr(int64(30))}, + {Slug: new("aaa"), ID: new(int64(30))}, }, }, }, Restrictions: &BranchRestrictions{ Users: []*User{ - {Login: Ptr("u"), ID: Ptr(int64(1))}, + {Login: new("u"), ID: new(int64(1))}, }, Teams: []*Team{ - {Slug: Ptr("t"), ID: Ptr(int64(2))}, + {Slug: new("t"), ID: new(int64(2))}, }, Apps: []*App{ - {Slug: Ptr("a"), ID: Ptr(int64(3))}, + {Slug: new("a"), ID: new(int64(3))}, }, }, BlockCreations: &BlockCreations{ - Enabled: Ptr(true), + Enabled: new(true), }, LockBranch: &LockBranch{ - Enabled: Ptr(true), + Enabled: new(true), }, AllowForkSyncing: &AllowForkSyncing{ - Enabled: Ptr(true), + Enabled: new(true), }, } if !cmp.Equal(protection, want) { @@ -1898,37 +1898,37 @@ func TestRepositoriesService_UpdateBranchProtection_Checks(t *testing.T) { DismissStaleReviews: true, DismissalRestrictions: &DismissalRestrictions{ Users: []*User{ - {Login: Ptr("uu"), ID: Ptr(int64(3))}, + {Login: new("uu"), ID: new(int64(3))}, }, Teams: []*Team{ - {Slug: Ptr("tt"), ID: Ptr(int64(4))}, + {Slug: new("tt"), ID: new(int64(4))}, }, Apps: []*App{ - {Slug: Ptr("aa"), ID: Ptr(int64(5))}, + {Slug: new("aa"), ID: new(int64(5))}, }, }, RequireCodeOwnerReviews: true, BypassPullRequestAllowances: &BypassPullRequestAllowances{ Users: []*User{ - {Login: Ptr("uuu"), ID: Ptr(int64(10))}, + {Login: new("uuu"), ID: new(int64(10))}, }, Teams: []*Team{ - {Slug: Ptr("ttt"), ID: Ptr(int64(20))}, + {Slug: new("ttt"), ID: new(int64(20))}, }, Apps: []*App{ - {Slug: Ptr("aaa"), ID: Ptr(int64(30))}, + {Slug: new("aaa"), ID: new(int64(30))}, }, }, }, Restrictions: &BranchRestrictions{ Users: []*User{ - {Login: Ptr("u"), ID: Ptr(int64(1))}, + {Login: new("u"), ID: new(int64(1))}, }, Teams: []*Team{ - {Slug: Ptr("t"), ID: Ptr(int64(2))}, + {Slug: new("t"), ID: new(int64(2))}, }, Apps: []*App{ - {Slug: Ptr("a"), ID: Ptr(int64(3))}, + {Slug: new("a"), ID: new(int64(3))}, }, }, } @@ -2036,37 +2036,37 @@ func TestRepositoriesService_UpdateBranchProtection_EmptyChecks(t *testing.T) { DismissStaleReviews: true, DismissalRestrictions: &DismissalRestrictions{ Users: []*User{ - {Login: Ptr("uu"), ID: Ptr(int64(3))}, + {Login: new("uu"), ID: new(int64(3))}, }, Teams: []*Team{ - {Slug: Ptr("tt"), ID: Ptr(int64(4))}, + {Slug: new("tt"), ID: new(int64(4))}, }, Apps: []*App{ - {Slug: Ptr("aa"), ID: Ptr(int64(5))}, + {Slug: new("aa"), ID: new(int64(5))}, }, }, RequireCodeOwnerReviews: true, BypassPullRequestAllowances: &BypassPullRequestAllowances{ Users: []*User{ - {Login: Ptr("uuu"), ID: Ptr(int64(10))}, + {Login: new("uuu"), ID: new(int64(10))}, }, Teams: []*Team{ - {Slug: Ptr("ttt"), ID: Ptr(int64(20))}, + {Slug: new("ttt"), ID: new(int64(20))}, }, Apps: []*App{ - {Slug: Ptr("aaa"), ID: Ptr(int64(30))}, + {Slug: new("aaa"), ID: new(int64(30))}, }, }, }, Restrictions: &BranchRestrictions{ Users: []*User{ - {Login: Ptr("u"), ID: Ptr(int64(1))}, + {Login: new("u"), ID: new(int64(1))}, }, Teams: []*Team{ - {Slug: Ptr("t"), ID: Ptr(int64(2))}, + {Slug: new("t"), ID: new(int64(2))}, }, Apps: []*App{ - {Slug: Ptr("a"), ID: Ptr(int64(3))}, + {Slug: new("a"), ID: new(int64(3))}, }, }, } @@ -2172,37 +2172,37 @@ func TestRepositoriesService_UpdateBranchProtection_StrictNoChecks(t *testing.T) DismissStaleReviews: true, DismissalRestrictions: &DismissalRestrictions{ Users: []*User{ - {Login: Ptr("uu"), ID: Ptr(int64(3))}, + {Login: new("uu"), ID: new(int64(3))}, }, Teams: []*Team{ - {Slug: Ptr("tt"), ID: Ptr(int64(4))}, + {Slug: new("tt"), ID: new(int64(4))}, }, Apps: []*App{ - {Slug: Ptr("aa"), ID: Ptr(int64(5))}, + {Slug: new("aa"), ID: new(int64(5))}, }, }, RequireCodeOwnerReviews: true, BypassPullRequestAllowances: &BypassPullRequestAllowances{ Users: []*User{ - {Login: Ptr("uuu"), ID: Ptr(int64(10))}, + {Login: new("uuu"), ID: new(int64(10))}, }, Teams: []*Team{ - {Slug: Ptr("ttt"), ID: Ptr(int64(20))}, + {Slug: new("ttt"), ID: new(int64(20))}, }, Apps: []*App{ - {Slug: Ptr("aaa"), ID: Ptr(int64(30))}, + {Slug: new("aaa"), ID: new(int64(30))}, }, }, }, Restrictions: &BranchRestrictions{ Users: []*User{ - {Login: Ptr("u"), ID: Ptr(int64(1))}, + {Login: new("u"), ID: new(int64(1))}, }, Teams: []*Team{ - {Slug: Ptr("t"), ID: Ptr(int64(2))}, + {Slug: new("t"), ID: new(int64(2))}, }, Apps: []*App{ - {Slug: Ptr("a"), ID: Ptr(int64(3))}, + {Slug: new("a"), ID: new(int64(3))}, }, }, } @@ -2230,7 +2230,7 @@ func TestRepositoriesService_UpdateBranchProtection_RequireLastPushApproval(t *t input := &ProtectionRequest{ RequiredPullRequestReviews: &PullRequestReviewsEnforcementRequest{ - RequireLastPushApproval: Ptr(true), + RequireLastPushApproval: new(true), }, } @@ -2326,14 +2326,14 @@ func TestRepositoriesService_License(t *testing.T) { } want := &RepositoryLicense{ - Name: Ptr("LICENSE"), - Path: Ptr("LICENSE"), + Name: new("LICENSE"), + Path: new("LICENSE"), License: &License{ - Name: Ptr("MIT License"), - Key: Ptr("mit"), - SPDXID: Ptr("MIT"), - URL: Ptr("https://api.github.com/licenses/mit"), - Featured: Ptr(true), + Name: new("MIT License"), + Key: new("mit"), + SPDXID: new("MIT"), + URL: new("https://api.github.com/licenses/mit"), + Featured: new(true), }, } @@ -2490,7 +2490,7 @@ func TestRepositoriesService_UpdateRequiredStatusChecks_Contexts(t *testing.T) { client, mux, _ := setup(t) input := &RequiredStatusChecksRequest{ - Strict: Ptr(true), + Strict: new(true), Contexts: []string{"continuous-integration"}, } @@ -2564,7 +2564,7 @@ func TestRepositoriesService_UpdateRequiredStatusChecks_Checks(t *testing.T) { appID := int64(123) noAppID := int64(-1) input := &RequiredStatusChecksRequest{ - Strict: Ptr(true), + Strict: new(true), Checks: []*RequiredStatusCheck{ { Context: "continuous-integration", @@ -2800,13 +2800,13 @@ func TestRepositoriesService_GetPullRequestReviewEnforcement(t *testing.T) { DismissStaleReviews: true, DismissalRestrictions: &DismissalRestrictions{ Users: []*User{ - {Login: Ptr("u"), ID: Ptr(int64(1))}, + {Login: new("u"), ID: new(int64(1))}, }, Teams: []*Team{ - {Slug: Ptr("t"), ID: Ptr(int64(2))}, + {Slug: new("t"), ID: new(int64(2))}, }, Apps: []*App{ - {Slug: Ptr("a"), ID: Ptr(int64(3))}, + {Slug: new("a"), ID: new(int64(3))}, }, }, RequireCodeOwnerReviews: true, @@ -2883,13 +2883,13 @@ func TestRepositoriesService_UpdatePullRequestReviewEnforcement(t *testing.T) { DismissStaleReviews: true, DismissalRestrictions: &DismissalRestrictions{ Users: []*User{ - {Login: Ptr("u"), ID: Ptr(int64(1))}, + {Login: new("u"), ID: new(int64(1))}, }, Teams: []*Team{ - {Slug: Ptr("t"), ID: Ptr(int64(2))}, + {Slug: new("t"), ID: new(int64(2))}, }, Apps: []*App{ - {Slug: Ptr("a"), ID: Ptr(int64(3))}, + {Slug: new("a"), ID: new(int64(3))}, }, }, RequireCodeOwnerReviews: true, @@ -3041,7 +3041,7 @@ func TestRepositoriesService_GetAdminEnforcement(t *testing.T) { } want := &AdminEnforcement{ - URL: Ptr("/repos/o/r/branches/b/protection/enforce_admins"), + URL: new("/repos/o/r/branches/b/protection/enforce_admins"), Enabled: true, } @@ -3093,7 +3093,7 @@ func TestRepositoriesService_AddAdminEnforcement(t *testing.T) { } want := &AdminEnforcement{ - URL: Ptr("/repos/o/r/branches/b/protection/enforce_admins"), + URL: new("/repos/o/r/branches/b/protection/enforce_admins"), Enabled: true, } if !cmp.Equal(enforcement, want) { @@ -3184,8 +3184,8 @@ func TestRepositoriesService_GetSignaturesProtectedBranch(t *testing.T) { } want := &SignaturesProtectedBranch{ - URL: Ptr("/repos/o/r/branches/b/protection/required_signatures"), - Enabled: Ptr(false), + URL: new("/repos/o/r/branches/b/protection/required_signatures"), + Enabled: new(false), } if !cmp.Equal(signature, want) { @@ -3276,8 +3276,8 @@ func TestRepositoriesService_RequireSignaturesOnProtectedBranch(t *testing.T) { } want := &SignaturesProtectedBranch{ - URL: Ptr("/repos/o/r/branches/b/protection/required_signatures"), - Enabled: Ptr(true), + URL: new("/repos/o/r/branches/b/protection/required_signatures"), + Enabled: new(true), } if !cmp.Equal(signature, want) { @@ -3564,7 +3564,7 @@ func TestRepositoriesService_ReplaceAppRestrictions(t *testing.T) { t.Errorf("Repositories.ReplaceAppRestrictions returned error: %v", err) } want := []*App{ - {Name: Ptr("octocat")}, + {Name: new("octocat")}, } if !cmp.Equal(got, want) { t.Errorf("Repositories.ReplaceAppRestrictions returned %+v, want %+v", got, want) @@ -3615,7 +3615,7 @@ func TestRepositoriesService_AddAppRestrictions(t *testing.T) { t.Errorf("Repositories.AddAppRestrictions returned error: %v", err) } want := []*App{ - {Name: Ptr("octocat")}, + {Name: new("octocat")}, } if !cmp.Equal(got, want) { t.Errorf("Repositories.AddAppRestrictions returned %+v, want %+v", got, want) @@ -3755,7 +3755,7 @@ func TestRepositoriesService_ReplaceTeamRestrictions(t *testing.T) { t.Errorf("Repositories.ReplaceTeamRestrictions returned error: %v", err) } want := []*Team{ - {Name: Ptr("octocat")}, + {Name: new("octocat")}, } if !cmp.Equal(got, want) { t.Errorf("Repositories.ReplaceTeamRestrictions returned %+v, want %+v", got, want) @@ -3806,7 +3806,7 @@ func TestRepositoriesService_AddTeamRestrictions(t *testing.T) { t.Errorf("Repositories.AddTeamRestrictions returned error: %v", err) } want := []*Team{ - {Name: Ptr("octocat")}, + {Name: new("octocat")}, } if !cmp.Equal(got, want) { t.Errorf("Repositories.AddTeamRestrictions returned %+v, want %+v", got, want) @@ -3946,7 +3946,7 @@ func TestRepositoriesService_ReplaceUserRestrictions(t *testing.T) { t.Errorf("Repositories.ReplaceUserRestrictions returned error: %v", err) } want := []*User{ - {Name: Ptr("octocat")}, + {Name: new("octocat")}, } if !cmp.Equal(got, want) { t.Errorf("Repositories.ReplaceUserRestrictions returned %+v, want %+v", got, want) @@ -3997,7 +3997,7 @@ func TestRepositoriesService_AddUserRestrictions(t *testing.T) { t.Errorf("Repositories.AddUserRestrictions returned error: %v", err) } want := []*User{ - {Name: Ptr("octocat")}, + {Name: new("octocat")}, } if !cmp.Equal(got, want) { t.Errorf("Repositories.AddUserRestrictions returned %+v, want %+v", got, want) @@ -4071,7 +4071,7 @@ func TestRepositoriesService_Transfer(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - input := TransferRequest{NewOwner: "a", NewName: Ptr("b"), TeamID: []int64{123}} + input := TransferRequest{NewOwner: "a", NewName: new("b"), TeamID: []int64{123}} mux.HandleFunc("/repos/o/r/transfer", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "POST") @@ -4085,7 +4085,7 @@ func TestRepositoriesService_Transfer(t *testing.T) { t.Errorf("Repositories.Transfer returned error: %v", err) } - want := &Repository{Owner: &User{Login: Ptr("a")}} + want := &Repository{Owner: &User{Login: new("a")}} if !cmp.Equal(got, want) { t.Errorf("Repositories.Transfer returned %+v, want %+v", got, want) } @@ -4156,7 +4156,7 @@ func TestRepositoriesService_Dispatch(t *testing.T) { t.Errorf("Repositories.Dispatch returned error: %v", err) } - want := &Repository{Owner: &User{Login: Ptr("a")}} + want := &Repository{Owner: &User{Login: new("a")}} if !cmp.Equal(got, want) { t.Errorf("Repositories.Dispatch returned %+v, want %+v", got, want) } @@ -4352,25 +4352,25 @@ func TestRepositoriesService_ListRepositoryActivities(t *testing.T) { Timestamp: &referenceTimestamp, ActivityType: "push", Actor: &RepositoryActor{ - Login: Ptr("testuser1"), - ID: Ptr(int64(111111)), - NodeID: Ptr("MDQ6VXNlcjExMTExMQ=="), - AvatarURL: Ptr("https://avatars.githubusercontent.com/u/111111?v=4"), - GravatarID: Ptr(""), - URL: Ptr("https://api.github.com/users/testuser1"), - HTMLURL: Ptr("https://github.com/testuser1"), - FollowersURL: Ptr("https://api.github.com/users/testuser1/followers"), - FollowingURL: Ptr("https://api.github.com/users/testuser1/following{/other_user}"), - GistsURL: Ptr("https://api.github.com/users/testuser1/gists{/gist_id}"), - StarredURL: Ptr("https://api.github.com/users/testuser1/starred{/owner}{/repo}"), - SubscriptionsURL: Ptr("https://api.github.com/users/testuser1/subscriptions"), - OrganizationsURL: Ptr("https://api.github.com/users/testuser1/orgs"), - ReposURL: Ptr("https://api.github.com/users/testuser1/repos"), - EventsURL: Ptr("https://api.github.com/users/testuser1/events{/privacy}"), - ReceivedEventsURL: Ptr("https://api.github.com/users/testuser1/received_events"), - Type: Ptr("User"), - UserViewType: Ptr("public"), - SiteAdmin: Ptr(false), + Login: new("testuser1"), + ID: new(int64(111111)), + NodeID: new("MDQ6VXNlcjExMTExMQ=="), + AvatarURL: new("https://avatars.githubusercontent.com/u/111111?v=4"), + GravatarID: new(""), + URL: new("https://api.github.com/users/testuser1"), + HTMLURL: new("https://github.com/testuser1"), + FollowersURL: new("https://api.github.com/users/testuser1/followers"), + FollowingURL: new("https://api.github.com/users/testuser1/following{/other_user}"), + GistsURL: new("https://api.github.com/users/testuser1/gists{/gist_id}"), + StarredURL: new("https://api.github.com/users/testuser1/starred{/owner}{/repo}"), + SubscriptionsURL: new("https://api.github.com/users/testuser1/subscriptions"), + OrganizationsURL: new("https://api.github.com/users/testuser1/orgs"), + ReposURL: new("https://api.github.com/users/testuser1/repos"), + EventsURL: new("https://api.github.com/users/testuser1/events{/privacy}"), + ReceivedEventsURL: new("https://api.github.com/users/testuser1/received_events"), + Type: new("User"), + UserViewType: new("public"), + SiteAdmin: new(false), }, }, { @@ -4382,25 +4382,25 @@ func TestRepositoriesService_ListRepositoryActivities(t *testing.T) { Timestamp: &referenceTimestamp, ActivityType: "branch_deletion", Actor: &RepositoryActor{ - Login: Ptr("testuser2"), - ID: Ptr(int64(222222)), - NodeID: Ptr("MDQ6VXNlcjIyMjIyMg=="), - AvatarURL: Ptr("https://avatars.githubusercontent.com/u/222222?v=4"), - GravatarID: Ptr(""), - URL: Ptr("https://api.github.com/users/testuser2"), - HTMLURL: Ptr("https://github.com/testuser2"), - FollowersURL: Ptr("https://api.github.com/users/testuser2/followers"), - FollowingURL: Ptr("https://api.github.com/users/testuser2/following{/other_user}"), - GistsURL: Ptr("https://api.github.com/users/testuser2/gists{/gist_id}"), - StarredURL: Ptr("https://api.github.com/users/testuser2/starred{/owner}{/repo}"), - SubscriptionsURL: Ptr("https://api.github.com/users/testuser2/subscriptions"), - OrganizationsURL: Ptr("https://api.github.com/users/testuser2/orgs"), - ReposURL: Ptr("https://api.github.com/users/testuser2/repos"), - EventsURL: Ptr("https://api.github.com/users/testuser2/events{/privacy}"), - ReceivedEventsURL: Ptr("https://api.github.com/users/testuser2/received_events"), - Type: Ptr("User"), - UserViewType: Ptr("public"), - SiteAdmin: Ptr(false), + Login: new("testuser2"), + ID: new(int64(222222)), + NodeID: new("MDQ6VXNlcjIyMjIyMg=="), + AvatarURL: new("https://avatars.githubusercontent.com/u/222222?v=4"), + GravatarID: new(""), + URL: new("https://api.github.com/users/testuser2"), + HTMLURL: new("https://github.com/testuser2"), + FollowersURL: new("https://api.github.com/users/testuser2/followers"), + FollowingURL: new("https://api.github.com/users/testuser2/following{/other_user}"), + GistsURL: new("https://api.github.com/users/testuser2/gists{/gist_id}"), + StarredURL: new("https://api.github.com/users/testuser2/starred{/owner}{/repo}"), + SubscriptionsURL: new("https://api.github.com/users/testuser2/subscriptions"), + OrganizationsURL: new("https://api.github.com/users/testuser2/orgs"), + ReposURL: new("https://api.github.com/users/testuser2/repos"), + EventsURL: new("https://api.github.com/users/testuser2/events{/privacy}"), + ReceivedEventsURL: new("https://api.github.com/users/testuser2/received_events"), + Type: new("User"), + UserViewType: new("public"), + SiteAdmin: new(false), }, }, } @@ -4500,25 +4500,25 @@ func TestRepositoriesService_ListRepositoryActivities_withOptions(t *testing.T) Timestamp: &referenceTimestamp, ActivityType: "push", Actor: &RepositoryActor{ - Login: Ptr("testuser1"), - ID: Ptr(int64(111111)), - NodeID: Ptr("MDQ6VXNlcjExMTExMQ=="), - AvatarURL: Ptr("https://avatars.githubusercontent.com/u/111111?v=4"), - GravatarID: Ptr(""), - URL: Ptr("https://api.github.com/users/testuser1"), - HTMLURL: Ptr("https://github.com/testuser1"), - FollowersURL: Ptr("https://api.github.com/users/testuser1/followers"), - FollowingURL: Ptr("https://api.github.com/users/testuser1/following{/other_user}"), - GistsURL: Ptr("https://api.github.com/users/testuser1/gists{/gist_id}"), - StarredURL: Ptr("https://api.github.com/users/testuser1/starred{/owner}{/repo}"), - SubscriptionsURL: Ptr("https://api.github.com/users/testuser1/subscriptions"), - OrganizationsURL: Ptr("https://api.github.com/users/testuser1/orgs"), - ReposURL: Ptr("https://api.github.com/users/testuser1/repos"), - EventsURL: Ptr("https://api.github.com/users/testuser1/events{/privacy}"), - ReceivedEventsURL: Ptr("https://api.github.com/users/testuser1/received_events"), - Type: Ptr("User"), - UserViewType: Ptr("public"), - SiteAdmin: Ptr(false), + Login: new("testuser1"), + ID: new(int64(111111)), + NodeID: new("MDQ6VXNlcjExMTExMQ=="), + AvatarURL: new("https://avatars.githubusercontent.com/u/111111?v=4"), + GravatarID: new(""), + URL: new("https://api.github.com/users/testuser1"), + HTMLURL: new("https://github.com/testuser1"), + FollowersURL: new("https://api.github.com/users/testuser1/followers"), + FollowingURL: new("https://api.github.com/users/testuser1/following{/other_user}"), + GistsURL: new("https://api.github.com/users/testuser1/gists{/gist_id}"), + StarredURL: new("https://api.github.com/users/testuser1/starred{/owner}{/repo}"), + SubscriptionsURL: new("https://api.github.com/users/testuser1/subscriptions"), + OrganizationsURL: new("https://api.github.com/users/testuser1/orgs"), + ReposURL: new("https://api.github.com/users/testuser1/repos"), + EventsURL: new("https://api.github.com/users/testuser1/events{/privacy}"), + ReceivedEventsURL: new("https://api.github.com/users/testuser1/received_events"), + Type: new("User"), + UserViewType: new("public"), + SiteAdmin: new(false), }, }, } diff --git a/github/repos_traffic_test.go b/github/repos_traffic_test.go index 3578739fbe3..17c2d2ec10f 100644 --- a/github/repos_traffic_test.go +++ b/github/repos_traffic_test.go @@ -32,9 +32,9 @@ func TestRepositoriesService_ListTrafficReferrers(t *testing.T) { } want := []*TrafficReferrer{{ - Referrer: Ptr("Google"), - Count: Ptr(4), - Uniques: Ptr(3), + Referrer: new("Google"), + Count: new(4), + Uniques: new(3), }} if !cmp.Equal(got, want) { t.Errorf("Repositories.ListTrafficReferrers returned %+v, want %+v", got, want) @@ -75,10 +75,10 @@ func TestRepositoriesService_ListTrafficPaths(t *testing.T) { } want := []*TrafficPath{{ - Path: Ptr("/github/hubot"), - Title: Ptr("github/hubot: A customizable life embetterment robot."), - Count: Ptr(3542), - Uniques: Ptr(2225), + Path: new("/github/hubot"), + Title: new("github/hubot: A customizable life embetterment robot."), + Count: new(3542), + Uniques: new(2225), }} if !cmp.Equal(got, want) { t.Errorf("Repositories.ListTrafficPaths returned %+v, want %+v", got, want) @@ -123,11 +123,11 @@ func TestRepositoriesService_ListTrafficViews(t *testing.T) { want := &TrafficViews{ Views: []*TrafficData{{ Timestamp: &referenceTimestamp, - Count: Ptr(7), - Uniques: Ptr(6), + Count: new(7), + Uniques: new(6), }}, - Count: Ptr(7), - Uniques: Ptr(6), + Count: new(7), + Uniques: new(6), } if !cmp.Equal(got, want) { @@ -173,11 +173,11 @@ func TestRepositoriesService_ListTrafficClones(t *testing.T) { want := &TrafficClones{ Clones: []*TrafficData{{ Timestamp: &referenceTimestamp, - Count: Ptr(7), - Uniques: Ptr(6), + Count: new(7), + Uniques: new(6), }}, - Count: Ptr(7), - Uniques: Ptr(6), + Count: new(7), + Uniques: new(6), } if !cmp.Equal(got, want) { diff --git a/github/rules.go b/github/rules.go index e6f48618a49..9d2230a5a2c 100644 --- a/github/rules.go +++ b/github/rules.go @@ -503,7 +503,7 @@ func (r *RulesetReviewer) UnmarshalJSON(data []byte) error { if aux.ID != nil { switch id := aux.ID.(type) { case float64: - r.ID = Ptr(int64(id)) + r.ID = new(int64(id)) case string: i, err := strconv.ParseInt(id, 10, 64) if err != nil { diff --git a/github/rules_test.go b/github/rules_test.go index ff0c69efc2c..56ad4077313 100644 --- a/github/rules_test.go +++ b/github/rules_test.go @@ -161,41 +161,41 @@ func TestRepositoryRulesetRules(t *testing.T) { RequiredReviewThreadResolution: true, }, RequiredStatusChecks: &RequiredStatusChecksRuleParameters{ - DoNotEnforceOnCreate: Ptr(true), + DoNotEnforceOnCreate: new(true), RequiredStatusChecks: []*RuleStatusCheck{ - {Context: "test1", IntegrationID: Ptr(int64(1))}, - {Context: "test2", IntegrationID: Ptr(int64(2))}, + {Context: "test1", IntegrationID: new(int64(1))}, + {Context: "test2", IntegrationID: new(int64(2))}, }, StrictRequiredStatusChecksPolicy: true, }, NonFastForward: &EmptyRuleParameters{}, CommitMessagePattern: &PatternRuleParameters{ - Name: Ptr("cmp"), - Negate: Ptr(false), + Name: new("cmp"), + Negate: new(false), Operator: PatternRuleOperatorStartsWith, Pattern: "test", }, CommitAuthorEmailPattern: &PatternRuleParameters{ - Name: Ptr("caep"), - Negate: Ptr(false), + Name: new("caep"), + Negate: new(false), Operator: PatternRuleOperatorStartsWith, Pattern: "test", }, CommitterEmailPattern: &PatternRuleParameters{ - Name: Ptr("cep"), - Negate: Ptr(false), + Name: new("cep"), + Negate: new(false), Operator: PatternRuleOperatorStartsWith, Pattern: "test", }, BranchNamePattern: &PatternRuleParameters{ - Name: Ptr("bp"), - Negate: Ptr(false), + Name: new("bp"), + Negate: new(false), Operator: PatternRuleOperatorStartsWith, Pattern: "test", }, TagNamePattern: &PatternRuleParameters{ - Name: Ptr("tp"), - Negate: Ptr(false), + Name: new("tp"), + Negate: new(false), Operator: PatternRuleOperatorStartsWith, Pattern: "test", }, @@ -208,19 +208,19 @@ func TestRepositoryRulesetRules(t *testing.T) { }, MaxFileSize: &MaxFileSizeRuleParameters{MaxFileSize: 1024}, Workflows: &WorkflowsRuleParameters{ - DoNotEnforceOnCreate: Ptr(true), + DoNotEnforceOnCreate: new(true), Workflows: []*RuleWorkflow{ { Path: ".github/workflows/test1.yaml", - Ref: Ptr("main"), - RepositoryID: Ptr(int64(1)), - SHA: Ptr("aaaa"), + Ref: new("main"), + RepositoryID: new(int64(1)), + SHA: new("aaaa"), }, { Path: ".github/workflows/test2.yaml", - Ref: Ptr("main"), - RepositoryID: Ptr(int64(2)), - SHA: Ptr("bbbb"), + Ref: new("main"), + RepositoryID: new(int64(2)), + SHA: new("bbbb"), }, }, }, @@ -460,10 +460,10 @@ func TestBranchRules(t *testing.T) { RulesetID: 1, }, Parameters: RequiredStatusChecksRuleParameters{ - DoNotEnforceOnCreate: Ptr(true), + DoNotEnforceOnCreate: new(true), RequiredStatusChecks: []*RuleStatusCheck{ - {Context: "test1", IntegrationID: Ptr(int64(1))}, - {Context: "test2", IntegrationID: Ptr(int64(2))}, + {Context: "test1", IntegrationID: new(int64(1))}, + {Context: "test2", IntegrationID: new(int64(2))}, }, StrictRequiredStatusChecksPolicy: true, }, @@ -484,8 +484,8 @@ func TestBranchRules(t *testing.T) { RulesetID: 1, }, Parameters: PatternRuleParameters{ - Name: Ptr("cmp"), - Negate: Ptr(false), + Name: new("cmp"), + Negate: new(false), Operator: PatternRuleOperatorStartsWith, Pattern: "test", }, @@ -499,8 +499,8 @@ func TestBranchRules(t *testing.T) { RulesetID: 1, }, Parameters: PatternRuleParameters{ - Name: Ptr("caep"), - Negate: Ptr(false), + Name: new("caep"), + Negate: new(false), Operator: PatternRuleOperatorStartsWith, Pattern: "test", }, @@ -514,8 +514,8 @@ func TestBranchRules(t *testing.T) { RulesetID: 1, }, Parameters: PatternRuleParameters{ - Name: Ptr("cep"), - Negate: Ptr(false), + Name: new("cep"), + Negate: new(false), Operator: PatternRuleOperatorStartsWith, Pattern: "test", }, @@ -529,8 +529,8 @@ func TestBranchRules(t *testing.T) { RulesetID: 1, }, Parameters: PatternRuleParameters{ - Name: Ptr("bp"), - Negate: Ptr(false), + Name: new("bp"), + Negate: new(false), Operator: PatternRuleOperatorStartsWith, Pattern: "test", }, @@ -544,8 +544,8 @@ func TestBranchRules(t *testing.T) { RulesetID: 1, }, Parameters: PatternRuleParameters{ - Name: Ptr("tp"), - Negate: Ptr(false), + Name: new("tp"), + Negate: new(false), Operator: PatternRuleOperatorStartsWith, Pattern: "test", }, @@ -603,19 +603,19 @@ func TestBranchRules(t *testing.T) { RulesetID: 1, }, Parameters: WorkflowsRuleParameters{ - DoNotEnforceOnCreate: Ptr(true), + DoNotEnforceOnCreate: new(true), Workflows: []*RuleWorkflow{ { Path: ".github/workflows/test1.yaml", - Ref: Ptr("main"), - RepositoryID: Ptr(int64(1)), - SHA: Ptr("aaaa"), + Ref: new("main"), + RepositoryID: new(int64(1)), + SHA: new("aaaa"), }, { Path: ".github/workflows/test2.yaml", - Ref: Ptr("main"), - RepositoryID: Ptr(int64(2)), - SHA: Ptr("bbbb"), + Ref: new("main"), + RepositoryID: new(int64(2)), + SHA: new("bbbb"), }, }, }, @@ -824,11 +824,11 @@ func TestRepositoryRule(t *testing.T) { RequiredReviewThreadResolution: false, RequiredReviewers: []*RulesetRequiredReviewer{ { - MinimumApprovals: Ptr(1), + MinimumApprovals: new(1), FilePatterns: []string{"*"}, Reviewer: &RulesetReviewer{ - ID: Ptr(int64(123456)), - Type: Ptr(RulesetReviewerTypeTeam), + ID: new(int64(123456)), + Type: new(RulesetReviewerTypeTeam), }, }, }, @@ -853,11 +853,11 @@ func TestRepositoryRule(t *testing.T) { RequiredReviewThreadResolution: false, RequiredReviewers: []*RulesetRequiredReviewer{ { - MinimumApprovals: Ptr(1), + MinimumApprovals: new(1), FilePatterns: []string{"*"}, Reviewer: &RulesetReviewer{ - ID: Ptr(int64(123456)), - Type: Ptr(RulesetReviewerTypeTeam), + ID: new(int64(123456)), + Type: new(RulesetReviewerTypeTeam), }, }, }, @@ -889,8 +889,8 @@ func TestRepositoryRule(t *testing.T) { &RepositoryRule{ Type: RulesetRuleTypeCommitMessagePattern, Parameters: &PatternRuleParameters{ - Name: Ptr("test"), - Negate: Ptr(false), + Name: new("test"), + Negate: new(false), Operator: PatternRuleOperatorStartsWith, Pattern: "test", }, @@ -902,8 +902,8 @@ func TestRepositoryRule(t *testing.T) { &RepositoryRule{ Type: RulesetRuleTypeCommitAuthorEmailPattern, Parameters: &PatternRuleParameters{ - Name: Ptr("test"), - Negate: Ptr(false), + Name: new("test"), + Negate: new(false), Operator: PatternRuleOperatorStartsWith, Pattern: "test", }, @@ -915,8 +915,8 @@ func TestRepositoryRule(t *testing.T) { &RepositoryRule{ Type: RulesetRuleTypeCommitterEmailPattern, Parameters: &PatternRuleParameters{ - Name: Ptr("test"), - Negate: Ptr(false), + Name: new("test"), + Negate: new(false), Operator: PatternRuleOperatorStartsWith, Pattern: "test", }, @@ -928,8 +928,8 @@ func TestRepositoryRule(t *testing.T) { &RepositoryRule{ Type: RulesetRuleTypeBranchNamePattern, Parameters: &PatternRuleParameters{ - Name: Ptr("test"), - Negate: Ptr(false), + Name: new("test"), + Negate: new(false), Operator: PatternRuleOperatorStartsWith, Pattern: "test", }, @@ -941,8 +941,8 @@ func TestRepositoryRule(t *testing.T) { &RepositoryRule{ Type: RulesetRuleTypeTagNamePattern, Parameters: &PatternRuleParameters{ - Name: Ptr("test"), - Negate: Ptr(false), + Name: new("test"), + Negate: new(false), Operator: PatternRuleOperatorStartsWith, Pattern: "test", }, diff --git a/github/scim_test.go b/github/scim_test.go index a26a3cb17c1..1aacfff16fd 100644 --- a/github/scim_test.go +++ b/github/scim_test.go @@ -63,9 +63,9 @@ func TestSCIMService_ListSCIMProvisionedIdentities(t *testing.T) { ctx := t.Context() opts := &ListSCIMProvisionedIdentitiesOptions{ - StartIndex: Ptr(1), - Count: Ptr(10), - Filter: Ptr(`userName="Octocat"`), + StartIndex: new(1), + Count: new(10), + Filter: new(`userName="Octocat"`), } identities, _, err := client.SCIM.ListSCIMProvisionedIdentities(ctx, "o", opts) if err != nil { @@ -74,35 +74,35 @@ func TestSCIMService_ListSCIMProvisionedIdentities(t *testing.T) { want := SCIMProvisionedIdentities{ Schemas: []string{"urn:ietf:params:scim:api:messages:2.0:ListResponse"}, - TotalResults: Ptr(1), - ItemsPerPage: Ptr(1), - StartIndex: Ptr(1), + TotalResults: new(1), + ItemsPerPage: new(1), + StartIndex: new(1), Resources: []*SCIMUserAttributes{ { - ID: Ptr("5fc0c238-1112-11e8-8e45-920c87bdbd75"), + ID: new("5fc0c238-1112-11e8-8e45-920c87bdbd75"), Meta: &SCIMMeta{ - ResourceType: Ptr("User"), + ResourceType: new("User"), Created: refTimestamp(1136178000), LastModified: refTimestamp(1136178001), - Location: Ptr("https://api.github.com/scim/v2/organizations/octo-org/Users/5fc0c238-1112-11e8-8e45-920c87bdbd75"), + Location: new("https://api.github.com/scim/v2/organizations/octo-org/Users/5fc0c238-1112-11e8-8e45-920c87bdbd75"), }, UserName: "octocat@github.com", Name: SCIMUserName{ GivenName: "Mona", FamilyName: "Octocat", - Formatted: Ptr("Mona Octocat"), + Formatted: new("Mona Octocat"), }, - DisplayName: Ptr("Mona Octocat"), + DisplayName: new("Mona Octocat"), Emails: []*SCIMUserEmail{ { Value: "octocat@github.com", - Primary: Ptr(true), + Primary: new(true), }, }, Schemas: []string{"urn:ietf:params:scim:schemas:core:2.0:User"}, - ExternalID: Ptr("00u1dhhb1fkIGP7RL1d8"), + ExternalID: new("00u1dhhb1fkIGP7RL1d8"), Groups: nil, - Active: Ptr(true), + Active: new(true), }, }, } @@ -153,7 +153,7 @@ func TestSCIMService_ProvisionAndInviteSCIMUser(t *testing.T) { } want := &SCIMUserAttributes{ - ID: Ptr("1234567890"), + ID: new("1234567890"), UserName: "userName", } if !cmp.Equal(user, want) { @@ -221,33 +221,33 @@ func TestSCIMService_GetSCIMProvisioningInfoForUser(t *testing.T) { } want := SCIMUserAttributes{ - ID: Ptr("edefdfedf-050c-11e7-8d32"), + ID: new("edefdfedf-050c-11e7-8d32"), Meta: &SCIMMeta{ - ResourceType: Ptr("User"), + ResourceType: new("User"), Created: refTimestamp(1136178000), LastModified: refTimestamp(1136178001), - Location: Ptr("https://api.github.com/scim/v2/organizations/octo-org/Users/edefdfedf-050c-11e7-8d32"), + Location: new("https://api.github.com/scim/v2/organizations/octo-org/Users/edefdfedf-050c-11e7-8d32"), }, UserName: "mona.octocat@okta.example.com", Name: SCIMUserName{ GivenName: "Mona", FamilyName: "Octocat", - Formatted: Ptr("Mona Octocat"), + Formatted: new("Mona Octocat"), }, - DisplayName: Ptr("Mona Octocat"), + DisplayName: new("Mona Octocat"), Emails: []*SCIMUserEmail{ { Value: "mona.octocat@okta.example.com", - Primary: Ptr(true), + Primary: new(true), }, { Value: "mona@octocat.github.com", }, }, Schemas: []string{"urn:ietf:params:scim:schemas:core:2.0:User"}, - ExternalID: Ptr("a7d0f98382"), + ExternalID: new("a7d0f98382"), Groups: nil, - Active: Ptr(true), + Active: new(true), } if !cmp.Equal(user, &want) { @@ -298,7 +298,7 @@ func TestSCIMService_UpdateProvisionedOrgMembership(t *testing.T) { } want := &SCIMUserAttributes{ - ID: Ptr("123"), + ID: new("123"), UserName: "userName", } if !cmp.Equal(user, want) { @@ -329,7 +329,7 @@ func TestSCIMService_UpdateAttributeForSCIMUser(t *testing.T) { Operations: []*UpdateAttributeForSCIMUserOperations{ { Op: "replace", - Path: Ptr("displayName"), + Path: new("displayName"), Value: json.RawMessage(`"NewDisplayName"`), }, }, @@ -363,7 +363,7 @@ func TestSCIMService_UpdateAttributeForSCIMUser(t *testing.T) { } want := &SCIMUserAttributes{ - ID: Ptr("123"), + ID: new("123"), UserName: "userName", } if !cmp.Equal(user, want) { diff --git a/github/search_test.go b/github/search_test.go index c7909134177..8c9c2571fe8 100644 --- a/github/search_test.go +++ b/github/search_test.go @@ -39,9 +39,9 @@ func TestSearchService_Repositories(t *testing.T) { } want := &RepositoriesSearchResult{ - Total: Ptr(4), - IncompleteResults: Ptr(false), - Repositories: []*Repository{{ID: Ptr(int64(1))}, {ID: Ptr(int64(2))}}, + Total: new(4), + IncompleteResults: new(false), + Repositories: []*Repository{{ID: new(int64(1))}, {ID: new(int64(2))}}, } if !cmp.Equal(result, want) { t.Errorf("Search.Repositories returned %+v, want %+v", result, want) @@ -130,18 +130,18 @@ func TestSearchService_RepositoriesTextMatch(t *testing.T) { } wantedRepoResult := &Repository{ - Name: Ptr("gopher1"), + Name: new("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}}}, + Fragment: new("I'm afraid my friend what you have found\nIs a gopher who lives to feed"), + Matches: []*Match{{Text: new("gopher"), Indices: []int{14, 21}}}, }, }, } want := &RepositoriesSearchResult{ - Total: Ptr(1), - IncompleteResults: Ptr(false), + Total: new(1), + IncompleteResults: new(false), Repositories: []*Repository{wantedRepoResult}, } if !cmp.Equal(result, want) { @@ -172,9 +172,9 @@ func TestSearchService_Topics(t *testing.T) { } want := &TopicsSearchResult{ - Total: Ptr(4), - IncompleteResults: Ptr(false), - Topics: []*TopicResult{{Name: Ptr("blah")}, {Name: Ptr("blahblah")}}, + Total: new(4), + IncompleteResults: new(false), + Topics: []*TopicResult{{Name: new("blah")}, {Name: new("blahblah")}}, } if !cmp.Equal(result, want) { t.Errorf("Search.Topics returned %+v, want %+v", result, want) @@ -225,9 +225,9 @@ func TestSearchService_Commits(t *testing.T) { } want := &CommitsSearchResult{ - Total: Ptr(4), - IncompleteResults: Ptr(false), - Commits: []*CommitResult{{SHA: Ptr("random_hash1")}, {SHA: Ptr("random_hash2")}}, + Total: new(4), + IncompleteResults: new(false), + Commits: []*CommitResult{{SHA: new("random_hash1")}, {SHA: new("random_hash2")}}, } if !cmp.Equal(result, want) { t.Errorf("Search.Commits returned %+v, want %+v", result, want) @@ -280,9 +280,9 @@ func TestSearchService_Issues(t *testing.T) { } want := &IssuesSearchResult{ - Total: Ptr(4), - IncompleteResults: Ptr(true), - Issues: []*Issue{{Number: Ptr(1)}, {Number: Ptr(2)}}, + Total: new(4), + IncompleteResults: new(true), + Issues: []*Issue{{Number: new(1)}, {Number: new(2)}}, } if !cmp.Equal(result, want) { t.Errorf("Search.Issues returned %+v, want %+v", result, want) @@ -315,7 +315,7 @@ func TestSearchService_Issues_advancedSearch(t *testing.T) { fmt.Fprint(w, `{"total_count": 4, "incomplete_results": true, "items": [{"number":1},{"number":2}]}`) }) - opts := &SearchOptions{Sort: "forks", Order: "desc", ListOptions: ListOptions{Page: 2, PerPage: 2}, AdvancedSearch: Ptr(true)} + opts := &SearchOptions{Sort: "forks", Order: "desc", ListOptions: ListOptions{Page: 2, PerPage: 2}, AdvancedSearch: new(true)} ctx := t.Context() result, _, err := client.Search.Issues(ctx, "blah", opts) if err != nil { @@ -323,9 +323,9 @@ func TestSearchService_Issues_advancedSearch(t *testing.T) { } want := &IssuesSearchResult{ - Total: Ptr(4), - IncompleteResults: Ptr(true), - Issues: []*Issue{{Number: Ptr(1)}, {Number: Ptr(2)}}, + Total: new(4), + IncompleteResults: new(true), + Issues: []*Issue{{Number: new(1)}, {Number: new(2)}}, } if !cmp.Equal(result, want) { t.Errorf("Search.Issues_advancedSearch returned %+v, want %+v", result, want) @@ -358,10 +358,10 @@ func TestSearchService_Issues_searchType(t *testing.T) { } want := &IssuesSearchResult{ - Total: Ptr(4), - IncompleteResults: Ptr(true), - SearchType: Ptr("hybrid"), - Issues: []*Issue{{Number: Ptr(1)}, {Number: Ptr(2)}}, + Total: new(4), + IncompleteResults: new(true), + SearchType: new("hybrid"), + Issues: []*Issue{{Number: new(1)}, {Number: new(2)}}, } if !cmp.Equal(result, want) { t.Errorf("Search.Issues_searchType returned %+v, want %+v", result, want) @@ -410,9 +410,9 @@ func TestSearchService_Issues_withQualifiersNoOpts(t *testing.T) { } want := &IssuesSearchResult{ - Total: Ptr(4), - IncompleteResults: Ptr(true), - Issues: []*Issue{{Number: Ptr(1)}, {Number: Ptr(2)}}, + Total: new(4), + IncompleteResults: new(true), + Issues: []*Issue{{Number: new(1)}, {Number: new(2)}}, } if !cmp.Equal(result, want) { t.Errorf("Search.Issues returned %+v, want %+v", result, want) @@ -449,9 +449,9 @@ func TestSearchService_Issues_withQualifiersAndOpts(t *testing.T) { } want := &IssuesSearchResult{ - Total: Ptr(4), - IncompleteResults: Ptr(true), - Issues: []*Issue{{Number: Ptr(1)}, {Number: Ptr(2)}}, + Total: new(4), + IncompleteResults: new(true), + Issues: []*Issue{{Number: new(1)}, {Number: new(2)}}, } if !cmp.Equal(result, want) { t.Errorf("Search.Issues returned %+v, want %+v", result, want) @@ -483,9 +483,9 @@ func TestSearchService_Users(t *testing.T) { } want := &UsersSearchResult{ - Total: Ptr(4), - IncompleteResults: Ptr(false), - Users: []*User{{ID: Ptr(int64(1))}, {ID: Ptr(int64(2))}}, + Total: new(4), + IncompleteResults: new(false), + Users: []*User{{ID: new(int64(1))}, {ID: new(int64(2))}}, } if !cmp.Equal(result, want) { t.Errorf("Search.Users returned %+v, want %+v", result, want) @@ -538,9 +538,9 @@ func TestSearchService_Code(t *testing.T) { } want := &CodeSearchResult{ - Total: Ptr(4), - IncompleteResults: Ptr(false), - CodeResults: []*CodeResult{{Name: Ptr("1")}, {Name: Ptr("2")}}, + Total: new(4), + IncompleteResults: new(false), + CodeResults: []*CodeResult{{Name: new("1")}, {Name: new("2")}}, } if !cmp.Equal(result, want) { t.Errorf("Search.Code returned %+v, want %+v", result, want) @@ -612,18 +612,18 @@ func TestSearchService_CodeTextMatch(t *testing.T) { } wantedCodeResult := &CodeResult{ - Name: Ptr("gopher1"), + Name: new("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}}}, + Fragment: new("I'm afraid my friend what you have found\nIs a gopher who lives to feed"), + Matches: []*Match{{Text: new("gopher"), Indices: []int{14, 21}}}, }, }, } want := &CodeSearchResult{ - Total: Ptr(1), - IncompleteResults: Ptr(false), + Total: new(1), + IncompleteResults: new(false), CodeResults: []*CodeResult{wantedCodeResult}, } if !cmp.Equal(result, want) { @@ -657,11 +657,11 @@ func TestSearchService_Labels(t *testing.T) { } want := &LabelsSearchResult{ - Total: Ptr(4), - IncompleteResults: Ptr(false), + Total: new(4), + IncompleteResults: new(false), Labels: []*LabelResult{ - {ID: Ptr(int64(1234)), Name: Ptr("bug"), Description: Ptr("some text")}, - {ID: Ptr(int64(4567)), Name: Ptr("feature")}, + {ID: new(int64(1234)), Name: new("bug"), Description: new("some text")}, + {ID: new(int64(4567)), Name: new("feature")}, }, } if !cmp.Equal(result, want) { diff --git a/github/secret_scanning_custom_patterns_test.go b/github/secret_scanning_custom_patterns_test.go index 051280e4b86..7424578bd1e 100644 --- a/github/secret_scanning_custom_patterns_test.go +++ b/github/secret_scanning_custom_patterns_test.go @@ -66,11 +66,11 @@ func TestSecretScanningService_ListCustomPatternsForRepo(t *testing.T) { Slug: "custom-pattern", State: "published", PushProtectionEnabled: true, - StartDelimiter: Ptr(`\b`), - EndDelimiter: Ptr(`\b`), + StartDelimiter: new(`\b`), + EndDelimiter: new(`\b`), MustMatch: []string{"ID-.*"}, MustNotMatch: []string{"TEST-.*"}, - CustomPatternVersion: Ptr("v1"), + CustomPatternVersion: new("v1"), CreatedAt: &referenceTimestamp, UpdatedAt: &referenceTimestamp, }, @@ -162,8 +162,8 @@ func TestSecretScanningService_UpdateCustomPatternForRepo(t *testing.T) { client, mux, _ := setup(t) input := SecretScanningUpdateCustomPatternRequest{ - Pattern: Ptr("[A-Z]{3}-[0-9]{4}"), - CustomPatternVersion: Ptr("v1"), + Pattern: new("[A-Z]{3}-[0-9]{4}"), + CustomPatternVersion: new("v1"), } mux.HandleFunc("/repos/o/r/secret-scanning/custom-patterns/1", func(w http.ResponseWriter, r *http.Request) { @@ -193,7 +193,7 @@ func TestSecretScanningService_UpdateCustomPatternForRepo(t *testing.T) { Slug: "custom-pattern", State: "published", PushProtectionEnabled: false, - CustomPatternVersion: Ptr("v2"), + CustomPatternVersion: new("v2"), } if !cmp.Equal(pattern, want) { t.Errorf("SecretScanning.UpdateCustomPatternForRepo returned %+v, want %+v", pattern, want) @@ -298,11 +298,11 @@ func TestSecretScanningService_ListCustomPatternsForOrg(t *testing.T) { Slug: "custom-pattern", State: "published", PushProtectionEnabled: true, - StartDelimiter: Ptr(`\b`), - EndDelimiter: Ptr(`\b`), + StartDelimiter: new(`\b`), + EndDelimiter: new(`\b`), MustMatch: []string{"ID-.*"}, MustNotMatch: []string{"TEST-.*"}, - CustomPatternVersion: Ptr("v1"), + CustomPatternVersion: new("v1"), CreatedAt: &referenceTimestamp, UpdatedAt: &referenceTimestamp, }, @@ -394,8 +394,8 @@ func TestSecretScanningService_UpdateCustomPatternForOrg(t *testing.T) { client, mux, _ := setup(t) input := SecretScanningUpdateCustomPatternRequest{ - Pattern: Ptr("[A-Z]{3}-[0-9]{4}"), - CustomPatternVersion: Ptr("v1"), + Pattern: new("[A-Z]{3}-[0-9]{4}"), + CustomPatternVersion: new("v1"), } mux.HandleFunc("/orgs/o/secret-scanning/custom-patterns/1", func(w http.ResponseWriter, r *http.Request) { @@ -425,7 +425,7 @@ func TestSecretScanningService_UpdateCustomPatternForOrg(t *testing.T) { Slug: "custom-pattern", State: "published", PushProtectionEnabled: false, - CustomPatternVersion: Ptr("v2"), + CustomPatternVersion: new("v2"), } if !cmp.Equal(pattern, want) { t.Errorf("SecretScanning.UpdateCustomPatternForOrg returned %+v, want %+v", pattern, want) @@ -530,11 +530,11 @@ func TestSecretScanningService_ListCustomPatternsForEnterprise(t *testing.T) { Slug: "custom-pattern", State: "published", PushProtectionEnabled: true, - StartDelimiter: Ptr(`\b`), - EndDelimiter: Ptr(`\b`), + StartDelimiter: new(`\b`), + EndDelimiter: new(`\b`), MustMatch: []string{"ID-.*"}, MustNotMatch: []string{"TEST-.*"}, - CustomPatternVersion: Ptr("v1"), + CustomPatternVersion: new("v1"), CreatedAt: &referenceTimestamp, UpdatedAt: &referenceTimestamp, }, @@ -626,8 +626,8 @@ func TestSecretScanningService_UpdateCustomPatternForEnterprise(t *testing.T) { client, mux, _ := setup(t) input := SecretScanningUpdateCustomPatternRequest{ - Pattern: Ptr("[A-Z]{3}-[0-9]{4}"), - CustomPatternVersion: Ptr("v1"), + Pattern: new("[A-Z]{3}-[0-9]{4}"), + CustomPatternVersion: new("v1"), } mux.HandleFunc("/enterprises/e/secret-scanning/custom-patterns/1", func(w http.ResponseWriter, r *http.Request) { @@ -657,7 +657,7 @@ func TestSecretScanningService_UpdateCustomPatternForEnterprise(t *testing.T) { Slug: "custom-pattern", State: "published", PushProtectionEnabled: false, - CustomPatternVersion: Ptr("v2"), + CustomPatternVersion: new("v2"), } if !cmp.Equal(pattern, want) { t.Errorf("SecretScanning.UpdateCustomPatternForEnterprise returned %+v, want %+v", pattern, want) diff --git a/github/secret_scanning_pattern_configs_test.go b/github/secret_scanning_pattern_configs_test.go index d41dfb4770a..de68d2d1c1f 100644 --- a/github/secret_scanning_pattern_configs_test.go +++ b/github/secret_scanning_pattern_configs_test.go @@ -63,37 +63,37 @@ func TestSecretScanningService_ListPatternConfigsForEnterprise(t *testing.T) { } want := &SecretScanningPatternConfigs{ - PatternConfigVersion: Ptr("0ujsswThIGTUYm2K8FjOOfXtY1K"), + PatternConfigVersion: new("0ujsswThIGTUYm2K8FjOOfXtY1K"), ProviderPatternOverrides: []*SecretScanningPatternOverride{ { - TokenType: Ptr("GITHUB_PERSONAL_ACCESS_TOKEN"), + TokenType: new("GITHUB_PERSONAL_ACCESS_TOKEN"), CustomPatternVersion: nil, - Slug: Ptr("github_personal_access_token_legacy_v2"), - DisplayName: Ptr("GitHub Personal Access Token (Legacy v2)"), - AlertTotal: Ptr(15), - AlertTotalPercentage: Ptr(36), - FalsePositives: Ptr(2), - FalsePositiveRate: Ptr(13), - Bypassrate: Ptr(13), - DefaultSetting: Ptr("enabled"), - EnterpriseSetting: Ptr("enabled"), - Setting: Ptr("enabled"), + Slug: new("github_personal_access_token_legacy_v2"), + DisplayName: new("GitHub Personal Access Token (Legacy v2)"), + AlertTotal: new(15), + AlertTotalPercentage: new(36), + FalsePositives: new(2), + FalsePositiveRate: new(13), + Bypassrate: new(13), + DefaultSetting: new("enabled"), + EnterpriseSetting: new("enabled"), + Setting: new("enabled"), }, }, CustomPatternOverrides: []*SecretScanningPatternOverride{ { - TokenType: Ptr("cp_2"), - CustomPatternVersion: Ptr("0ujsswThIGTUYm2K8FjOOfXtY1K"), - Slug: Ptr("custom-api-key"), - DisplayName: Ptr("Custom API Key"), - AlertTotal: Ptr(15), - AlertTotalPercentage: Ptr(36), - FalsePositives: Ptr(3), - FalsePositiveRate: Ptr(20), - Bypassrate: Ptr(20), - DefaultSetting: Ptr("disabled"), + TokenType: new("cp_2"), + CustomPatternVersion: new("0ujsswThIGTUYm2K8FjOOfXtY1K"), + Slug: new("custom-api-key"), + DisplayName: new("Custom API Key"), + AlertTotal: new(15), + AlertTotalPercentage: new(36), + FalsePositives: new(3), + FalsePositiveRate: new(20), + Bypassrate: new(20), + DefaultSetting: new("disabled"), EnterpriseSetting: nil, - Setting: Ptr("enabled"), + Setting: new("enabled"), }, }, } @@ -164,37 +164,37 @@ func TestSecretScanningService_ListPatternConfigsForOrg(t *testing.T) { } want := &SecretScanningPatternConfigs{ - PatternConfigVersion: Ptr("0ujsswThIGTUYm2K8FjOOfXtY1K"), + PatternConfigVersion: new("0ujsswThIGTUYm2K8FjOOfXtY1K"), ProviderPatternOverrides: []*SecretScanningPatternOverride{ { - TokenType: Ptr("GITHUB_PERSONAL_ACCESS_TOKEN"), + TokenType: new("GITHUB_PERSONAL_ACCESS_TOKEN"), CustomPatternVersion: nil, - Slug: Ptr("github_personal_access_token_legacy_v2"), - DisplayName: Ptr("GitHub Personal Access Token (Legacy v2)"), - AlertTotal: Ptr(15), - AlertTotalPercentage: Ptr(36), - FalsePositives: Ptr(2), - FalsePositiveRate: Ptr(13), - Bypassrate: Ptr(13), - DefaultSetting: Ptr("enabled"), - EnterpriseSetting: Ptr("enabled"), - Setting: Ptr("enabled"), + Slug: new("github_personal_access_token_legacy_v2"), + DisplayName: new("GitHub Personal Access Token (Legacy v2)"), + AlertTotal: new(15), + AlertTotalPercentage: new(36), + FalsePositives: new(2), + FalsePositiveRate: new(13), + Bypassrate: new(13), + DefaultSetting: new("enabled"), + EnterpriseSetting: new("enabled"), + Setting: new("enabled"), }, }, CustomPatternOverrides: []*SecretScanningPatternOverride{ { - TokenType: Ptr("cp_2"), - CustomPatternVersion: Ptr("0ujsswThIGTUYm2K8FjOOfXtY1K"), - Slug: Ptr("custom-api-key"), - DisplayName: Ptr("Custom API Key"), - AlertTotal: Ptr(15), - AlertTotalPercentage: Ptr(36), - FalsePositives: Ptr(3), - FalsePositiveRate: Ptr(20), - Bypassrate: Ptr(20), - DefaultSetting: Ptr("disabled"), + TokenType: new("cp_2"), + CustomPatternVersion: new("0ujsswThIGTUYm2K8FjOOfXtY1K"), + Slug: new("custom-api-key"), + DisplayName: new("Custom API Key"), + AlertTotal: new(15), + AlertTotalPercentage: new(36), + FalsePositives: new(3), + FalsePositiveRate: new(20), + Bypassrate: new(20), + DefaultSetting: new("disabled"), EnterpriseSetting: nil, - Setting: Ptr("enabled"), + Setting: new("enabled"), }, }, } @@ -231,7 +231,7 @@ func TestSecretScanningService_UpdatePatternConfigsForEnterprise(t *testing.T) { ctx := t.Context() opts := &SecretScanningPatternConfigsUpdateOptions{ - PatternConfigVersion: Ptr("0ujsswThIGTUYm2K8FjOOfXtY1K"), + PatternConfigVersion: new("0ujsswThIGTUYm2K8FjOOfXtY1K"), ProviderPatternSettings: []*SecretScanningProviderPatternSetting{ { TokenType: "GITHUB_PERSONAL_ACCESS_TOKEN", @@ -241,7 +241,7 @@ func TestSecretScanningService_UpdatePatternConfigsForEnterprise(t *testing.T) { CustomPatternSettings: []*SecretScanningCustomPatternSetting{ { TokenType: "cp_2", - CustomPatternVersion: Ptr("0ujsswThIGTUYm2K8FjOOfXtY1K"), + CustomPatternVersion: new("0ujsswThIGTUYm2K8FjOOfXtY1K"), PushProtectionSetting: "enabled", }, }, @@ -253,7 +253,7 @@ func TestSecretScanningService_UpdatePatternConfigsForEnterprise(t *testing.T) { } want := &SecretScanningPatternConfigsUpdate{ - PatternConfigVersion: Ptr("0ujsswThIGTUYm2K8FjOOfXtY1K"), + PatternConfigVersion: new("0ujsswThIGTUYm2K8FjOOfXtY1K"), } if !cmp.Equal(configsUpdate, want) { @@ -288,7 +288,7 @@ func TestSecretScanningService_UpdatePatternConfigsForOrg(t *testing.T) { ctx := t.Context() opts := &SecretScanningPatternConfigsUpdateOptions{ - PatternConfigVersion: Ptr("0ujsswThIGTUYm2K8FjOOfXtY1K"), + PatternConfigVersion: new("0ujsswThIGTUYm2K8FjOOfXtY1K"), ProviderPatternSettings: []*SecretScanningProviderPatternSetting{ { TokenType: "GITHUB_PERSONAL_ACCESS_TOKEN", @@ -298,7 +298,7 @@ func TestSecretScanningService_UpdatePatternConfigsForOrg(t *testing.T) { CustomPatternSettings: []*SecretScanningCustomPatternSetting{ { TokenType: "cp_2", - CustomPatternVersion: Ptr("0ujsswThIGTUYm2K8FjOOfXtY1K"), + CustomPatternVersion: new("0ujsswThIGTUYm2K8FjOOfXtY1K"), PushProtectionSetting: "enabled", }, }, @@ -310,7 +310,7 @@ func TestSecretScanningService_UpdatePatternConfigsForOrg(t *testing.T) { } want := &SecretScanningPatternConfigsUpdate{ - PatternConfigVersion: Ptr("0ujsswThIGTUYm2K8FjOOfXtY1K"), + PatternConfigVersion: new("0ujsswThIGTUYm2K8FjOOfXtY1K"), } if !cmp.Equal(configsUpdate, want) { diff --git a/github/secret_scanning_test.go b/github/secret_scanning_test.go index 852e3da073f..e23cb5e42f9 100644 --- a/github/secret_scanning_test.go +++ b/github/secret_scanning_test.go @@ -51,21 +51,21 @@ func TestSecretScanningService_ListAlertsForEnterprise(t *testing.T) { want := []*SecretScanningAlert{ { - Number: Ptr(1), + Number: new(1), CreatedAt: refTimestamp(1136178000), - URL: Ptr("https://api.github.com/repos/o/r/secret-scanning/alerts/1"), - HTMLURL: Ptr("https://github.com/o/r/security/secret-scanning/1"), - LocationsURL: Ptr("https://api.github.com/repos/o/r/secret-scanning/alerts/1/locations"), - State: Ptr("open"), + URL: new("https://api.github.com/repos/o/r/secret-scanning/alerts/1"), + HTMLURL: new("https://github.com/o/r/security/secret-scanning/1"), + LocationsURL: new("https://api.github.com/repos/o/r/secret-scanning/alerts/1/locations"), + State: new("open"), Resolution: nil, ResolvedAt: nil, ResolvedBy: nil, - SecretType: Ptr("mailchimp_api_key"), - Secret: Ptr("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX-us2"), + SecretType: new("mailchimp_api_key"), + Secret: new("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX-us2"), Repository: &Repository{ - ID: Ptr(int64(1)), - URL: Ptr("url"), - Name: Ptr("n"), + ID: new(int64(1)), + URL: new("url"), + Name: new("n"), }, }, } @@ -120,17 +120,17 @@ func TestSecretScanningService_ListAlertsForOrg(t *testing.T) { want := []*SecretScanningAlert{ { - Number: Ptr(1), + Number: new(1), CreatedAt: refTimestamp(1136178000), - URL: Ptr("https://api.github.com/repos/o/r/secret-scanning/alerts/1"), - HTMLURL: Ptr("https://github.com/o/r/security/secret-scanning/1"), - LocationsURL: Ptr("https://api.github.com/repos/o/r/secret-scanning/alerts/1/locations"), - State: Ptr("open"), + URL: new("https://api.github.com/repos/o/r/secret-scanning/alerts/1"), + HTMLURL: new("https://github.com/o/r/security/secret-scanning/1"), + LocationsURL: new("https://api.github.com/repos/o/r/secret-scanning/alerts/1/locations"), + State: new("open"), Resolution: nil, ResolvedAt: nil, ResolvedBy: nil, - SecretType: Ptr("mailchimp_api_key"), - Secret: Ptr("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX-us2"), + SecretType: new("mailchimp_api_key"), + Secret: new("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX-us2"), }, } @@ -186,17 +186,17 @@ func TestSecretScanningService_ListAlertsForOrgListOptions(t *testing.T) { want := []*SecretScanningAlert{ { - Number: Ptr(1), + Number: new(1), CreatedAt: refTimestamp(1136178000), - URL: Ptr("https://api.github.com/repos/o/r/secret-scanning/alerts/1"), - HTMLURL: Ptr("https://github.com/o/r/security/secret-scanning/1"), - LocationsURL: Ptr("https://api.github.com/repos/o/r/secret-scanning/alerts/1/locations"), - State: Ptr("open"), + URL: new("https://api.github.com/repos/o/r/secret-scanning/alerts/1"), + HTMLURL: new("https://github.com/o/r/security/secret-scanning/1"), + LocationsURL: new("https://api.github.com/repos/o/r/secret-scanning/alerts/1/locations"), + State: new("open"), Resolution: nil, ResolvedAt: nil, ResolvedBy: nil, - SecretType: Ptr("mailchimp_api_key"), - Secret: Ptr("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX-us2"), + SecretType: new("mailchimp_api_key"), + Secret: new("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX-us2"), }, } @@ -250,17 +250,17 @@ func TestSecretScanningService_ListAlertsForRepo(t *testing.T) { want := []*SecretScanningAlert{ { - Number: Ptr(1), + Number: new(1), CreatedAt: refTimestamp(1136178000), - URL: Ptr("https://api.github.com/repos/o/r/secret-scanning/alerts/1"), - HTMLURL: Ptr("https://github.com/o/r/security/secret-scanning/1"), - LocationsURL: Ptr("https://api.github.com/repos/o/r/secret-scanning/alerts/1/locations"), - State: Ptr("open"), + URL: new("https://api.github.com/repos/o/r/secret-scanning/alerts/1"), + HTMLURL: new("https://github.com/o/r/security/secret-scanning/1"), + LocationsURL: new("https://api.github.com/repos/o/r/secret-scanning/alerts/1/locations"), + State: new("open"), Resolution: nil, ResolvedAt: nil, ResolvedBy: nil, - SecretType: Ptr("mailchimp_api_key"), - Secret: Ptr("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX-us2"), + SecretType: new("mailchimp_api_key"), + Secret: new("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX-us2"), }, } @@ -311,17 +311,17 @@ func TestSecretScanningService_GetAlert(t *testing.T) { } want := &SecretScanningAlert{ - Number: Ptr(1), + Number: new(1), CreatedAt: refTimestamp(1136178000), - URL: Ptr("https://api.github.com/repos/o/r/secret-scanning/alerts/1"), - HTMLURL: Ptr("https://github.com/o/r/security/secret-scanning/1"), - LocationsURL: Ptr("https://api.github.com/repos/o/r/secret-scanning/alerts/1/locations"), - State: Ptr("open"), + URL: new("https://api.github.com/repos/o/r/secret-scanning/alerts/1"), + HTMLURL: new("https://github.com/o/r/security/secret-scanning/1"), + LocationsURL: new("https://api.github.com/repos/o/r/secret-scanning/alerts/1/locations"), + State: new("open"), Resolution: nil, ResolvedAt: nil, ResolvedBy: nil, - SecretType: Ptr("mailchimp_api_key"), - Secret: Ptr("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX-us2"), + SecretType: new("mailchimp_api_key"), + Secret: new("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX-us2"), } if !cmp.Equal(alert, want) { @@ -345,7 +345,7 @@ func TestSecretScanningService_UpdateAlert(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - opts := &SecretScanningAlertUpdateOptions{State: "resolved", Resolution: Ptr("used_in_tests")} + opts := &SecretScanningAlertUpdateOptions{State: "resolved", Resolution: new("used_in_tests")} mux.HandleFunc("/repos/o/r/secret-scanning/alerts/1", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "PATCH") @@ -373,18 +373,18 @@ func TestSecretScanningService_UpdateAlert(t *testing.T) { } want := &SecretScanningAlert{ - Number: Ptr(1), + Number: new(1), CreatedAt: refTimestamp(1136178000), - URL: Ptr("https://api.github.com/repos/o/r/secret-scanning/alerts/1"), - HTMLURL: Ptr("https://github.com/o/r/security/secret-scanning/1"), - LocationsURL: Ptr("https://api.github.com/repos/o/r/secret-scanning/alerts/1/locations"), - State: Ptr("resolved"), - Resolution: Ptr("used_in_tests"), - ResolutionComment: Ptr("resolution comment"), + URL: new("https://api.github.com/repos/o/r/secret-scanning/alerts/1"), + HTMLURL: new("https://github.com/o/r/security/secret-scanning/1"), + LocationsURL: new("https://api.github.com/repos/o/r/secret-scanning/alerts/1/locations"), + State: new("resolved"), + Resolution: new("used_in_tests"), + ResolutionComment: new("resolution comment"), ResolvedAt: refTimestamp(1136178001), ResolvedBy: nil, - SecretType: Ptr("mailchimp_api_key"), - Secret: Ptr("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX-us2"), + SecretType: new("mailchimp_api_key"), + Secret: new("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX-us2"), } if !cmp.Equal(alert, want) { @@ -438,17 +438,17 @@ func TestSecretScanningService_ListLocationsForAlert(t *testing.T) { want := []*SecretScanningAlertLocation{ { - Type: Ptr("commit"), + Type: new("commit"), Details: &SecretScanningAlertLocationDetails{ - Path: Ptr("/example/secrets.txt"), - Startline: Ptr(1), - EndLine: Ptr(1), - StartColumn: Ptr(1), - EndColumn: Ptr(64), - BlobSHA: Ptr("af5626b4a114abcb82d63db7c8082c3c4756e51b"), - BlobURL: Ptr("https://api.github.com/repos/o/r/git/blobs/af5626b4a114abcb82d63db7c8082c3c4756e51b"), - CommitSHA: Ptr("f14d7debf9775f957cf4f1e8176da0786431f72b"), - CommitURL: Ptr("https://api.github.com/repos/o/r/git/commits/f14d7debf9775f957cf4f1e8176da0786431f72b"), + Path: new("/example/secrets.txt"), + Startline: new(1), + EndLine: new(1), + StartColumn: new(1), + EndColumn: new(64), + BlobSHA: new("af5626b4a114abcb82d63db7c8082c3c4756e51b"), + BlobURL: new("https://api.github.com/repos/o/r/git/blobs/af5626b4a114abcb82d63db7c8082c3c4756e51b"), + CommitSHA: new("f14d7debf9775f957cf4f1e8176da0786431f72b"), + CommitURL: new("https://api.github.com/repos/o/r/git/commits/f14d7debf9775f957cf4f1e8176da0786431f72b"), }, }, } @@ -564,8 +564,8 @@ func TestSecretScanningService_GetScanHistory(t *testing.T) { CustomPatternBackfillScans: []*CustomPatternBackfillScan{ { SecretsScan: SecretsScan{Type: "custom_backfill", Status: "in_progress", CompletedAt: nil, StartedAt: refTimestamp(1136178002)}, - PatternSlug: Ptr("my-custom-pattern"), - PatternScope: Ptr("organization"), + PatternSlug: new("my-custom-pattern"), + PatternScope: new("organization"), }, }, } diff --git a/github/security_advisories_test.go b/github/security_advisories_test.go index cea5b9abe90..9f0acfc34db 100644 --- a/github/security_advisories_test.go +++ b/github/security_advisories_test.go @@ -170,105 +170,105 @@ func TestSecurityAdvisoriesService_CreateTemporaryPrivateFork(t *testing.T) { } want := &Repository{ - ID: Ptr(int64(1)), - NodeID: Ptr("R_kgDPP3c6pQ"), + ID: new(int64(1)), + NodeID: new("R_kgDPP3c6pQ"), Owner: &User{ - Login: Ptr("owner"), - ID: Ptr(int64(2)), - NodeID: Ptr("MDQ6VXFGcjYyMjcyMTQw"), - AvatarURL: Ptr("https://avatars.githubusercontent.com/u/111111?v=4"), - HTMLURL: Ptr("https://github.com/xxxxx"), - GravatarID: Ptr(""), - Type: Ptr("User"), - SiteAdmin: Ptr(false), - URL: Ptr("https://api.github.com/users/owner"), - EventsURL: Ptr("https://api.github.com/users/owner/events{/privacy}"), - FollowingURL: Ptr("https://api.github.com/users/owner/following{/other_user}"), - FollowersURL: Ptr("https://api.github.com/users/owner/followers"), - GistsURL: Ptr("https://api.github.com/users/owner/gists{/gist_id}"), - OrganizationsURL: Ptr("https://api.github.com/users/owner/orgs"), - ReceivedEventsURL: Ptr("https://api.github.com/users/owner/received_events"), - ReposURL: Ptr("https://api.github.com/users/owner/repos"), - StarredURL: Ptr("https://api.github.com/users/owner/starred{/owner}{/repo}"), - SubscriptionsURL: Ptr("https://api.github.com/users/owner/subscriptions"), + Login: new("owner"), + ID: new(int64(2)), + NodeID: new("MDQ6VXFGcjYyMjcyMTQw"), + AvatarURL: new("https://avatars.githubusercontent.com/u/111111?v=4"), + HTMLURL: new("https://github.com/xxxxx"), + GravatarID: new(""), + Type: new("User"), + SiteAdmin: new(false), + URL: new("https://api.github.com/users/owner"), + EventsURL: new("https://api.github.com/users/owner/events{/privacy}"), + FollowingURL: new("https://api.github.com/users/owner/following{/other_user}"), + FollowersURL: new("https://api.github.com/users/owner/followers"), + GistsURL: new("https://api.github.com/users/owner/gists{/gist_id}"), + OrganizationsURL: new("https://api.github.com/users/owner/orgs"), + ReceivedEventsURL: new("https://api.github.com/users/owner/received_events"), + ReposURL: new("https://api.github.com/users/owner/repos"), + StarredURL: new("https://api.github.com/users/owner/starred{/owner}{/repo}"), + SubscriptionsURL: new("https://api.github.com/users/owner/subscriptions"), }, - Name: Ptr("repo-ghsa-xxxx-xxxx-xxxx"), - FullName: Ptr("owner/repo-ghsa-xxxx-xxxx-xxxx"), - DefaultBranch: Ptr("master"), + Name: new("repo-ghsa-xxxx-xxxx-xxxx"), + FullName: new("owner/repo-ghsa-xxxx-xxxx-xxxx"), + DefaultBranch: new("master"), CreatedAt: refTimestamp(1136178000), PushedAt: refTimestamp(1136178001), UpdatedAt: refTimestamp(1136178002), - HTMLURL: Ptr("https://github.com/owner/repo-ghsa-xxxx-xxxx-xxxx"), - CloneURL: Ptr("https://github.com/owner/repo-ghsa-xxxx-xxxx-xxxx.git"), - GitURL: Ptr("git://github.com/owner/repo-ghsa-xxxx-xxxx-xxxx.git"), - SSHURL: Ptr("git@github.com:owner/repo-ghsa-xxxx-xxxx-xxxx.git"), - SVNURL: Ptr("https://github.com/owner/repo-ghsa-xxxx-xxxx-xxxx"), - Fork: Ptr(false), - ForksCount: Ptr(0), - NetworkCount: Ptr(0), - OpenIssuesCount: Ptr(0), - OpenIssues: Ptr(0), - StargazersCount: Ptr(0), - SubscribersCount: Ptr(0), - WatchersCount: Ptr(0), - Watchers: Ptr(0), - Size: Ptr(0), + HTMLURL: new("https://github.com/owner/repo-ghsa-xxxx-xxxx-xxxx"), + CloneURL: new("https://github.com/owner/repo-ghsa-xxxx-xxxx-xxxx.git"), + GitURL: new("git://github.com/owner/repo-ghsa-xxxx-xxxx-xxxx.git"), + SSHURL: new("git@github.com:owner/repo-ghsa-xxxx-xxxx-xxxx.git"), + SVNURL: new("https://github.com/owner/repo-ghsa-xxxx-xxxx-xxxx"), + Fork: new(false), + ForksCount: new(0), + NetworkCount: new(0), + OpenIssuesCount: new(0), + OpenIssues: new(0), + StargazersCount: new(0), + SubscribersCount: new(0), + WatchersCount: new(0), + Watchers: new(0), + Size: new(0), Permissions: &RepositoryPermissions{ - Admin: Ptr(true), - Maintain: Ptr(true), - Pull: Ptr(true), - Push: Ptr(true), - Triage: Ptr(true), + Admin: new(true), + Maintain: new(true), + Pull: new(true), + Push: new(true), + Triage: new(true), }, - AllowForking: Ptr(true), - WebCommitSignoffRequired: Ptr(false), - Archived: Ptr(false), - Disabled: Ptr(false), - Private: Ptr(true), - HasIssues: Ptr(false), - HasWiki: Ptr(false), - HasPages: Ptr(false), - HasProjects: Ptr(false), - HasDownloads: Ptr(false), - HasDiscussions: Ptr(false), - IsTemplate: Ptr(false), - URL: Ptr("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx"), - ArchiveURL: Ptr("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/{archive_format}{/ref}"), - AssigneesURL: Ptr("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/assignees{/user}"), - BlobsURL: Ptr("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/git/blobs{/sha}"), - BranchesURL: Ptr("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/branches{/branch}"), - CollaboratorsURL: Ptr("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/collaborators{/collaborator}"), - CommentsURL: Ptr("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/comments{/number}"), - CommitsURL: Ptr("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/commits{/sha}"), - CompareURL: Ptr("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/compare/{base}...{head}"), - ContentsURL: Ptr("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/contents/{+path}"), - ContributorsURL: Ptr("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/contributors"), - DeploymentsURL: Ptr("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/deployments"), - DownloadsURL: Ptr("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/downloads"), - EventsURL: Ptr("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/events"), - ForksURL: Ptr("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/forks"), - GitCommitsURL: Ptr("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/git/commits{/sha}"), - GitRefsURL: Ptr("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/git/refs{/sha}"), - GitTagsURL: Ptr("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/git/tags{/sha}"), - HooksURL: Ptr("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/hooks"), - IssueCommentURL: Ptr("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/issues/comments{/number}"), - IssueEventsURL: Ptr("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/issues/events{/number}"), - IssuesURL: Ptr("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/issues{/number}"), - KeysURL: Ptr("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/keys{/key_id}"), - LabelsURL: Ptr("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/labels{/name}"), - LanguagesURL: Ptr("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/languages"), - MergesURL: Ptr("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/merges"), - MilestonesURL: Ptr("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/milestones{/number}"), - NotificationsURL: Ptr("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/notifications{?since,all,participating}"), - PullsURL: Ptr("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/pulls{/number}"), - ReleasesURL: Ptr("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/releases{/id}"), - StargazersURL: Ptr("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/stargazers"), - StatusesURL: Ptr("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/statuses/{sha}"), - SubscribersURL: Ptr("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/subscribers"), - SubscriptionURL: Ptr("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/subscription"), - TagsURL: Ptr("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/tags"), - TeamsURL: Ptr("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/teams"), - Visibility: Ptr("private"), + AllowForking: new(true), + WebCommitSignoffRequired: new(false), + Archived: new(false), + Disabled: new(false), + Private: new(true), + HasIssues: new(false), + HasWiki: new(false), + HasPages: new(false), + HasProjects: new(false), + HasDownloads: new(false), + HasDiscussions: new(false), + IsTemplate: new(false), + URL: new("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx"), + ArchiveURL: new("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/{archive_format}{/ref}"), + AssigneesURL: new("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/assignees{/user}"), + BlobsURL: new("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/git/blobs{/sha}"), + BranchesURL: new("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/branches{/branch}"), + CollaboratorsURL: new("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/collaborators{/collaborator}"), + CommentsURL: new("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/comments{/number}"), + CommitsURL: new("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/commits{/sha}"), + CompareURL: new("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/compare/{base}...{head}"), + ContentsURL: new("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/contents/{+path}"), + ContributorsURL: new("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/contributors"), + DeploymentsURL: new("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/deployments"), + DownloadsURL: new("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/downloads"), + EventsURL: new("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/events"), + ForksURL: new("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/forks"), + GitCommitsURL: new("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/git/commits{/sha}"), + GitRefsURL: new("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/git/refs{/sha}"), + GitTagsURL: new("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/git/tags{/sha}"), + HooksURL: new("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/hooks"), + IssueCommentURL: new("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/issues/comments{/number}"), + IssueEventsURL: new("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/issues/events{/number}"), + IssuesURL: new("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/issues{/number}"), + KeysURL: new("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/keys{/key_id}"), + LabelsURL: new("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/labels{/name}"), + LanguagesURL: new("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/languages"), + MergesURL: new("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/merges"), + MilestonesURL: new("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/milestones{/number}"), + NotificationsURL: new("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/notifications{?since,all,participating}"), + PullsURL: new("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/pulls{/number}"), + ReleasesURL: new("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/releases{/id}"), + StargazersURL: new("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/stargazers"), + StatusesURL: new("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/statuses/{sha}"), + SubscribersURL: new("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/subscribers"), + SubscriptionURL: new("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/subscription"), + TagsURL: new("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/tags"), + TeamsURL: new("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/teams"), + Visibility: new("private"), } if !cmp.Equal(fork, want) { t.Errorf("SecurityAdvisoriesService.CreateTemporaryPrivateFork returned %+v, want %+v", fork, want) @@ -406,105 +406,105 @@ func TestSecurityAdvisoriesService_CreateTemporaryPrivateFork_deferred(t *testin } want := &Repository{ - ID: Ptr(int64(1)), - NodeID: Ptr("R_kgDPP3c6pQ"), + ID: new(int64(1)), + NodeID: new("R_kgDPP3c6pQ"), Owner: &User{ - Login: Ptr("owner"), - ID: Ptr(int64(2)), - NodeID: Ptr("MDQ6VXFGcjYyMjcyMTQw"), - AvatarURL: Ptr("https://avatars.githubusercontent.com/u/111111?v=4"), - HTMLURL: Ptr("https://github.com/xxxxx"), - GravatarID: Ptr(""), - Type: Ptr("User"), - SiteAdmin: Ptr(false), - URL: Ptr("https://api.github.com/users/owner"), - EventsURL: Ptr("https://api.github.com/users/owner/events{/privacy}"), - FollowingURL: Ptr("https://api.github.com/users/owner/following{/other_user}"), - FollowersURL: Ptr("https://api.github.com/users/owner/followers"), - GistsURL: Ptr("https://api.github.com/users/owner/gists{/gist_id}"), - OrganizationsURL: Ptr("https://api.github.com/users/owner/orgs"), - ReceivedEventsURL: Ptr("https://api.github.com/users/owner/received_events"), - ReposURL: Ptr("https://api.github.com/users/owner/repos"), - StarredURL: Ptr("https://api.github.com/users/owner/starred{/owner}{/repo}"), - SubscriptionsURL: Ptr("https://api.github.com/users/owner/subscriptions"), + Login: new("owner"), + ID: new(int64(2)), + NodeID: new("MDQ6VXFGcjYyMjcyMTQw"), + AvatarURL: new("https://avatars.githubusercontent.com/u/111111?v=4"), + HTMLURL: new("https://github.com/xxxxx"), + GravatarID: new(""), + Type: new("User"), + SiteAdmin: new(false), + URL: new("https://api.github.com/users/owner"), + EventsURL: new("https://api.github.com/users/owner/events{/privacy}"), + FollowingURL: new("https://api.github.com/users/owner/following{/other_user}"), + FollowersURL: new("https://api.github.com/users/owner/followers"), + GistsURL: new("https://api.github.com/users/owner/gists{/gist_id}"), + OrganizationsURL: new("https://api.github.com/users/owner/orgs"), + ReceivedEventsURL: new("https://api.github.com/users/owner/received_events"), + ReposURL: new("https://api.github.com/users/owner/repos"), + StarredURL: new("https://api.github.com/users/owner/starred{/owner}{/repo}"), + SubscriptionsURL: new("https://api.github.com/users/owner/subscriptions"), }, - Name: Ptr("repo-ghsa-xxxx-xxxx-xxxx"), - FullName: Ptr("owner/repo-ghsa-xxxx-xxxx-xxxx"), - DefaultBranch: Ptr("master"), + Name: new("repo-ghsa-xxxx-xxxx-xxxx"), + FullName: new("owner/repo-ghsa-xxxx-xxxx-xxxx"), + DefaultBranch: new("master"), CreatedAt: refTimestamp(1136178000), PushedAt: refTimestamp(1136178001), UpdatedAt: refTimestamp(1136178002), - HTMLURL: Ptr("https://github.com/owner/repo-ghsa-xxxx-xxxx-xxxx"), - CloneURL: Ptr("https://github.com/owner/repo-ghsa-xxxx-xxxx-xxxx.git"), - GitURL: Ptr("git://github.com/owner/repo-ghsa-xxxx-xxxx-xxxx.git"), - SSHURL: Ptr("git@github.com:owner/repo-ghsa-xxxx-xxxx-xxxx.git"), - SVNURL: Ptr("https://github.com/owner/repo-ghsa-xxxx-xxxx-xxxx"), - Fork: Ptr(false), - ForksCount: Ptr(0), - NetworkCount: Ptr(0), - OpenIssuesCount: Ptr(0), - OpenIssues: Ptr(0), - StargazersCount: Ptr(0), - SubscribersCount: Ptr(0), - WatchersCount: Ptr(0), - Watchers: Ptr(0), - Size: Ptr(0), + HTMLURL: new("https://github.com/owner/repo-ghsa-xxxx-xxxx-xxxx"), + CloneURL: new("https://github.com/owner/repo-ghsa-xxxx-xxxx-xxxx.git"), + GitURL: new("git://github.com/owner/repo-ghsa-xxxx-xxxx-xxxx.git"), + SSHURL: new("git@github.com:owner/repo-ghsa-xxxx-xxxx-xxxx.git"), + SVNURL: new("https://github.com/owner/repo-ghsa-xxxx-xxxx-xxxx"), + Fork: new(false), + ForksCount: new(0), + NetworkCount: new(0), + OpenIssuesCount: new(0), + OpenIssues: new(0), + StargazersCount: new(0), + SubscribersCount: new(0), + WatchersCount: new(0), + Watchers: new(0), + Size: new(0), Permissions: &RepositoryPermissions{ - Admin: Ptr(true), - Maintain: Ptr(true), - Pull: Ptr(true), - Push: Ptr(true), - Triage: Ptr(true), + Admin: new(true), + Maintain: new(true), + Pull: new(true), + Push: new(true), + Triage: new(true), }, - AllowForking: Ptr(true), - WebCommitSignoffRequired: Ptr(false), - Archived: Ptr(false), - Disabled: Ptr(false), - Private: Ptr(true), - HasIssues: Ptr(false), - HasWiki: Ptr(false), - HasPages: Ptr(false), - HasProjects: Ptr(false), - HasDownloads: Ptr(false), - HasDiscussions: Ptr(false), - IsTemplate: Ptr(false), - URL: Ptr("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx"), - ArchiveURL: Ptr("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/{archive_format}{/ref}"), - AssigneesURL: Ptr("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/assignees{/user}"), - BlobsURL: Ptr("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/git/blobs{/sha}"), - BranchesURL: Ptr("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/branches{/branch}"), - CollaboratorsURL: Ptr("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/collaborators{/collaborator}"), - CommentsURL: Ptr("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/comments{/number}"), - CommitsURL: Ptr("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/commits{/sha}"), - CompareURL: Ptr("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/compare/{base}...{head}"), - ContentsURL: Ptr("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/contents/{+path}"), - ContributorsURL: Ptr("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/contributors"), - DeploymentsURL: Ptr("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/deployments"), - DownloadsURL: Ptr("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/downloads"), - EventsURL: Ptr("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/events"), - ForksURL: Ptr("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/forks"), - GitCommitsURL: Ptr("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/git/commits{/sha}"), - GitRefsURL: Ptr("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/git/refs{/sha}"), - GitTagsURL: Ptr("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/git/tags{/sha}"), - HooksURL: Ptr("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/hooks"), - IssueCommentURL: Ptr("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/issues/comments{/number}"), - IssueEventsURL: Ptr("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/issues/events{/number}"), - IssuesURL: Ptr("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/issues{/number}"), - KeysURL: Ptr("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/keys{/key_id}"), - LabelsURL: Ptr("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/labels{/name}"), - LanguagesURL: Ptr("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/languages"), - MergesURL: Ptr("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/merges"), - MilestonesURL: Ptr("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/milestones{/number}"), - NotificationsURL: Ptr("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/notifications{?since,all,participating}"), - PullsURL: Ptr("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/pulls{/number}"), - ReleasesURL: Ptr("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/releases{/id}"), - StargazersURL: Ptr("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/stargazers"), - StatusesURL: Ptr("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/statuses/{sha}"), - SubscribersURL: Ptr("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/subscribers"), - SubscriptionURL: Ptr("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/subscription"), - TagsURL: Ptr("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/tags"), - TeamsURL: Ptr("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/teams"), - Visibility: Ptr("private"), + AllowForking: new(true), + WebCommitSignoffRequired: new(false), + Archived: new(false), + Disabled: new(false), + Private: new(true), + HasIssues: new(false), + HasWiki: new(false), + HasPages: new(false), + HasProjects: new(false), + HasDownloads: new(false), + HasDiscussions: new(false), + IsTemplate: new(false), + URL: new("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx"), + ArchiveURL: new("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/{archive_format}{/ref}"), + AssigneesURL: new("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/assignees{/user}"), + BlobsURL: new("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/git/blobs{/sha}"), + BranchesURL: new("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/branches{/branch}"), + CollaboratorsURL: new("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/collaborators{/collaborator}"), + CommentsURL: new("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/comments{/number}"), + CommitsURL: new("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/commits{/sha}"), + CompareURL: new("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/compare/{base}...{head}"), + ContentsURL: new("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/contents/{+path}"), + ContributorsURL: new("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/contributors"), + DeploymentsURL: new("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/deployments"), + DownloadsURL: new("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/downloads"), + EventsURL: new("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/events"), + ForksURL: new("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/forks"), + GitCommitsURL: new("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/git/commits{/sha}"), + GitRefsURL: new("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/git/refs{/sha}"), + GitTagsURL: new("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/git/tags{/sha}"), + HooksURL: new("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/hooks"), + IssueCommentURL: new("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/issues/comments{/number}"), + IssueEventsURL: new("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/issues/events{/number}"), + IssuesURL: new("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/issues{/number}"), + KeysURL: new("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/keys{/key_id}"), + LabelsURL: new("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/labels{/name}"), + LanguagesURL: new("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/languages"), + MergesURL: new("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/merges"), + MilestonesURL: new("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/milestones{/number}"), + NotificationsURL: new("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/notifications{?since,all,participating}"), + PullsURL: new("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/pulls{/number}"), + ReleasesURL: new("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/releases{/id}"), + StargazersURL: new("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/stargazers"), + StatusesURL: new("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/statuses/{sha}"), + SubscribersURL: new("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/subscribers"), + SubscriptionURL: new("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/subscription"), + TagsURL: new("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/tags"), + TeamsURL: new("https://api.github.com/repos/owner/repo-ghsa-xxxx-xxxx-xxxx/teams"), + Visibility: new("private"), } if !cmp.Equal(fork, want) { t.Errorf("SecurityAdvisoriesService.CreateTemporaryPrivateFork returned %+v, want %+v", fork, want) @@ -616,8 +616,8 @@ func TestSecurityAdvisoriesService_ListRepositorySecurityAdvisoriesForOrg(t *tes want := []*SecurityAdvisory{ { - GHSAID: Ptr("GHSA-abcd-1234-efgh"), - CVEID: Ptr("CVE-2050-00000"), + GHSAID: new("GHSA-abcd-1234-efgh"), + CVEID: new("CVE-2050-00000"), }, } if !cmp.Equal(advisories, want) { @@ -717,8 +717,8 @@ func TestSecurityAdvisoriesService_ListRepositorySecurityAdvisories(t *testing.T want := []*SecurityAdvisory{ { - GHSAID: Ptr("GHSA-abcd-1234-efgh"), - CVEID: Ptr("CVE-2050-00000"), + GHSAID: new("GHSA-abcd-1234-efgh"), + CVEID: new("CVE-2050-00000"), }, } if !cmp.Equal(advisories, want) { @@ -833,7 +833,7 @@ func TestListGlobalSecurityAdvisories(t *testing.T) { }) ctx := t.Context() - opts := &ListGlobalSecurityAdvisoriesOptions{CVEID: Ptr("CVE-xoxo-1234")} + opts := &ListGlobalSecurityAdvisoriesOptions{CVEID: new("CVE-xoxo-1234")} advisories, _, err := client.SecurityAdvisories.ListGlobalSecurityAdvisories(ctx, opts) if err != nil { @@ -842,46 +842,46 @@ func TestListGlobalSecurityAdvisories(t *testing.T) { want := []*GlobalSecurityAdvisory{ { - ID: Ptr(int64(1)), + ID: new(int64(1)), SecurityAdvisory: SecurityAdvisory{ - GHSAID: Ptr("GHSA-xoxo-1234-xoxo"), - CVEID: Ptr("CVE-xoxo-1234"), - URL: Ptr("https://api.github.com/advisories/GHSA-xoxo-1234-xoxo"), - HTMLURL: Ptr("https://github.com/advisories/GHSA-xoxo-1234-xoxo"), - Severity: Ptr("high"), - Summary: Ptr("Heartbleed security advisory"), - Description: Ptr("This bug allows an attacker to read portions of the affected server’s memory, potentially disclosing sensitive information."), + GHSAID: new("GHSA-xoxo-1234-xoxo"), + CVEID: new("CVE-xoxo-1234"), + URL: new("https://api.github.com/advisories/GHSA-xoxo-1234-xoxo"), + HTMLURL: new("https://github.com/advisories/GHSA-xoxo-1234-xoxo"), + Severity: new("high"), + Summary: new("Heartbleed security advisory"), + Description: new("This bug allows an attacker to read portions of the affected server’s memory, potentially disclosing sensitive information."), Identifiers: []*AdvisoryIdentifier{ { - Type: Ptr("GHSA"), - Value: Ptr("GHSA-xoxo-1234-xoxo"), + Type: new("GHSA"), + Value: new("GHSA-xoxo-1234-xoxo"), }, { - Type: Ptr("CVE"), - Value: Ptr("CVE-xoxo-1234"), + Type: new("CVE"), + Value: new("CVE-xoxo-1234"), }, }, PublishedAt: refTimestamp(1136178000), UpdatedAt: refTimestamp(1136178001), WithdrawnAt: nil, CVSS: &AdvisoryCVSS{ - VectorString: Ptr("CVSS:3.1/AV:N/AC:H/PR:H/UI:R/S:C/C:H/I:H/A:H"), - Score: Ptr(7.6), + VectorString: new("CVSS:3.1/AV:N/AC:H/PR:H/UI:R/S:C/C:H/I:H/A:H"), + Score: new(7.6), }, CVSSSeverities: &AdvisoryCVSSSeverities{ CVSSV3: &AdvisoryCVSS{ - VectorString: Ptr("CVSS:3.1/AV:N/AC:H/PR:H/UI:R/S:C/C:H/I:H/A:H"), - Score: Ptr(7.6), + VectorString: new("CVSS:3.1/AV:N/AC:H/PR:H/UI:R/S:C/C:H/I:H/A:H"), + Score: new(7.6), }, CVSSV4: &AdvisoryCVSS{ - VectorString: Ptr("CVSS:4.0/AV:N/AC:L/AT:N/PR:H/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N"), - Score: Ptr(8.7), + VectorString: new("CVSS:4.0/AV:N/AC:L/AT:N/PR:H/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N"), + Score: new(8.7), }, }, CWEs: []*AdvisoryCWEs{ { - CWEID: Ptr("CWE-400"), - Name: Ptr("Uncontrolled Resource Consumption"), + CWEID: new("CWE-400"), + Name: new("Uncontrolled Resource Consumption"), }, }, }, @@ -889,42 +889,42 @@ func TestListGlobalSecurityAdvisories(t *testing.T) { Vulnerabilities: []*GlobalSecurityVulnerability{ { Package: &VulnerabilityPackage{ - Ecosystem: Ptr("npm"), - Name: Ptr("a-package"), + Ecosystem: new("npm"), + Name: new("a-package"), }, - FirstPatchedVersion: Ptr("1.0.3"), - VulnerableVersionRange: Ptr("<=1.0.2"), + FirstPatchedVersion: new("1.0.3"), + VulnerableVersionRange: new("<=1.0.2"), VulnerableFunctions: []string{"a_function"}, }, }, - RepositoryAdvisoryURL: Ptr("https://api.github.com/repos/project/a-package/security-advisories/GHSA-xoxo-1234-xoxo"), - Type: Ptr("reviewed"), - SourceCodeLocation: Ptr("https://github.com/project/a-package"), + RepositoryAdvisoryURL: new("https://api.github.com/repos/project/a-package/security-advisories/GHSA-xoxo-1234-xoxo"), + Type: new("reviewed"), + SourceCodeLocation: new("https://github.com/project/a-package"), GithubReviewedAt: refTimestamp(1136178002), NVDPublishedAt: refTimestamp(1136178003), Credits: []*Credit{ { User: &User{ - Login: Ptr("user"), - ID: Ptr(int64(1)), - NodeID: Ptr("12="), - AvatarURL: Ptr("a"), - GravatarID: Ptr(""), - URL: Ptr("a"), - HTMLURL: Ptr("b"), - FollowersURL: Ptr("b"), - FollowingURL: Ptr("c"), - GistsURL: Ptr("d"), - StarredURL: Ptr("e"), - SubscriptionsURL: Ptr("f"), - OrganizationsURL: Ptr("g"), - ReposURL: Ptr("h"), - EventsURL: Ptr("i"), - ReceivedEventsURL: Ptr("j"), - Type: Ptr("User"), - SiteAdmin: Ptr(false), + Login: new("user"), + ID: new(int64(1)), + NodeID: new("12="), + AvatarURL: new("a"), + GravatarID: new(""), + URL: new("a"), + HTMLURL: new("b"), + FollowersURL: new("b"), + FollowingURL: new("c"), + GistsURL: new("d"), + StarredURL: new("e"), + SubscriptionsURL: new("f"), + OrganizationsURL: new("g"), + ReposURL: new("h"), + EventsURL: new("i"), + ReceivedEventsURL: new("j"), + Type: new("User"), + SiteAdmin: new(false), }, - Type: Ptr("analyst"), + Type: new("analyst"), }, }, }, @@ -1036,52 +1036,52 @@ func TestGetGlobalSecurityAdvisories(t *testing.T) { } want := &GlobalSecurityAdvisory{ - ID: Ptr(int64(1)), + ID: new(int64(1)), SecurityAdvisory: SecurityAdvisory{ - GHSAID: Ptr("GHSA-xoxo-1234-xoxo"), - CVEID: Ptr("CVE-xoxo-1234"), - URL: Ptr("https://api.github.com/advisories/GHSA-xoxo-1234-xoxo"), - HTMLURL: Ptr("https://github.com/advisories/GHSA-xoxo-1234-xoxo"), - Severity: Ptr("high"), - Summary: Ptr("Heartbleed security advisory"), - Description: Ptr("This bug allows an attacker to read portions of the affected server’s memory, potentially disclosing sensitive information."), + GHSAID: new("GHSA-xoxo-1234-xoxo"), + CVEID: new("CVE-xoxo-1234"), + URL: new("https://api.github.com/advisories/GHSA-xoxo-1234-xoxo"), + HTMLURL: new("https://github.com/advisories/GHSA-xoxo-1234-xoxo"), + Severity: new("high"), + Summary: new("Heartbleed security advisory"), + Description: new("This bug allows an attacker to read portions of the affected server’s memory, potentially disclosing sensitive information."), Identifiers: []*AdvisoryIdentifier{ { - Type: Ptr("GHSA"), - Value: Ptr("GHSA-xoxo-1234-xoxo"), + Type: new("GHSA"), + Value: new("GHSA-xoxo-1234-xoxo"), }, { - Type: Ptr("CVE"), - Value: Ptr("CVE-xoxo-1234"), + Type: new("CVE"), + Value: new("CVE-xoxo-1234"), }, }, PublishedAt: refTimestamp(1136178000), UpdatedAt: refTimestamp(1136178001), WithdrawnAt: nil, CVSS: &AdvisoryCVSS{ - VectorString: Ptr("CVSS:3.1/AV:N/AC:H/PR:H/UI:R/S:C/C:H/I:H/A:H"), - Score: Ptr(7.6), + VectorString: new("CVSS:3.1/AV:N/AC:H/PR:H/UI:R/S:C/C:H/I:H/A:H"), + Score: new(7.6), }, CVSSSeverities: &AdvisoryCVSSSeverities{ CVSSV3: &AdvisoryCVSS{ - VectorString: Ptr("CVSS:3.1/AV:N/AC:H/PR:H/UI:R/S:C/C:H/I:H/A:H"), - Score: Ptr(7.6), + VectorString: new("CVSS:3.1/AV:N/AC:H/PR:H/UI:R/S:C/C:H/I:H/A:H"), + Score: new(7.6), }, CVSSV4: &AdvisoryCVSS{ - VectorString: Ptr("CVSS:4.0/AV:N/AC:L/AT:N/PR:H/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N"), - Score: Ptr(8.7), + VectorString: new("CVSS:4.0/AV:N/AC:L/AT:N/PR:H/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N"), + Score: new(8.7), }, }, CWEs: []*AdvisoryCWEs{ { - CWEID: Ptr("CWE-400"), - Name: Ptr("Uncontrolled Resource Consumption"), + CWEID: new("CWE-400"), + Name: new("Uncontrolled Resource Consumption"), }, }, }, - RepositoryAdvisoryURL: Ptr("https://api.github.com/repos/project/a-package/security-advisories/GHSA-xoxo-1234-xoxo"), - Type: Ptr("reviewed"), - SourceCodeLocation: Ptr("https://github.com/project/a-package"), + RepositoryAdvisoryURL: new("https://api.github.com/repos/project/a-package/security-advisories/GHSA-xoxo-1234-xoxo"), + Type: new("reviewed"), + SourceCodeLocation: new("https://github.com/project/a-package"), References: []string{"https://nvd.nist.gov/vuln/detail/CVE-xoxo-1234"}, GithubReviewedAt: refTimestamp(1136178002), NVDPublishedAt: refTimestamp(1136178003), @@ -1089,37 +1089,37 @@ func TestGetGlobalSecurityAdvisories(t *testing.T) { Vulnerabilities: []*GlobalSecurityVulnerability{ { Package: &VulnerabilityPackage{ - Ecosystem: Ptr("npm"), - Name: Ptr("a-package"), + Ecosystem: new("npm"), + Name: new("a-package"), }, - FirstPatchedVersion: Ptr("1.0.3"), - VulnerableVersionRange: Ptr("<=1.0.2"), + FirstPatchedVersion: new("1.0.3"), + VulnerableVersionRange: new("<=1.0.2"), VulnerableFunctions: []string{"a_function"}, }, }, Credits: []*Credit{ { User: &User{ - Login: Ptr("user"), - ID: Ptr(int64(1)), - NodeID: Ptr("12="), - AvatarURL: Ptr("a"), - GravatarID: Ptr(""), - URL: Ptr("a"), - HTMLURL: Ptr("b"), - FollowersURL: Ptr("b"), - FollowingURL: Ptr("c"), - GistsURL: Ptr("d"), - StarredURL: Ptr("e"), - SubscriptionsURL: Ptr("f"), - OrganizationsURL: Ptr("g"), - ReposURL: Ptr("h"), - EventsURL: Ptr("i"), - ReceivedEventsURL: Ptr("j"), - Type: Ptr("User"), - SiteAdmin: Ptr(false), + Login: new("user"), + ID: new(int64(1)), + NodeID: new("12="), + AvatarURL: new("a"), + GravatarID: new(""), + URL: new("a"), + HTMLURL: new("b"), + FollowersURL: new("b"), + FollowingURL: new("c"), + GistsURL: new("d"), + StarredURL: new("e"), + SubscriptionsURL: new("f"), + OrganizationsURL: new("g"), + ReposURL: new("h"), + EventsURL: new("i"), + ReceivedEventsURL: new("j"), + Type: new("User"), + SiteAdmin: new(false), }, - Type: Ptr("analyst"), + Type: new("analyst"), }, }, } diff --git a/github/strings_benchmark_test.go b/github/strings_benchmark_test.go index b19db42c51e..5998c80632d 100644 --- a/github/strings_benchmark_test.go +++ b/github/strings_benchmark_test.go @@ -27,7 +27,7 @@ func BenchmarkStringify(b *testing.B) { Score: 1.1, Rank: 99.999999, Tags: []string{"go", "github", "api"}, - Pointer: Ptr(42), + Pointer: new(42), } b.ResetTimer() for b.Loop() { diff --git a/github/strings_test.go b/github/strings_test.go index 83392f1f80e..7858924cccf 100644 --- a/github/strings_test.go +++ b/github/strings_test.go @@ -45,12 +45,12 @@ func TestStringify(t *testing.T) { // pointers {nilPointer, ``}, - {Ptr("foo"), `"foo"`}, - {Ptr(123), `123`}, - {Ptr(false), `false`}, + {new("foo"), `"foo"`}, + {new(123), `123`}, + {new(false), `false`}, { //nolint:sliceofpointers - []*string{Ptr("a"), Ptr("b")}, + []*string{new("a"), new("b")}, `["a" "b"]`, }, @@ -64,11 +64,11 @@ func TestStringify(t *testing.T) { `github.Timestamp{2006-01-02 15:04:05 +0000 UTC}`, }, { - User{ID: Ptr(int64(123)), Name: Ptr("n")}, + User{ID: new(int64(123)), Name: new("n")}, `github.User{ID:123, Name:"n"}`, }, { - Repository{Owner: &User{ID: Ptr(int64(123))}}, + Repository{Owner: &User{ID: new(int64(123))}}, `github.Repository{Owner:github.User{ID:123}}`, }, } @@ -178,48 +178,48 @@ func TestString(t *testing.T) { in any out string }{ - {CodeResult{Name: Ptr("n")}, `github.CodeResult{Name:"n"}`}, - {CommitAuthor{Name: Ptr("n")}, `github.CommitAuthor{Name:"n"}`}, - {CommitFile{SHA: Ptr("s")}, `github.CommitFile{SHA:"s"}`}, - {CommitStats{Total: Ptr(1)}, `github.CommitStats{Total:1}`}, - {CommitsComparison{TotalCommits: Ptr(1)}, `github.CommitsComparison{TotalCommits:1}`}, - {Commit{SHA: Ptr("s")}, `github.Commit{SHA:"s"}`}, - {Event{ID: Ptr("1")}, `github.Event{ID:"1"}`}, - {GistComment{ID: Ptr(int64(1))}, `github.GistComment{ID:1}`}, - {GistFile{Size: Ptr(1)}, `github.GistFile{Size:1}`}, - {Gist{ID: Ptr("1")}, `github.Gist{ID:"1"}`}, - {GitObject{SHA: Ptr("s")}, `github.GitObject{SHA:"s"}`}, - {Gitignore{Name: Ptr("n")}, `github.Gitignore{Name:"n"}`}, - {Hook{ID: Ptr(int64(1))}, `github.Hook{ID:1}`}, - {IssueComment{ID: Ptr(int64(1))}, `github.IssueComment{ID:1}`}, - {Issue{Number: Ptr(1)}, `github.Issue{Number:1}`}, - {SubIssue{ID: Ptr(int64(1))}, `github.SubIssue{ID:1}`}, - {Key{ID: Ptr(int64(1))}, `github.Key{ID:1}`}, + {CodeResult{Name: new("n")}, `github.CodeResult{Name:"n"}`}, + {CommitAuthor{Name: new("n")}, `github.CommitAuthor{Name:"n"}`}, + {CommitFile{SHA: new("s")}, `github.CommitFile{SHA:"s"}`}, + {CommitStats{Total: new(1)}, `github.CommitStats{Total:1}`}, + {CommitsComparison{TotalCommits: new(1)}, `github.CommitsComparison{TotalCommits:1}`}, + {Commit{SHA: new("s")}, `github.Commit{SHA:"s"}`}, + {Event{ID: new("1")}, `github.Event{ID:"1"}`}, + {GistComment{ID: new(int64(1))}, `github.GistComment{ID:1}`}, + {GistFile{Size: new(1)}, `github.GistFile{Size:1}`}, + {Gist{ID: new("1")}, `github.Gist{ID:"1"}`}, + {GitObject{SHA: new("s")}, `github.GitObject{SHA:"s"}`}, + {Gitignore{Name: new("n")}, `github.Gitignore{Name:"n"}`}, + {Hook{ID: new(int64(1))}, `github.Hook{ID:1}`}, + {IssueComment{ID: new(int64(1))}, `github.IssueComment{ID:1}`}, + {Issue{Number: new(1)}, `github.Issue{Number:1}`}, + {SubIssue{ID: new(int64(1))}, `github.SubIssue{ID:1}`}, + {Key{ID: new(int64(1))}, `github.Key{ID:1}`}, {Label{ID: 1, Name: "l"}, `github.Label{ID:1, URL:"", Name:"l", Color:"", Default:false, NodeID:""}`}, - {Organization{ID: Ptr(int64(1))}, `github.Organization{ID:1}`}, - {PullRequestComment{ID: Ptr(int64(1))}, `github.PullRequestComment{ID:1}`}, - {PullRequest{Number: Ptr(1)}, `github.PullRequest{Number:1}`}, - {PullRequestReview{ID: Ptr(int64(1))}, `github.PullRequestReview{ID:1}`}, - {DraftReviewComment{Position: Ptr(1)}, `github.DraftReviewComment{Position:1}`}, - {PullRequestReviewRequest{Body: Ptr("r")}, `github.PullRequestReviewRequest{Body:"r"}`}, + {Organization{ID: new(int64(1))}, `github.Organization{ID:1}`}, + {PullRequestComment{ID: new(int64(1))}, `github.PullRequestComment{ID:1}`}, + {PullRequest{Number: new(1)}, `github.PullRequest{Number:1}`}, + {PullRequestReview{ID: new(int64(1))}, `github.PullRequestReview{ID:1}`}, + {DraftReviewComment{Position: new(1)}, `github.DraftReviewComment{Position:1}`}, + {PullRequestReviewRequest{Body: new("r")}, `github.PullRequestReviewRequest{Body:"r"}`}, {PullRequestDismissReviewRequest{Message: "r"}, `github.PullRequestDismissReviewRequest{Message:"r"}`}, - {HeadCommit{SHA: Ptr("s")}, `github.HeadCommit{SHA:"s"}`}, - {PushEvent{PushID: Ptr(int64(1))}, `github.PushEvent{PushID:1}`}, - {Reference{Ref: Ptr("r")}, `github.Reference{Ref:"r"}`}, - {ReleaseAsset{ID: Ptr(int64(1))}, `github.ReleaseAsset{ID:1}`}, - {RepoStatus{ID: Ptr(int64(1))}, `github.RepoStatus{ID:1}`}, - {RepositoryComment{ID: Ptr(int64(1))}, `github.RepositoryComment{ID:1}`}, - {RepositoryCommit{SHA: Ptr("s")}, `github.RepositoryCommit{SHA:"s"}`}, - {RepositoryContent{Name: Ptr("n")}, `github.RepositoryContent{Name:"n"}`}, + {HeadCommit{SHA: new("s")}, `github.HeadCommit{SHA:"s"}`}, + {PushEvent{PushID: new(int64(1))}, `github.PushEvent{PushID:1}`}, + {Reference{Ref: new("r")}, `github.Reference{Ref:"r"}`}, + {ReleaseAsset{ID: new(int64(1))}, `github.ReleaseAsset{ID:1}`}, + {RepoStatus{ID: new(int64(1))}, `github.RepoStatus{ID:1}`}, + {RepositoryComment{ID: new(int64(1))}, `github.RepositoryComment{ID:1}`}, + {RepositoryCommit{SHA: new("s")}, `github.RepositoryCommit{SHA:"s"}`}, + {RepositoryContent{Name: new("n")}, `github.RepositoryContent{Name:"n"}`}, {RepositoryRelease{ID: 1}, `github.RepositoryRelease{TagName:"", TargetCommitish:"", Draft:false, Prerelease:false, ID:1, CreatedAt:github.Timestamp{0001-01-01 00:00:00 +0000 UTC}, URL:"", HTMLURL:"", AssetsURL:"", UploadURL:"", NodeID:""}`}, - {Repository{ID: Ptr(int64(1))}, `github.Repository{ID:1}`}, - {Team{ID: Ptr(int64(1))}, `github.Team{ID:1}`}, - {TreeEntry{SHA: Ptr("s")}, `github.TreeEntry{SHA:"s"}`}, - {Tree{SHA: Ptr("s")}, `github.Tree{SHA:"s"}`}, - {User{ID: Ptr(int64(1))}, `github.User{ID:1}`}, - {WebHookAuthor{Name: Ptr("n")}, `github.CommitAuthor{Name:"n"}`}, - {WebHookCommit{ID: Ptr("1")}, `github.HeadCommit{ID:"1"}`}, - {WebHookPayload{Ref: Ptr("r")}, `github.PushEvent{Ref:"r"}`}, + {Repository{ID: new(int64(1))}, `github.Repository{ID:1}`}, + {Team{ID: new(int64(1))}, `github.Team{ID:1}`}, + {TreeEntry{SHA: new("s")}, `github.TreeEntry{SHA:"s"}`}, + {Tree{SHA: new("s")}, `github.Tree{SHA:"s"}`}, + {User{ID: new(int64(1))}, `github.User{ID:1}`}, + {WebHookAuthor{Name: new("n")}, `github.CommitAuthor{Name:"n"}`}, + {WebHookCommit{ID: new("1")}, `github.HeadCommit{ID:"1"}`}, + {WebHookPayload{Ref: new("r")}, `github.PushEvent{Ref:"r"}`}, } for i, tt := range tests { diff --git a/github/sub_issue_test.go b/github/sub_issue_test.go index faeea077d6e..920165addcc 100644 --- a/github/sub_issue_test.go +++ b/github/sub_issue_test.go @@ -31,7 +31,7 @@ func TestSubIssuesService_Add(t *testing.T) { t.Errorf("SubIssues.Add returned error: %v", err) } - want := &SubIssue{Number: Ptr(1), ID: Ptr(int64(42))} + want := &SubIssue{Number: new(1), ID: new(int64(42))} if !cmp.Equal(got, want) { t.Errorf("SubIssues.Add = %+v, want %+v", got, want) } @@ -70,7 +70,7 @@ func TestSubIssuesService_ListByIssue(t *testing.T) { t.Errorf("SubIssues.ListByIssue returned error: %v", err) } - want := []*SubIssue{{ID: Ptr(int64(1))}, {ID: Ptr(int64(2))}} + want := []*SubIssue{{ID: new(int64(1))}, {ID: new(int64(2))}} if !cmp.Equal(issues, want) { t.Errorf("SubIssues.ListByIssue = %+v, want %+v", issues, want) } @@ -108,7 +108,7 @@ func TestSubIssuesService_Remove(t *testing.T) { t.Errorf("SubIssues.Remove returned error: %v", err) } - want := &SubIssue{ID: Ptr(int64(42)), Number: Ptr(1)} + want := &SubIssue{ID: new(int64(42)), Number: new(1)} if !cmp.Equal(got, want) { t.Errorf("SubIssues.Remove = %+v, want %+v", got, want) } @@ -127,7 +127,7 @@ func TestSubIssuesService_Reprioritize(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - input := &SubIssueRequest{SubIssueID: 42, AfterID: Ptr(int64(5))} + input := &SubIssueRequest{SubIssueID: 42, AfterID: new(int64(5))} mux.HandleFunc("/repos/o/r/issues/1/sub_issues/priority", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "PATCH") @@ -141,7 +141,7 @@ func TestSubIssuesService_Reprioritize(t *testing.T) { t.Errorf("SubIssues.Reprioritize returned error: %v", err) } - want := &SubIssue{ID: Ptr(int64(42)), Number: Ptr(1)} + want := &SubIssue{ID: new(int64(42)), Number: new(1)} if !cmp.Equal(got, want) { t.Errorf("SubIssues.Reprioritize = %+v, want %+v", got, want) } @@ -172,7 +172,7 @@ func TestSubIssuesService_GetParentIssue(t *testing.T) { t.Errorf("SubIssues.GetParentIssue returned error: %v", err) } - want := &Issue{Number: Ptr(1), ID: Ptr(int64(1))} + want := &Issue{Number: new(1), ID: new(int64(1))} if !cmp.Equal(got, want) { t.Errorf("SubIssues.GetParentIssue = %+v, want %+v", got, want) } diff --git a/github/teams_discussion_comments_test.go b/github/teams_discussion_comments_test.go index c25ba0f12d9..edcc7792459 100644 --- a/github/teams_discussion_comments_test.go +++ b/github/teams_discussion_comments_test.go @@ -80,35 +80,35 @@ func TestTeamsService_ListComments(t *testing.T) { want := []*DiscussionComment{ { Author: &User{ - Login: Ptr("author"), - ID: Ptr(int64(0)), - AvatarURL: Ptr("https://avatars1.githubusercontent.com/u/0?v=4"), - GravatarID: Ptr(""), - URL: Ptr("https://api.github.com/users/author"), - HTMLURL: Ptr("https://github.com/author"), - FollowersURL: Ptr("https://api.github.com/users/author/followers"), - FollowingURL: Ptr("https://api.github.com/users/author/following{/other_user}"), - GistsURL: Ptr("https://api.github.com/users/author/gists{/gist_id}"), - StarredURL: Ptr("https://api.github.com/users/author/starred{/owner}{/repo}"), - SubscriptionsURL: Ptr("https://api.github.com/users/author/subscriptions"), - OrganizationsURL: Ptr("https://api.github.com/users/author/orgs"), - ReposURL: Ptr("https://api.github.com/users/author/repos"), - EventsURL: Ptr("https://api.github.com/users/author/events{/privacy}"), - ReceivedEventsURL: Ptr("https://api.github.com/users/author/received_events"), - Type: Ptr("User"), - SiteAdmin: Ptr(false), + Login: new("author"), + ID: new(int64(0)), + AvatarURL: new("https://avatars1.githubusercontent.com/u/0?v=4"), + GravatarID: new(""), + URL: new("https://api.github.com/users/author"), + HTMLURL: new("https://github.com/author"), + FollowersURL: new("https://api.github.com/users/author/followers"), + FollowingURL: new("https://api.github.com/users/author/following{/other_user}"), + GistsURL: new("https://api.github.com/users/author/gists{/gist_id}"), + StarredURL: new("https://api.github.com/users/author/starred{/owner}{/repo}"), + SubscriptionsURL: new("https://api.github.com/users/author/subscriptions"), + OrganizationsURL: new("https://api.github.com/users/author/orgs"), + ReposURL: new("https://api.github.com/users/author/repos"), + EventsURL: new("https://api.github.com/users/author/events{/privacy}"), + ReceivedEventsURL: new("https://api.github.com/users/author/received_events"), + Type: new("User"), + SiteAdmin: new(false), }, - Body: Ptr("comment"), - BodyHTML: Ptr("

comment

"), - BodyVersion: Ptr("version"), + Body: new("comment"), + BodyHTML: new("

comment

"), + BodyVersion: new("version"), CreatedAt: refTimestamp(1136178000), LastEditedAt: nil, - DiscussionURL: Ptr("https://api.github.com/teams/2/discussions/3"), - HTMLURL: Ptr("https://github.com/orgs/1/teams/2/discussions/3/comments/4"), - NodeID: Ptr("node"), - Number: Ptr(4), + DiscussionURL: new("https://api.github.com/teams/2/discussions/3"), + HTMLURL: new("https://github.com/orgs/1/teams/2/discussions/3/comments/4"), + NodeID: new("node"), + Number: new(4), UpdatedAt: refTimestamp(1136178001), - URL: Ptr("https://api.github.com/teams/2/discussions/3/comments/4"), + URL: new("https://api.github.com/teams/2/discussions/3/comments/4"), }, } @@ -180,7 +180,7 @@ func TestTeamsService_GetComment(t *testing.T) { testMethod(t, r, "GET") fmt.Fprint(w, `{"number":4}`) } - want := &DiscussionComment{Number: Ptr(4)} + want := &DiscussionComment{Number: new(4)} e := tdcEndpointByID("1", "2", "3", "4") mux.HandleFunc(e, handlerFunc) @@ -240,14 +240,14 @@ func TestTeamsService_CreateComment(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - input := DiscussionComment{Body: Ptr("c")} + input := DiscussionComment{Body: new("c")} handlerFunc := func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "POST") testJSONBody(t, r, input) fmt.Fprint(w, `{"number":4}`) } - want := &DiscussionComment{Number: Ptr(4)} + want := &DiscussionComment{Number: new(4)} e := tdcEndpointByID("1", "2", "3", "") mux.HandleFunc(e, handlerFunc) @@ -307,13 +307,13 @@ func TestTeamsService_EditComment(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - input := DiscussionComment{Body: Ptr("e")} + input := DiscussionComment{Body: new("e")} handlerFunc := func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "PATCH") testJSONBody(t, r, input) fmt.Fprint(w, `{"number":4}`) } - want := &DiscussionComment{Number: Ptr(4)} + want := &DiscussionComment{Number: new(4)} e := tdcEndpointByID("1", "2", "3", "4") mux.HandleFunc(e, handlerFunc) diff --git a/github/teams_discussions_test.go b/github/teams_discussions_test.go index 11be8d3ddda..98a9710d68e 100644 --- a/github/teams_discussions_test.go +++ b/github/teams_discussions_test.go @@ -73,40 +73,40 @@ func TestTeamsService_ListDiscussionsByID(t *testing.T) { want := []*TeamDiscussion{ { Author: &User{ - Login: Ptr("author"), - ID: Ptr(int64(0)), - AvatarURL: Ptr("https://avatars1.githubusercontent.com/u/0?v=4"), - GravatarID: Ptr(""), - URL: Ptr("https://api.github.com/users/author"), - HTMLURL: Ptr("https://github.com/author"), - FollowersURL: Ptr("https://api.github.com/users/author/followers"), - FollowingURL: Ptr("https://api.github.com/users/author/following{/other_user}"), - GistsURL: Ptr("https://api.github.com/users/author/gists{/gist_id}"), - StarredURL: Ptr("https://api.github.com/users/author/starred{/owner}{/repo}"), - SubscriptionsURL: Ptr("https://api.github.com/users/author/subscriptions"), - OrganizationsURL: Ptr("https://api.github.com/users/author/orgs"), - ReposURL: Ptr("https://api.github.com/users/author/repos"), - EventsURL: Ptr("https://api.github.com/users/author/events{/privacy}"), - ReceivedEventsURL: Ptr("https://api.github.com/users/author/received_events"), - Type: Ptr("User"), - SiteAdmin: Ptr(false), + Login: new("author"), + ID: new(int64(0)), + AvatarURL: new("https://avatars1.githubusercontent.com/u/0?v=4"), + GravatarID: new(""), + URL: new("https://api.github.com/users/author"), + HTMLURL: new("https://github.com/author"), + FollowersURL: new("https://api.github.com/users/author/followers"), + FollowingURL: new("https://api.github.com/users/author/following{/other_user}"), + GistsURL: new("https://api.github.com/users/author/gists{/gist_id}"), + StarredURL: new("https://api.github.com/users/author/starred{/owner}{/repo}"), + SubscriptionsURL: new("https://api.github.com/users/author/subscriptions"), + OrganizationsURL: new("https://api.github.com/users/author/orgs"), + ReposURL: new("https://api.github.com/users/author/repos"), + EventsURL: new("https://api.github.com/users/author/events{/privacy}"), + ReceivedEventsURL: new("https://api.github.com/users/author/received_events"), + Type: new("User"), + SiteAdmin: new(false), }, - Body: Ptr("test"), - BodyHTML: Ptr("

test

"), - BodyVersion: Ptr("version"), - CommentsCount: Ptr(1), - CommentsURL: Ptr("https://api.github.com/teams/2/discussions/3/comments"), + Body: new("test"), + BodyHTML: new("

test

"), + BodyVersion: new("version"), + CommentsCount: new(1), + CommentsURL: new("https://api.github.com/teams/2/discussions/3/comments"), CreatedAt: refTimestamp(1136178000), LastEditedAt: nil, - HTMLURL: Ptr("https://github.com/orgs/1/teams/2/discussions/3"), - NodeID: Ptr("node"), - Number: Ptr(3), - Pinned: Ptr(false), - Private: Ptr(false), - TeamURL: Ptr("https://api.github.com/teams/2"), - Title: Ptr("test"), + HTMLURL: new("https://github.com/orgs/1/teams/2/discussions/3"), + NodeID: new("node"), + Number: new(3), + Pinned: new(false), + Private: new(false), + TeamURL: new("https://api.github.com/teams/2"), + Title: new("test"), UpdatedAt: refTimestamp(1136178001), - URL: Ptr("https://api.github.com/teams/2/discussions/3"), + URL: new("https://api.github.com/teams/2/discussions/3"), }, } if !cmp.Equal(discussions, want) { @@ -188,40 +188,40 @@ func TestTeamsService_ListDiscussionsBySlug(t *testing.T) { want := []*TeamDiscussion{ { Author: &User{ - Login: Ptr("author"), - ID: Ptr(int64(0)), - AvatarURL: Ptr("https://avatars1.githubusercontent.com/u/0?v=4"), - GravatarID: Ptr(""), - URL: Ptr("https://api.github.com/users/author"), - HTMLURL: Ptr("https://github.com/author"), - FollowersURL: Ptr("https://api.github.com/users/author/followers"), - FollowingURL: Ptr("https://api.github.com/users/author/following{/other_user}"), - GistsURL: Ptr("https://api.github.com/users/author/gists{/gist_id}"), - StarredURL: Ptr("https://api.github.com/users/author/starred{/owner}{/repo}"), - SubscriptionsURL: Ptr("https://api.github.com/users/author/subscriptions"), - OrganizationsURL: Ptr("https://api.github.com/users/author/orgs"), - ReposURL: Ptr("https://api.github.com/users/author/repos"), - EventsURL: Ptr("https://api.github.com/users/author/events{/privacy}"), - ReceivedEventsURL: Ptr("https://api.github.com/users/author/received_events"), - Type: Ptr("User"), - SiteAdmin: Ptr(false), + Login: new("author"), + ID: new(int64(0)), + AvatarURL: new("https://avatars1.githubusercontent.com/u/0?v=4"), + GravatarID: new(""), + URL: new("https://api.github.com/users/author"), + HTMLURL: new("https://github.com/author"), + FollowersURL: new("https://api.github.com/users/author/followers"), + FollowingURL: new("https://api.github.com/users/author/following{/other_user}"), + GistsURL: new("https://api.github.com/users/author/gists{/gist_id}"), + StarredURL: new("https://api.github.com/users/author/starred{/owner}{/repo}"), + SubscriptionsURL: new("https://api.github.com/users/author/subscriptions"), + OrganizationsURL: new("https://api.github.com/users/author/orgs"), + ReposURL: new("https://api.github.com/users/author/repos"), + EventsURL: new("https://api.github.com/users/author/events{/privacy}"), + ReceivedEventsURL: new("https://api.github.com/users/author/received_events"), + Type: new("User"), + SiteAdmin: new(false), }, - Body: Ptr("test"), - BodyHTML: Ptr("

test

"), - BodyVersion: Ptr("version"), - CommentsCount: Ptr(1), - CommentsURL: Ptr("https://api.github.com/teams/2/discussions/3/comments"), + Body: new("test"), + BodyHTML: new("

test

"), + BodyVersion: new("version"), + CommentsCount: new(1), + CommentsURL: new("https://api.github.com/teams/2/discussions/3/comments"), CreatedAt: refTimestamp(1136178000), LastEditedAt: nil, - HTMLURL: Ptr("https://github.com/orgs/1/teams/2/discussions/3"), - NodeID: Ptr("node"), - Number: Ptr(3), - Pinned: Ptr(false), - Private: Ptr(false), - TeamURL: Ptr("https://api.github.com/teams/2"), - Title: Ptr("test"), + HTMLURL: new("https://github.com/orgs/1/teams/2/discussions/3"), + NodeID: new("node"), + Number: new(3), + Pinned: new(false), + Private: new(false), + TeamURL: new("https://api.github.com/teams/2"), + Title: new("test"), UpdatedAt: refTimestamp(1136178001), - URL: Ptr("https://api.github.com/teams/2/discussions/3"), + URL: new("https://api.github.com/teams/2/discussions/3"), }, } if !cmp.Equal(discussions, want) { @@ -258,7 +258,7 @@ func TestTeamsService_GetDiscussionByID(t *testing.T) { t.Errorf("Teams.GetDiscussionByID returned error: %v", err) } - want := &TeamDiscussion{Number: Ptr(3)} + want := &TeamDiscussion{Number: new(3)} if !cmp.Equal(discussion, want) { t.Errorf("Teams.GetDiscussionByID returned %+v, want %+v", discussion, want) } @@ -293,7 +293,7 @@ func TestTeamsService_GetDiscussionBySlug(t *testing.T) { t.Errorf("Teams.GetDiscussionBySlug returned error: %v", err) } - want := &TeamDiscussion{Number: Ptr(3)} + want := &TeamDiscussion{Number: new(3)} if !cmp.Equal(discussion, want) { t.Errorf("Teams.GetDiscussionBySlug returned %+v, want %+v", discussion, want) } @@ -317,7 +317,7 @@ func TestTeamsService_CreateDiscussionByID(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - input := TeamDiscussion{Title: Ptr("c_t"), Body: Ptr("c_b")} + input := TeamDiscussion{Title: new("c_t"), Body: new("c_b")} mux.HandleFunc("/organizations/1/team/2/discussions", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "POST") @@ -331,7 +331,7 @@ func TestTeamsService_CreateDiscussionByID(t *testing.T) { t.Errorf("Teams.CreateDiscussionByID returned error: %v", err) } - want := &TeamDiscussion{Number: Ptr(3)} + want := &TeamDiscussion{Number: new(3)} if !cmp.Equal(comment, want) { t.Errorf("Teams.CreateDiscussionByID returned %+v, want %+v", comment, want) } @@ -355,7 +355,7 @@ func TestTeamsService_CreateDiscussionBySlug(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - input := TeamDiscussion{Title: Ptr("c_t"), Body: Ptr("c_b")} + input := TeamDiscussion{Title: new("c_t"), Body: new("c_b")} mux.HandleFunc("/orgs/o/teams/s/discussions", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "POST") @@ -369,7 +369,7 @@ func TestTeamsService_CreateDiscussionBySlug(t *testing.T) { t.Errorf("Teams.CreateDiscussionBySlug returned error: %v", err) } - want := &TeamDiscussion{Number: Ptr(3)} + want := &TeamDiscussion{Number: new(3)} if !cmp.Equal(comment, want) { t.Errorf("Teams.CreateDiscussionBySlug returned %+v, want %+v", comment, want) } @@ -393,7 +393,7 @@ func TestTeamsService_EditDiscussionByID(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - input := TeamDiscussion{Title: Ptr("e_t"), Body: Ptr("e_b")} + input := TeamDiscussion{Title: new("e_t"), Body: new("e_b")} mux.HandleFunc("/organizations/1/team/2/discussions/3", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "PATCH") @@ -407,7 +407,7 @@ func TestTeamsService_EditDiscussionByID(t *testing.T) { t.Errorf("Teams.EditDiscussionByID returned error: %v", err) } - want := &TeamDiscussion{Number: Ptr(3)} + want := &TeamDiscussion{Number: new(3)} if !cmp.Equal(comment, want) { t.Errorf("Teams.EditDiscussionByID returned %+v, want %+v", comment, want) } @@ -431,7 +431,7 @@ func TestTeamsService_EditDiscussionBySlug(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - input := TeamDiscussion{Title: Ptr("e_t"), Body: Ptr("e_b")} + input := TeamDiscussion{Title: new("e_t"), Body: new("e_b")} mux.HandleFunc("/orgs/o/teams/s/discussions/3", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "PATCH") @@ -445,7 +445,7 @@ func TestTeamsService_EditDiscussionBySlug(t *testing.T) { t.Errorf("Teams.EditDiscussionBySlug returned error: %v", err) } - want := &TeamDiscussion{Number: Ptr(3)} + want := &TeamDiscussion{Number: new(3)} if !cmp.Equal(comment, want) { t.Errorf("Teams.EditDiscussionBySlug returned %+v, want %+v", comment, want) } diff --git a/github/teams_members_test.go b/github/teams_members_test.go index 72f775e5028..1bae792cbab 100644 --- a/github/teams_members_test.go +++ b/github/teams_members_test.go @@ -30,7 +30,7 @@ func TestTeamsService_ListTeamMembersByID(t *testing.T) { t.Errorf("Teams.ListTeamMembersByID returned error: %v", err) } - want := []*User{{ID: Ptr(int64(1))}} + want := []*User{{ID: new(int64(1))}} if !cmp.Equal(members, want) { t.Errorf("Teams.ListTeamMembersByID returned %+v, want %+v", members, want) } @@ -105,7 +105,7 @@ func TestTeamsService_ListTeamMembersBySlug(t *testing.T) { t.Errorf("Teams.ListTeamMembersBySlug returned error: %v", err) } - want := []*User{{ID: Ptr(int64(1))}} + want := []*User{{ID: new(int64(1))}} if !cmp.Equal(members, want) { t.Errorf("Teams.ListTeamMembersBySlug returned %+v, want %+v", members, want) } @@ -187,7 +187,7 @@ func TestTeamsService_GetTeamMembershipByID(t *testing.T) { t.Errorf("Teams.GetTeamMembershipByID returned error: %v", err) } - want := &Membership{URL: Ptr("u"), State: Ptr("active")} + want := &Membership{URL: new("u"), State: new("active")} if !cmp.Equal(membership, want) { t.Errorf("Teams.GetTeamMembershipByID returned %+v, want %+v", membership, want) } @@ -258,7 +258,7 @@ func TestTeamsService_GetTeamMembershipBySlug(t *testing.T) { t.Errorf("Teams.GetTeamMembershipBySlug returned error: %v", err) } - want := &Membership{URL: Ptr("u"), State: Ptr("active")} + want := &Membership{URL: new("u"), State: new("active")} if !cmp.Equal(membership, want) { t.Errorf("Teams.GetTeamMembershipBySlug returned %+v, want %+v", membership, want) } @@ -341,7 +341,7 @@ func TestTeamsService_AddTeamMembershipByID(t *testing.T) { t.Errorf("Teams.AddTeamMembershipByID returned error: %v", err) } - want := &Membership{URL: Ptr("u"), State: Ptr("pending")} + want := &Membership{URL: new("u"), State: new("pending")} if !cmp.Equal(membership, want) { t.Errorf("Teams.AddTeamMembershipByID returned %+v, want %+v", membership, want) } @@ -418,7 +418,7 @@ func TestTeamsService_AddTeamMembershipBySlug(t *testing.T) { t.Errorf("Teams.AddTeamMembershipBySlug returned error: %v", err) } - want := &Membership{URL: Ptr("u"), State: Ptr("pending")} + want := &Membership{URL: new("u"), State: new("pending")} if !cmp.Equal(membership, want) { t.Errorf("Teams.AddTeamMembershipBySlug returned %+v, want %+v", membership, want) } @@ -622,7 +622,7 @@ func TestTeamsService_ListPendingTeamInvitationsByID(t *testing.T) { t.Errorf("Teams.ListPendingTeamInvitationsByID returned error: %v", err) } - want := []*Invitation{{ID: Ptr(int64(1))}} + want := []*Invitation{{ID: new(int64(1))}} if !cmp.Equal(invitations, want) { t.Errorf("Teams.ListPendingTeamInvitationsByID returned %+v, want %+v", invitations, want) } @@ -697,7 +697,7 @@ func TestTeamsService_ListPendingTeamInvitationsBySlug(t *testing.T) { t.Errorf("Teams.ListPendingTeamInvitationsBySlug returned error: %v", err) } - want := []*Invitation{{ID: Ptr(int64(1))}} + want := []*Invitation{{ID: new(int64(1))}} if !cmp.Equal(invitations, want) { t.Errorf("Teams.ListPendingTeamInvitationsBySlug returned %+v, want %+v", invitations, want) } diff --git a/github/teams_test.go b/github/teams_test.go index 5cbede587e3..5c0896e2365 100644 --- a/github/teams_test.go +++ b/github/teams_test.go @@ -31,7 +31,7 @@ func TestTeamsService_ListTeams(t *testing.T) { t.Errorf("Teams.ListTeams returned error: %v", err) } - want := []*Team{{ID: Ptr(int64(1))}} + want := []*Team{{ID: new(int64(1))}} if !cmp.Equal(teams, want) { t.Errorf("Teams.ListTeams returned %+v, want %+v", teams, want) } @@ -75,7 +75,7 @@ func TestTeamsService_GetTeamByID(t *testing.T) { t.Errorf("Teams.GetTeamByID returned error: %v", err) } - want := &Team{ID: Ptr(int64(1)), Name: Ptr("n"), Description: Ptr("d"), URL: Ptr("u"), Slug: Ptr("s"), Permission: Ptr("p"), LDAPDN: Ptr("cn=n,ou=groups,dc=example,dc=com"), Type: Ptr("organization")} + want := &Team{ID: new(int64(1)), Name: new("n"), Description: new("d"), URL: new("u"), Slug: new("s"), Permission: new("p"), LDAPDN: new("cn=n,ou=groups,dc=example,dc=com"), Type: new("organization")} if !cmp.Equal(team, want) { t.Errorf("Teams.GetTeamByID returned %+v, want %+v", team, want) } @@ -132,7 +132,7 @@ func TestTeamsService_GetTeamBySlug(t *testing.T) { t.Errorf("Teams.GetTeamBySlug returned error: %v", err) } - want := &Team{ID: Ptr(int64(1)), Name: Ptr("n"), Description: Ptr("d"), URL: Ptr("u"), Slug: Ptr("s"), Permission: Ptr("p"), LDAPDN: Ptr("cn=n,ou=groups,dc=example,dc=com"), Type: Ptr("organization")} + want := &Team{ID: new(int64(1)), Name: new("n"), Description: new("d"), URL: new("u"), Slug: new("s"), Permission: new("p"), LDAPDN: new("cn=n,ou=groups,dc=example,dc=com"), Type: new("organization")} if !cmp.Equal(team, want) { t.Errorf("Teams.GetTeamBySlug returned %+v, want %+v", team, want) } @@ -187,7 +187,7 @@ func TestTeamsService_CreateTeam(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - input := CreateTeamRequest{Name: "n", Privacy: Ptr("closed"), RepoNames: []string{"r"}} + input := CreateTeamRequest{Name: "n", Privacy: new("closed"), RepoNames: []string{"r"}} mux.HandleFunc("/orgs/o/teams", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "POST") @@ -201,7 +201,7 @@ func TestTeamsService_CreateTeam(t *testing.T) { t.Errorf("Teams.CreateTeam returned error: %v", err) } - want := &Team{ID: Ptr(int64(1))} + want := &Team{ID: new(int64(1))} if !cmp.Equal(team, want) { t.Errorf("Teams.CreateTeam returned %+v, want %+v", team, want) } @@ -234,7 +234,7 @@ func TestTeamsService_UpdateTeamByID(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - input := UpdateTeamRequest{Name: Ptr("n"), Privacy: Ptr("closed")} + input := UpdateTeamRequest{Name: new("n"), Privacy: new("closed")} mux.HandleFunc("/organizations/1/team/1", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "PATCH") @@ -248,7 +248,7 @@ func TestTeamsService_UpdateTeamByID(t *testing.T) { t.Errorf("Teams.UpdateTeamByID returned error: %v", err) } - want := &Team{ID: Ptr(int64(1))} + want := &Team{ID: new(int64(1))} if !cmp.Equal(team, want) { t.Errorf("Teams.UpdateTeamByID returned %+v, want %+v", team, want) } @@ -272,7 +272,7 @@ func TestTeamsService_UpdateTeamByID_RemoveParent(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - input := UpdateTeamRequest{Name: Ptr("n"), NotificationSetting: Ptr("notifications_enabled"), Privacy: Ptr("closed"), RemoveParentTeam: true} + input := UpdateTeamRequest{Name: new("n"), NotificationSetting: new("notifications_enabled"), Privacy: new("closed"), RemoveParentTeam: true} mux.HandleFunc("/organizations/1/team/1", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "PATCH") @@ -287,7 +287,7 @@ func TestTeamsService_UpdateTeamByID_RemoveParent(t *testing.T) { t.Errorf("Teams.UpdateTeamByID returned error: %v", err) } - want := &Team{ID: Ptr(int64(1))} + want := &Team{ID: new(int64(1))} if !cmp.Equal(team, want) { t.Errorf("Teams.UpdateTeamByID returned %+v, want %+v", team, want) } @@ -297,7 +297,7 @@ func TestTeamsService_UpdateTeamBySlug(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - input := UpdateTeamRequest{Name: Ptr("n"), Privacy: Ptr("closed")} + input := UpdateTeamRequest{Name: new("n"), Privacy: new("closed")} mux.HandleFunc("/orgs/o/teams/s", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "PATCH") @@ -311,7 +311,7 @@ func TestTeamsService_UpdateTeamBySlug(t *testing.T) { t.Errorf("Teams.UpdateTeamBySlug returned error: %v", err) } - want := &Team{ID: Ptr(int64(1))} + want := &Team{ID: new(int64(1))} if !cmp.Equal(team, want) { t.Errorf("Teams.UpdateTeamBySlug returned %+v, want %+v", team, want) } @@ -335,7 +335,7 @@ func TestTeamsService_UpdateTeamBySlug_RemoveParent(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - input := UpdateTeamRequest{Name: Ptr("n"), NotificationSetting: Ptr("notifications_disabled"), Privacy: Ptr("closed"), RemoveParentTeam: true} + input := UpdateTeamRequest{Name: new("n"), NotificationSetting: new("notifications_disabled"), Privacy: new("closed"), RemoveParentTeam: true} mux.HandleFunc("/orgs/o/teams/s", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "PATCH") @@ -350,7 +350,7 @@ func TestTeamsService_UpdateTeamBySlug_RemoveParent(t *testing.T) { t.Errorf("Teams.UpdateTeamBySlug returned error: %v", err) } - want := &Team{ID: Ptr(int64(1))} + want := &Team{ID: new(int64(1))} if !cmp.Equal(team, want) { t.Errorf("Teams.UpdateTeamBySlug returned %+v, want %+v", team, want) } @@ -423,7 +423,7 @@ func TestTeamsService_ListChildTeamsByParentID(t *testing.T) { t.Errorf("Teams.ListChildTeamsByParentID returned error: %v", err) } - want := []*Team{{ID: Ptr(int64(2))}} + want := []*Team{{ID: new(int64(2))}} if !cmp.Equal(teams, want) { t.Errorf("Teams.ListChildTeamsByParentID returned %+v, want %+v", teams, want) } @@ -460,7 +460,7 @@ func TestTeamsService_ListChildTeamsByParentSlug(t *testing.T) { t.Errorf("Teams.ListChildTeamsByParentSlug returned error: %v", err) } - want := []*Team{{ID: Ptr(int64(2))}} + want := []*Team{{ID: new(int64(2))}} if !cmp.Equal(teams, want) { t.Errorf("Teams.ListChildTeamsByParentSlug returned %+v, want %+v", teams, want) } @@ -498,7 +498,7 @@ func TestTeamsService_ListTeamReposByID(t *testing.T) { t.Errorf("Teams.ListTeamReposByID returned error: %v", err) } - want := []*Repository{{ID: Ptr(int64(1))}} + want := []*Repository{{ID: new(int64(1))}} if !cmp.Equal(members, want) { t.Errorf("Teams.ListTeamReposByID returned %+v, want %+v", members, want) } @@ -536,7 +536,7 @@ func TestTeamsService_ListTeamReposBySlug(t *testing.T) { t.Errorf("Teams.ListTeamReposBySlug returned error: %v", err) } - want := []*Repository{{ID: Ptr(int64(1))}} + want := []*Repository{{ID: new(int64(1))}} if !cmp.Equal(members, want) { t.Errorf("Teams.ListTeamReposBySlug returned %+v, want %+v", members, want) } @@ -572,7 +572,7 @@ func TestTeamsService_IsTeamRepoByID_true(t *testing.T) { t.Errorf("Teams.IsTeamRepoByID returned error: %v", err) } - want := &Repository{ID: Ptr(int64(1))} + want := &Repository{ID: new(int64(1))} if !cmp.Equal(repo, want) { t.Errorf("Teams.IsTeamRepoByID returned %+v, want %+v", repo, want) } @@ -608,7 +608,7 @@ func TestTeamsService_IsTeamRepoBySlug_true(t *testing.T) { t.Errorf("Teams.IsTeamRepoBySlug returned error: %v", err) } - want := &Repository{ID: Ptr(int64(1))} + want := &Repository{ID: new(int64(1))} if !cmp.Equal(repo, want) { t.Errorf("Teams.IsTeamRepoBySlug returned %+v, want %+v", repo, want) } @@ -929,7 +929,7 @@ func TestTeamsService_ListUserTeams(t *testing.T) { t.Errorf("Teams.ListUserTeams returned error: %v", err) } - want := []*Team{{ID: Ptr(int64(1))}} + want := []*Team{{ID: new(int64(1))}} if !cmp.Equal(teams, want) { t.Errorf("Teams.ListUserTeams returned %+v, want %+v", teams, want) } @@ -960,7 +960,7 @@ func TestTeamsService_ListProjectsByID(t *testing.T) { t.Errorf("Teams.ListTeamProjectsByID returned error: %v", err) } - want := []*ProjectV2{{ID: Ptr(int64(1))}} + want := []*ProjectV2{{ID: new(int64(1))}} if !cmp.Equal(projects, want) { t.Errorf("Teams.ListTeamProjectsByID returned %+v, want %+v", projects, want) } @@ -996,7 +996,7 @@ func TestTeamsService_ListProjectsBySlug(t *testing.T) { t.Errorf("Teams.ListTeamProjectsBySlug returned error: %v", err) } - want := []*ProjectV2{{ID: Ptr(int64(1))}} + want := []*ProjectV2{{ID: new(int64(1))}} if !cmp.Equal(projects, want) { t.Errorf("Teams.ListTeamProjectsBySlug returned %+v, want %+v", projects, want) } @@ -1032,7 +1032,7 @@ func TestTeamsService_ReviewProjectsByID(t *testing.T) { t.Errorf("Teams.ReviewTeamProjectsByID returned error: %v", err) } - want := &ProjectV2{ID: Ptr(int64(1))} + want := &ProjectV2{ID: new(int64(1))} if !cmp.Equal(project, want) { t.Errorf("Teams.ReviewTeamProjectsByID returned %+v, want %+v", project, want) } @@ -1068,7 +1068,7 @@ func TestTeamsService_ReviewProjectsBySlug(t *testing.T) { t.Errorf("Teams.ReviewTeamProjectsBySlug returned error: %v", err) } - want := &ProjectV2{ID: Ptr(int64(1))} + want := &ProjectV2{ID: new(int64(1))} if !cmp.Equal(project, want) { t.Errorf("Teams.ReviewTeamProjectsBySlug returned %+v, want %+v", project, want) } @@ -1093,7 +1093,7 @@ func TestTeamsService_AddTeamProjectByID(t *testing.T) { client, mux, _ := setup(t) opt := &TeamProjectOptions{ - Permission: Ptr("admin"), + Permission: new("admin"), } mux.HandleFunc("/organizations/1/team/1/projects/1", func(w http.ResponseWriter, r *http.Request) { @@ -1125,7 +1125,7 @@ func TestTeamsService_AddTeamProjectBySlug(t *testing.T) { client, mux, _ := setup(t) opt := &TeamProjectOptions{ - Permission: Ptr("admin"), + Permission: new("admin"), } mux.HandleFunc("/orgs/o/teams/s/projects/1", func(w http.ResponseWriter, r *http.Request) { @@ -1232,9 +1232,9 @@ func TestTeamsService_ListIDPGroupsInOrganization(t *testing.T) { want := &IDPGroupList{ Groups: []*IDPGroup{ { - GroupID: Ptr("1"), - GroupName: Ptr("n"), - GroupDescription: Ptr("d"), + GroupID: new("1"), + GroupName: new("n"), + GroupDescription: new("d"), }, }, } @@ -1275,9 +1275,9 @@ func TestTeamsService_ListIDPGroupsForTeamByID(t *testing.T) { want := &IDPGroupList{ Groups: []*IDPGroup{ { - GroupID: Ptr("1"), - GroupName: Ptr("n"), - GroupDescription: Ptr("d"), + GroupID: new("1"), + GroupName: new("n"), + GroupDescription: new("d"), }, }, } @@ -1318,9 +1318,9 @@ func TestTeamsService_ListIDPGroupsForTeamBySlug(t *testing.T) { want := &IDPGroupList{ Groups: []*IDPGroup{ { - GroupID: Ptr("1"), - GroupName: Ptr("n"), - GroupDescription: Ptr("d"), + GroupID: new("1"), + GroupName: new("n"), + GroupDescription: new("d"), }, }, } @@ -1355,9 +1355,9 @@ func TestTeamsService_CreateOrUpdateIDPGroupConnectionsByID(t *testing.T) { input := IDPGroupList{ Groups: []*IDPGroup{ { - GroupID: Ptr("1"), - GroupName: Ptr("n"), - GroupDescription: Ptr("d"), + GroupID: new("1"), + GroupName: new("n"), + GroupDescription: new("d"), }, }, } @@ -1371,9 +1371,9 @@ func TestTeamsService_CreateOrUpdateIDPGroupConnectionsByID(t *testing.T) { want := &IDPGroupList{ Groups: []*IDPGroup{ { - GroupID: Ptr("1"), - GroupName: Ptr("n"), - GroupDescription: Ptr("d"), + GroupID: new("1"), + GroupName: new("n"), + GroupDescription: new("d"), }, }, } @@ -1408,9 +1408,9 @@ func TestTeamsService_CreateOrUpdateIDPGroupConnectionsBySlug(t *testing.T) { input := IDPGroupList{ Groups: []*IDPGroup{ { - GroupID: Ptr("1"), - GroupName: Ptr("n"), - GroupDescription: Ptr("d"), + GroupID: new("1"), + GroupName: new("n"), + GroupDescription: new("d"), }, }, } @@ -1424,9 +1424,9 @@ func TestTeamsService_CreateOrUpdateIDPGroupConnectionsBySlug(t *testing.T) { want := &IDPGroupList{ Groups: []*IDPGroup{ { - GroupID: Ptr("1"), - GroupName: Ptr("n"), - GroupDescription: Ptr("d"), + GroupID: new("1"), + GroupName: new("n"), + GroupDescription: new("d"), }, }, } @@ -1547,31 +1547,31 @@ func TestTeamsService_GetExternalGroup(t *testing.T) { } want := &ExternalGroup{ - GroupID: Ptr(int64(123)), - GroupName: Ptr("Octocat admins"), + GroupID: new(int64(123)), + GroupName: new("Octocat admins"), UpdatedAt: &Timestamp{Time: referenceTime}, Teams: []*ExternalGroupTeam{ { - TeamID: Ptr(int64(1)), - TeamName: Ptr("team-test"), + TeamID: new(int64(1)), + TeamName: new("team-test"), }, { - TeamID: Ptr(int64(2)), - TeamName: Ptr("team-test2"), + TeamID: new(int64(2)), + TeamName: new("team-test2"), }, }, Members: []*ExternalGroupMember{ { - MemberID: Ptr(int64(1)), - MemberLogin: Ptr("mona-lisa_eocsaxrs"), - MemberName: Ptr("Mona Lisa"), - MemberEmail: Ptr("mona_lisa@github.com"), + MemberID: new(int64(1)), + MemberLogin: new("mona-lisa_eocsaxrs"), + MemberName: new("Mona Lisa"), + MemberEmail: new("mona_lisa@github.com"), }, { - MemberID: Ptr(int64(2)), - MemberLogin: Ptr("octo-lisa_eocsaxrs"), - MemberName: Ptr("Octo Lisa"), - MemberEmail: Ptr("octo_lisa@github.com"), + MemberID: new(int64(2)), + MemberLogin: new("octo-lisa_eocsaxrs"), + MemberName: new("Octo Lisa"), + MemberEmail: new("octo_lisa@github.com"), }, }, } @@ -1635,7 +1635,7 @@ func TestTeamsService_ListExternalGroups(t *testing.T) { ctx := t.Context() opts := &ListExternalGroupsOptions{ - DisplayName: Ptr("Octocat"), + DisplayName: new("Octocat"), } list, _, err := client.Teams.ListExternalGroups(ctx, "o", opts) if err != nil { @@ -1645,8 +1645,8 @@ func TestTeamsService_ListExternalGroups(t *testing.T) { want := &ExternalGroupList{ Groups: []*ExternalGroup{ { - GroupID: Ptr(int64(123)), - GroupName: Ptr("Octocat admins"), + GroupID: new(int64(123)), + GroupName: new("Octocat admins"), UpdatedAt: &Timestamp{Time: referenceTime}, }, }, @@ -1718,8 +1718,8 @@ func TestTeamsService_ListExternalGroupsForTeamBySlug(t *testing.T) { want := &ExternalGroupList{ Groups: []*ExternalGroup{ { - GroupID: Ptr(int64(123)), - GroupName: Ptr("Octocat admins"), + GroupID: new(int64(123)), + GroupName: new("Octocat admins"), UpdatedAt: &Timestamp{Time: referenceTime}, }, }, @@ -1812,31 +1812,31 @@ func TestTeamsService_UpdateConnectedExternalGroup(t *testing.T) { } want := &ExternalGroup{ - GroupID: Ptr(int64(123)), - GroupName: Ptr("Octocat admins"), + GroupID: new(int64(123)), + GroupName: new("Octocat admins"), UpdatedAt: &Timestamp{Time: referenceTime}, Teams: []*ExternalGroupTeam{ { - TeamID: Ptr(int64(1)), - TeamName: Ptr("team-test"), + TeamID: new(int64(1)), + TeamName: new("team-test"), }, { - TeamID: Ptr(int64(2)), - TeamName: Ptr("team-test2"), + TeamID: new(int64(2)), + TeamName: new("team-test2"), }, }, Members: []*ExternalGroupMember{ { - MemberID: Ptr(int64(1)), - MemberLogin: Ptr("mona-lisa_eocsaxrs"), - MemberName: Ptr("Mona Lisa"), - MemberEmail: Ptr("mona_lisa@github.com"), + MemberID: new(int64(1)), + MemberLogin: new("mona-lisa_eocsaxrs"), + MemberName: new("Mona Lisa"), + MemberEmail: new("mona_lisa@github.com"), }, { - MemberID: Ptr(int64(2)), - MemberLogin: Ptr("octo-lisa_eocsaxrs"), - MemberName: Ptr("Octo Lisa"), - MemberEmail: Ptr("octo_lisa@github.com"), + MemberID: new(int64(2)), + MemberLogin: new("octo-lisa_eocsaxrs"), + MemberName: new("Octo Lisa"), + MemberEmail: new("octo_lisa@github.com"), }, }, } diff --git a/github/users_administration_test.go b/github/users_administration_test.go index 34ca232a269..563975823b8 100644 --- a/github/users_administration_test.go +++ b/github/users_administration_test.go @@ -92,7 +92,7 @@ func TestUsersServiceReason_Suspend(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - input := &UserSuspendOptions{Reason: Ptr("test")} + input := &UserSuspendOptions{Reason: new("test")} mux.HandleFunc("/users/u/suspended", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "PUT") diff --git a/github/users_blocking_test.go b/github/users_blocking_test.go index 79e0dbf6589..12a1d017367 100644 --- a/github/users_blocking_test.go +++ b/github/users_blocking_test.go @@ -33,7 +33,7 @@ func TestUsersService_ListBlockedUsers(t *testing.T) { t.Errorf("Users.ListBlockedUsers returned error: %v", err) } - want := []*User{{Login: Ptr("octocat")}} + want := []*User{{Login: new("octocat")}} if !cmp.Equal(blockedUsers, want) { t.Errorf("Users.ListBlockedUsers returned %+v, want %+v", blockedUsers, want) } diff --git a/github/users_emails_test.go b/github/users_emails_test.go index 3d24c1bdd4a..2ec5793aab3 100644 --- a/github/users_emails_test.go +++ b/github/users_emails_test.go @@ -34,7 +34,7 @@ func TestUsersService_ListEmails(t *testing.T) { t.Errorf("Users.ListEmails returned error: %v", err) } - want := []*UserEmail{{Email: Ptr("user@example.com"), Verified: Ptr(false), Primary: Ptr(true)}} + want := []*UserEmail{{Email: new("user@example.com"), Verified: new(false), Primary: new(true)}} if !cmp.Equal(emails, want) { t.Errorf("Users.ListEmails returned %+v, want %+v", emails, want) } @@ -68,8 +68,8 @@ func TestUsersService_AddEmails(t *testing.T) { } want := []*UserEmail{ - {Email: Ptr("old@example.com")}, - {Email: Ptr("new@example.com")}, + {Email: new("old@example.com")}, + {Email: new("new@example.com")}, } if !cmp.Equal(emails, want) { t.Errorf("Users.AddEmails returned %+v, want %+v", emails, want) @@ -112,7 +112,7 @@ func TestUsersService_SetEmailVisibility(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - input := &UserEmail{Visibility: Ptr("private")} + input := &UserEmail{Visibility: new("private")} mux.HandleFunc("/user/email/visibility", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "PATCH") @@ -131,7 +131,7 @@ func TestUsersService_SetEmailVisibility(t *testing.T) { t.Errorf("Users.SetEmailVisibility returned error: %v", err) } - want := []*UserEmail{{Email: Ptr("user@example.com"), Verified: Ptr(false), Primary: Ptr(true), Visibility: Ptr("private")}} + want := []*UserEmail{{Email: new("user@example.com"), Verified: new(false), Primary: new(true), Visibility: new("private")}} if !cmp.Equal(emails, want) { t.Errorf("Users.SetEmailVisibility returned %+v, want %+v", emails, want) } diff --git a/github/users_followers_test.go b/github/users_followers_test.go index 21e42aab34c..3a486f75010 100644 --- a/github/users_followers_test.go +++ b/github/users_followers_test.go @@ -30,7 +30,7 @@ func TestUsersService_ListFollowers_authenticatedUser(t *testing.T) { t.Errorf("Users.ListFollowers returned error: %v", err) } - want := []*User{{ID: Ptr(int64(1))}} + want := []*User{{ID: new(int64(1))}} if !cmp.Equal(users, want) { t.Errorf("Users.ListFollowers returned %+v, want %+v", users, want) } @@ -65,7 +65,7 @@ func TestUsersService_ListFollowers_specifiedUser(t *testing.T) { t.Errorf("Users.ListFollowers returned error: %v", err) } - want := []*User{{ID: Ptr(int64(1))}} + want := []*User{{ID: new(int64(1))}} if !cmp.Equal(users, want) { t.Errorf("Users.ListFollowers returned %+v, want %+v", users, want) } @@ -111,7 +111,7 @@ func TestUsersService_ListFollowing_authenticatedUser(t *testing.T) { t.Errorf("Users.ListFollowing returned error: %v", err) } - want := []*User{{ID: Ptr(int64(1))}} + want := []*User{{ID: new(int64(1))}} if !cmp.Equal(users, want) { t.Errorf("Users.ListFollowing returned %+v, want %+v", users, want) } @@ -146,7 +146,7 @@ func TestUsersService_ListFollowing_specifiedUser(t *testing.T) { t.Errorf("Users.ListFollowing returned error: %v", err) } - want := []*User{{ID: Ptr(int64(1))}} + want := []*User{{ID: new(int64(1))}} if !cmp.Equal(users, want) { t.Errorf("Users.ListFollowing returned %+v, want %+v", users, want) } diff --git a/github/users_gpg_keys_test.go b/github/users_gpg_keys_test.go index 0c87f31f761..843c910b15e 100644 --- a/github/users_gpg_keys_test.go +++ b/github/users_gpg_keys_test.go @@ -30,7 +30,7 @@ func TestUsersService_ListGPGKeys_authenticatedUser(t *testing.T) { t.Errorf("Users.ListGPGKeys returned error: %v", err) } - want := []*GPGKey{{ID: Ptr(int64(1)), PrimaryKeyID: Ptr(int64(2))}} + want := []*GPGKey{{ID: new(int64(1)), PrimaryKeyID: new(int64(2))}} if !cmp.Equal(keys, want) { t.Errorf("Users.ListGPGKeys = %+v, want %+v", keys, want) } @@ -65,7 +65,7 @@ func TestUsersService_ListGPGKeys_specifiedUser(t *testing.T) { t.Errorf("Users.ListGPGKeys returned error: %v", err) } - want := []*GPGKey{{ID: Ptr(int64(1)), PrimaryKeyID: Ptr(int64(2))}} + want := []*GPGKey{{ID: new(int64(1)), PrimaryKeyID: new(int64(2))}} if !cmp.Equal(keys, want) { t.Errorf("Users.ListGPGKeys = %+v, want %+v", keys, want) } @@ -95,7 +95,7 @@ func TestUsersService_GetGPGKey(t *testing.T) { t.Errorf("Users.GetGPGKey returned error: %v", err) } - want := &GPGKey{ID: Ptr(int64(1))} + want := &GPGKey{ID: new(int64(1))} if !cmp.Equal(key, want) { t.Errorf("Users.GetGPGKey = %+v, want %+v", key, want) } @@ -146,7 +146,7 @@ mQINBFcEd9kBEACo54TDbGhKlXKWMvJgecEUKPPcv7XdnpKdGb3LRw5MvFwT0V0f t.Errorf("Users.CreateGPGKey returned error: %v", err) } - want := &GPGKey{ID: Ptr(int64(1))} + want := &GPGKey{ID: new(int64(1))} if !cmp.Equal(gpgKey, want) { t.Errorf("Users.GetGPGKey = %+v, want %+v", gpgKey, want) } diff --git a/github/users_keys_test.go b/github/users_keys_test.go index 245d99516a2..31c0037bec2 100644 --- a/github/users_keys_test.go +++ b/github/users_keys_test.go @@ -30,7 +30,7 @@ func TestUsersService_ListKeys_authenticatedUser(t *testing.T) { t.Errorf("Users.ListKeys returned error: %v", err) } - want := []*Key{{ID: Ptr(int64(1))}} + want := []*Key{{ID: new(int64(1))}} if !cmp.Equal(keys, want) { t.Errorf("Users.ListKeys returned %+v, want %+v", keys, want) } @@ -65,7 +65,7 @@ func TestUsersService_ListKeys_specifiedUser(t *testing.T) { t.Errorf("Users.ListKeys returned error: %v", err) } - want := []*Key{{ID: Ptr(int64(1))}} + want := []*Key{{ID: new(int64(1))}} if !cmp.Equal(keys, want) { t.Errorf("Users.ListKeys returned %+v, want %+v", keys, want) } @@ -95,7 +95,7 @@ func TestUsersService_GetKey(t *testing.T) { t.Errorf("Users.GetKey returned error: %v", err) } - want := &Key{ID: Ptr(int64(1))} + want := &Key{ID: new(int64(1))} if !cmp.Equal(key, want) { t.Errorf("Users.GetKey returned %+v, want %+v", key, want) } @@ -119,7 +119,7 @@ func TestUsersService_CreateKey(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - input := &Key{Key: Ptr("k"), Title: Ptr("t")} + input := &Key{Key: new("k"), Title: new("t")} mux.HandleFunc("/user/keys", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "POST") @@ -133,7 +133,7 @@ func TestUsersService_CreateKey(t *testing.T) { t.Errorf("Users.CreateKey returned error: %v", err) } - want := &Key{ID: Ptr(int64(1))} + want := &Key{ID: new(int64(1))} if !cmp.Equal(key, want) { t.Errorf("Users.CreateKey returned %+v, want %+v", key, want) } diff --git a/github/users_packages_test.go b/github/users_packages_test.go index 939344fd93d..013a2485988 100644 --- a/github/users_packages_test.go +++ b/github/users_packages_test.go @@ -36,19 +36,19 @@ func TestUsersService_Authenticated_ListPackages(t *testing.T) { }) ctx := t.Context() - packages, _, err := client.Users.ListPackages(ctx, "", &PackageListOptions{PackageType: Ptr("container"), Visibility: Ptr("private")}) + packages, _, err := client.Users.ListPackages(ctx, "", &PackageListOptions{PackageType: new("container"), Visibility: new("private")}) if err != nil { t.Errorf("Users.Authenticated_ListPackages returned error: %v", err) } want := []*Package{{ - ID: Ptr(int64(197)), - Name: Ptr("hello_docker"), - PackageType: Ptr("container"), - VersionCount: Ptr(int64(1)), - Visibility: Ptr("private"), - URL: Ptr("https://api.github.com/orgs/github/packages/container/hello_docker"), - HTMLURL: Ptr("https://github.com/orgs/github/packages/container/package/hello_docker"), + ID: new(int64(197)), + Name: new("hello_docker"), + PackageType: new("container"), + VersionCount: new(int64(1)), + Visibility: new("private"), + URL: new("https://api.github.com/orgs/github/packages/container/hello_docker"), + HTMLURL: new("https://github.com/orgs/github/packages/container/package/hello_docker"), CreatedAt: &Timestamp{referenceTime}, UpdatedAt: &Timestamp{referenceTime}, }} @@ -92,19 +92,19 @@ func TestUsersService_specifiedUser_ListPackages(t *testing.T) { }) ctx := t.Context() - packages, _, err := client.Users.ListPackages(ctx, "u", &PackageListOptions{PackageType: Ptr("container"), Visibility: Ptr("public")}) + packages, _, err := client.Users.ListPackages(ctx, "u", &PackageListOptions{PackageType: new("container"), Visibility: new("public")}) if err != nil { t.Errorf("Users.specifiedUser_ListPackages returned error: %v", err) } want := []*Package{{ - ID: Ptr(int64(197)), - Name: Ptr("hello_docker"), - PackageType: Ptr("container"), - VersionCount: Ptr(int64(1)), - Visibility: Ptr("public"), - URL: Ptr("https://api.github.com/orgs/github/packages/container/hello_docker"), - HTMLURL: Ptr("https://github.com/orgs/github/packages/container/package/hello_docker"), + ID: new(int64(197)), + Name: new("hello_docker"), + PackageType: new("container"), + VersionCount: new(int64(1)), + Visibility: new("public"), + URL: new("https://api.github.com/orgs/github/packages/container/hello_docker"), + HTMLURL: new("https://github.com/orgs/github/packages/container/package/hello_docker"), CreatedAt: &Timestamp{referenceTime}, UpdatedAt: &Timestamp{referenceTime}, }} @@ -156,13 +156,13 @@ func TestUsersService_specifiedUser_GetPackage(t *testing.T) { } want := &Package{ - ID: Ptr(int64(197)), - Name: Ptr("hello/hello_docker"), - PackageType: Ptr("container"), - VersionCount: Ptr(int64(1)), - Visibility: Ptr("private"), - URL: Ptr("https://api.github.com/orgs/github/packages/container/hello%2Fhello_docker"), - HTMLURL: Ptr("https://github.com/orgs/github/packages/container/package/hello%2Fhello_docker"), + ID: new(int64(197)), + Name: new("hello/hello_docker"), + PackageType: new("container"), + VersionCount: new(int64(1)), + Visibility: new("private"), + URL: new("https://api.github.com/orgs/github/packages/container/hello%2Fhello_docker"), + HTMLURL: new("https://github.com/orgs/github/packages/container/package/hello%2Fhello_docker"), CreatedAt: &Timestamp{referenceTime}, UpdatedAt: &Timestamp{referenceTime}, } @@ -210,13 +210,13 @@ func TestUsersService_Authenticated_GetPackage(t *testing.T) { } want := &Package{ - ID: Ptr(int64(197)), - Name: Ptr("hello_docker"), - PackageType: Ptr("container"), - VersionCount: Ptr(int64(1)), - Visibility: Ptr("private"), - URL: Ptr("https://api.github.com/orgs/github/packages/container/hello_docker"), - HTMLURL: Ptr("https://github.com/orgs/github/packages/container/package/hello_docker"), + ID: new(int64(197)), + Name: new("hello_docker"), + PackageType: new("container"), + VersionCount: new(int64(1)), + Visibility: new("private"), + URL: new("https://api.github.com/orgs/github/packages/container/hello_docker"), + HTMLURL: new("https://github.com/orgs/github/packages/container/package/hello_docker"), CreatedAt: &Timestamp{referenceTime}, UpdatedAt: &Timestamp{referenceTime}, } @@ -377,13 +377,13 @@ func TestUsersService_ListPackageVersions(t *testing.T) { } want := []*PackageVersion{{ - ID: Ptr(int64(45763)), - Name: Ptr("sha256:08a44bab0bddaddd8837a8b381aebc2e4b933768b981685a9e088360af0d3dd9"), - URL: Ptr("https://api.github.com/users/octocat/packages/container/hello_docker/versions/45763"), - PackageHTMLURL: Ptr("https://github.com/users/octocat/packages/container/package/hello_docker"), + ID: new(int64(45763)), + Name: new("sha256:08a44bab0bddaddd8837a8b381aebc2e4b933768b981685a9e088360af0d3dd9"), + URL: new("https://api.github.com/users/octocat/packages/container/hello_docker/versions/45763"), + PackageHTMLURL: new("https://github.com/users/octocat/packages/container/package/hello_docker"), CreatedAt: &Timestamp{referenceTime}, UpdatedAt: &Timestamp{referenceTime}, - HTMLURL: Ptr("https://github.com/users/octocat/packages/container/hello_docker/45763"), + HTMLURL: new("https://github.com/users/octocat/packages/container/hello_docker/45763"), Metadata: json.RawMessage(m), }} if !cmp.Equal(packages, want) { @@ -440,13 +440,13 @@ func TestUsersService_ListUserPackageVersions(t *testing.T) { } want := []*PackageVersion{{ - ID: Ptr(int64(45763)), - Name: Ptr("sha256:08a44bab0bddaddd8837a8b381aebc2e4b933768b981685a9e088360af0d3dd9"), - URL: Ptr("https://api.github.com/users/octocat/packages/container/hello_docker/versions/45763"), - PackageHTMLURL: Ptr("https://github.com/users/octocat/packages/container/package/hello_docker"), + ID: new(int64(45763)), + Name: new("sha256:08a44bab0bddaddd8837a8b381aebc2e4b933768b981685a9e088360af0d3dd9"), + URL: new("https://api.github.com/users/octocat/packages/container/hello_docker/versions/45763"), + PackageHTMLURL: new("https://github.com/users/octocat/packages/container/package/hello_docker"), CreatedAt: &Timestamp{referenceTime}, UpdatedAt: &Timestamp{referenceTime}, - HTMLURL: Ptr("https://github.com/users/octocat/packages/container/hello_docker/45763"), + HTMLURL: new("https://github.com/users/octocat/packages/container/hello_docker/45763"), Metadata: json.RawMessage(m), }} if !cmp.Equal(packages, want) { @@ -503,13 +503,13 @@ func TestUsersService_Authenticated_PackageGetVersion(t *testing.T) { } want := &PackageVersion{ - ID: Ptr(int64(45763)), - Name: Ptr("sha256:08a44bab0bddaddd8837a8b381aebc2e4b933768b981685a9e088360af0d3dd9"), - URL: Ptr("https://api.github.com/users/octocat/packages/container/hello_docker/versions/45763"), - PackageHTMLURL: Ptr("https://github.com/users/octocat/packages/container/package/hello_docker"), + ID: new(int64(45763)), + Name: new("sha256:08a44bab0bddaddd8837a8b381aebc2e4b933768b981685a9e088360af0d3dd9"), + URL: new("https://api.github.com/users/octocat/packages/container/hello_docker/versions/45763"), + PackageHTMLURL: new("https://github.com/users/octocat/packages/container/package/hello_docker"), CreatedAt: &Timestamp{referenceTime}, UpdatedAt: &Timestamp{referenceTime}, - HTMLURL: Ptr("https://github.com/users/octocat/packages/container/hello_docker/45763"), + HTMLURL: new("https://github.com/users/octocat/packages/container/hello_docker/45763"), Metadata: json.RawMessage(m), } if !cmp.Equal(packages, want) { @@ -566,13 +566,13 @@ func TestUsersService_specifiedUser_PackageGetVersion(t *testing.T) { } want := &PackageVersion{ - ID: Ptr(int64(45763)), - Name: Ptr("sha256:08a44bab0bddaddd8837a8b381aebc2e4b933768b981685a9e088360af0d3dd9"), - URL: Ptr("https://api.github.com/users/octocat/packages/container/hello_docker/versions/45763"), - PackageHTMLURL: Ptr("https://github.com/users/octocat/packages/container/package/hello_docker"), + ID: new(int64(45763)), + Name: new("sha256:08a44bab0bddaddd8837a8b381aebc2e4b933768b981685a9e088360af0d3dd9"), + URL: new("https://api.github.com/users/octocat/packages/container/hello_docker/versions/45763"), + PackageHTMLURL: new("https://github.com/users/octocat/packages/container/package/hello_docker"), CreatedAt: &Timestamp{referenceTime}, UpdatedAt: &Timestamp{referenceTime}, - HTMLURL: Ptr("https://github.com/users/octocat/packages/container/hello_docker/45763"), + HTMLURL: new("https://github.com/users/octocat/packages/container/hello_docker/45763"), Metadata: json.RawMessage(m), } if !cmp.Equal(packages, want) { diff --git a/github/users_social_accounts_test.go b/github/users_social_accounts_test.go index 5cb8631593d..4afca7f3bd7 100644 --- a/github/users_social_accounts_test.go +++ b/github/users_social_accounts_test.go @@ -34,7 +34,7 @@ func TestUsersService_ListSocialAccounts(t *testing.T) { t.Errorf("Users.ListSocialAccounts returned error: %v", err) } - want := []*SocialAccount{{Provider: Ptr("example"), URL: Ptr("https://example.com")}} + want := []*SocialAccount{{Provider: new("example"), URL: new("https://example.com")}} if !cmp.Equal(accounts, want) { t.Errorf("Users.ListSocialAccounts returned %#v, want %#v", accounts, want) } @@ -71,7 +71,7 @@ func TestUsersService_AddSocialAccounts(t *testing.T) { } want := []*SocialAccount{ - {Provider: Ptr("example"), URL: Ptr("https://example.com")}, + {Provider: new("example"), URL: new("https://example.com")}, } if !cmp.Equal(accounts, want) { t.Errorf("Users.AddSocialAccounts returned %#v, want %#v", accounts, want) @@ -135,7 +135,7 @@ func TestUsersService_ListUserSocialAccounts(t *testing.T) { t.Errorf("Users.ListUserSocialAccounts returned error: %v", err) } - want := []*SocialAccount{{Provider: Ptr("example"), URL: Ptr("https://example.com")}} + want := []*SocialAccount{{Provider: new("example"), URL: new("https://example.com")}} if !cmp.Equal(accounts, want) { t.Errorf("Users.ListUserSocialAccounts returned %#v, want %#v", accounts, want) } diff --git a/github/users_ssh_signing_keys_test.go b/github/users_ssh_signing_keys_test.go index f4c9c7f7a52..f3878342e11 100644 --- a/github/users_ssh_signing_keys_test.go +++ b/github/users_ssh_signing_keys_test.go @@ -30,7 +30,7 @@ func TestUsersService_ListSSHSigningKeys_authenticatedUser(t *testing.T) { t.Errorf("Users.ListSSHSigningKeys returned error: %v", err) } - want := []*SSHSigningKey{{ID: Ptr(int64(1))}} + want := []*SSHSigningKey{{ID: new(int64(1))}} if !cmp.Equal(keys, want) { t.Errorf("Users.ListSSHSigningKeys returned %+v, want %+v", keys, want) } @@ -65,7 +65,7 @@ func TestUsersService_ListSSHSigningKeys_specifiedUser(t *testing.T) { t.Errorf("Users.ListSSHSigningKeys returned error: %v", err) } - want := []*SSHSigningKey{{ID: Ptr(int64(1))}} + want := []*SSHSigningKey{{ID: new(int64(1))}} if !cmp.Equal(keys, want) { t.Errorf("Users.ListSSHSigningKeys returned %+v, want %+v", keys, want) } @@ -95,7 +95,7 @@ func TestUsersService_GetSSHSigningKey(t *testing.T) { t.Errorf("Users.GetSSHSigningKey returned error: %v", err) } - want := &SSHSigningKey{ID: Ptr(int64(1))} + want := &SSHSigningKey{ID: new(int64(1))} if !cmp.Equal(key, want) { t.Errorf("Users.GetSSHSigningKey returned %+v, want %+v", key, want) } @@ -119,7 +119,7 @@ func TestUsersService_CreateSSHSigningKey(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - input := &Key{Key: Ptr("k"), Title: Ptr("t")} + input := &Key{Key: new("k"), Title: new("t")} mux.HandleFunc("/user/ssh_signing_keys", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "POST") @@ -133,7 +133,7 @@ func TestUsersService_CreateSSHSigningKey(t *testing.T) { t.Errorf("Users.CreateSSHSigningKey returned error: %v", err) } - want := &SSHSigningKey{ID: Ptr(int64(1))} + want := &SSHSigningKey{ID: new(int64(1))} if !cmp.Equal(key, want) { t.Errorf("Users.CreateSSHSigningKey returned %+v, want %+v", key, want) } diff --git a/github/users_test.go b/github/users_test.go index 7cf364c183c..7be50124cc6 100644 --- a/github/users_test.go +++ b/github/users_test.go @@ -28,7 +28,7 @@ func TestUsersService_Get_authenticatedUser(t *testing.T) { t.Errorf("Users.Get returned error: %v", err) } - want := &User{ID: Ptr(int64(1))} + want := &User{ID: new(int64(1))} if !cmp.Equal(user, want) { t.Errorf("Users.Get returned %+v, want %+v", user, want) } @@ -63,7 +63,7 @@ func TestUsersService_Get_specifiedUser(t *testing.T) { t.Errorf("Users.Get returned error: %v", err) } - want := &User{ID: Ptr(int64(1))} + want := &User{ID: new(int64(1))} if !cmp.Equal(user, want) { t.Errorf("Users.Get returned %+v, want %+v", user, want) } @@ -93,7 +93,7 @@ func TestUsersService_GetByID(t *testing.T) { t.Fatalf("Users.GetByID returned error: %v", err) } - want := &User{ID: Ptr(int64(1))} + want := &User{ID: new(int64(1))} if !cmp.Equal(user, want) { t.Errorf("Users.GetByID returned %+v, want %+v", user, want) } @@ -117,7 +117,7 @@ func TestUsersService_Update(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - input := UserUpdateRequest{Name: Ptr("n")} + input := UserUpdateRequest{Name: new("n")} mux.HandleFunc("/user", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "PATCH") @@ -131,7 +131,7 @@ func TestUsersService_Update(t *testing.T) { t.Errorf("Users.Update returned error: %v", err) } - want := &User{ID: Ptr(int64(1))} + want := &User{ID: new(int64(1))} if !cmp.Equal(user, want) { t.Errorf("Users.Update returned %+v, want %+v", user, want) } @@ -163,7 +163,7 @@ func TestUsersService_GetHovercard(t *testing.T) { t.Errorf("Users.GetHovercard returned error: %v", err) } - want := &Hovercard{Contexts: []*UserContext{{Message: Ptr("Owns this repository"), Octicon: Ptr("repo")}}} + want := &Hovercard{Contexts: []*UserContext{{Message: new("Owns this repository"), Octicon: new("repo")}}} if !cmp.Equal(hovercard, want) { t.Errorf("Users.GetHovercard returned %+v, want %+v", hovercard, want) } @@ -200,7 +200,7 @@ func TestUsersService_ListAll(t *testing.T) { t.Errorf("Users.ListAll returned error: %v", err) } - want := []*User{{ID: Ptr(int64(2))}} + want := []*User{{ID: new(int64(2))}} if !cmp.Equal(users, want) { t.Errorf("Users.ListAll returned %+v, want %+v", users, want) } @@ -230,7 +230,7 @@ func TestUsersService_ListInvitations(t *testing.T) { t.Errorf("Users.ListInvitations returned error: %v", err) } - want := []*RepositoryInvitation{{ID: Ptr(int64(1))}, {ID: Ptr(int64(2))}} + want := []*RepositoryInvitation{{ID: new(int64(1))}, {ID: new(int64(2))}} if !cmp.Equal(got, want) { t.Errorf("Users.ListInvitations = %+v, want %+v", got, want) } diff --git a/go.mod b/go.mod index 229ed21bb29..d4c95dba674 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/google/go-github/v90 -go 1.25.0 +go 1.26.0 require ( github.com/google/go-cmp v0.7.0 From 5f86d04a4fc0d5dc4e76539a61a4b13c435b7984 Mon Sep 17 00:00:00 2001 From: ajayk Date: Sun, 23 Aug 2026 08:50:47 -0700 Subject: [PATCH 2/2] feat: Require Go 1.26 and use new(expr) for pointer literals Bump go.mod to 1.26 per the N-1 support policy (Go 1.27 is current) and replace Ptr() with the new(v) builtin across tests. --- example/actionpermissions/main.go | 6 +++--- example/commitpr/main.go | 6 +++--- example/go.mod | 2 +- example/newfilewithappauth/main.go | 2 +- github/github.go | 9 +++------ github/issue_import.go | 3 +-- github/orgs_outside_collaborators_test.go | 9 +++------ github/repos_forks.go | 3 +-- github/security_advisories.go | 3 +-- otel/go.mod | 2 +- test/integration/activity_test.go | 2 +- test/integration/licences_test.go | 2 +- test/integration/repos_test.go | 18 +++++++++--------- test/integration/users_test.go | 6 +++--- tools/go.mod | 2 +- tools/metadata/main_test.go | 8 ++++---- 16 files changed, 37 insertions(+), 46 deletions(-) diff --git a/example/actionpermissions/main.go b/example/actionpermissions/main.go index aff4ad89da8..cfdf2fee2d4 100644 --- a/example/actionpermissions/main.go +++ b/example/actionpermissions/main.go @@ -47,7 +47,7 @@ func main() { fmt.Printf("Current ActionsPermissions %v\n", actionsPermissionsRepository) - actionsPermissionsRepository = &github.ActionsPermissionsRepository{Enabled: github.Ptr(true), AllowedActions: github.Ptr("selected")} + actionsPermissionsRepository = &github.ActionsPermissionsRepository{Enabled: new(true), AllowedActions: new("selected")} _, _, err = client.Repositories.UpdateActionsPermissions(ctx, *owner, *name, *actionsPermissionsRepository) if err != nil { log.Fatal(err) @@ -62,7 +62,7 @@ func main() { fmt.Printf("Current ActionsAllowed %v\n", actionsAllowed) - actionsAllowed = &github.ActionsAllowed{GithubOwnedAllowed: github.Ptr(true), VerifiedAllowed: github.Ptr(false), PatternsAllowed: []string{"a/b"}} + actionsAllowed = &github.ActionsAllowed{GithubOwnedAllowed: new(true), VerifiedAllowed: new(false), PatternsAllowed: []string{"a/b"}} _, _, err = client.Repositories.EditActionsAllowed(ctx, *owner, *name, *actionsAllowed) if err != nil { log.Fatal(err) @@ -70,7 +70,7 @@ func main() { fmt.Printf("Current ActionsAllowed %v\n", actionsAllowed) - actionsPermissionsRepository = &github.ActionsPermissionsRepository{Enabled: github.Ptr(true), AllowedActions: github.Ptr("all")} + actionsPermissionsRepository = &github.ActionsPermissionsRepository{Enabled: new(true), AllowedActions: new("all")} _, _, err = client.Repositories.UpdateActionsPermissions(ctx, *owner, *name, *actionsPermissionsRepository) if err != nil { log.Fatal(err) diff --git a/example/commitpr/main.go b/example/commitpr/main.go index ec4c980112e..667fb7d7b6b 100644 --- a/example/commitpr/main.go +++ b/example/commitpr/main.go @@ -105,7 +105,7 @@ func getTree(ref *github.Reference) (tree *github.Tree, err error) { if err != nil { return nil, err } - entries = append(entries, &github.TreeEntry{Path: &file, Type: github.Ptr("blob"), Content: github.Ptr(string(content)), Mode: github.Ptr("100644")}) + entries = append(entries, &github.TreeEntry{Path: &file, Type: new("blob"), Content: new(string(content)), Mode: new("100644")}) } tree, _, err = client.Git.CreateTree(ctx, *sourceOwner, *sourceRepo, *ref.Object.SHA, entries) @@ -173,7 +173,7 @@ func pushCommit(ref *github.Reference, tree *github.Tree) (err error) { ref.Object.SHA = newCommit.SHA _, _, err = client.Git.UpdateRef(ctx, *sourceOwner, *sourceRepo, *ref.Ref, github.UpdateRef{ SHA: *newCommit.SHA, - Force: github.Ptr(false), + Force: new(false), }) return err } @@ -200,7 +200,7 @@ func createPR() (err error) { HeadRepo: repoBranch, Base: *prBranch, Body: prDescription, - MaintainerCanModify: github.Ptr(true), + MaintainerCanModify: new(true), } pr, _, err := client.PullRequests.Create(ctx, *prRepoOwner, *prRepo, newPR) diff --git a/example/go.mod b/example/go.mod index ea9c2173a98..a46bbc67ef4 100644 --- a/example/go.mod +++ b/example/go.mod @@ -1,6 +1,6 @@ module github.com/google/go-github/v90/example -go 1.25.8 +go 1.26.0 require ( github.com/ProtonMail/go-crypto v1.4.1 diff --git a/example/newfilewithappauth/main.go b/example/newfilewithappauth/main.go index b18c2de888c..fb58a229993 100644 --- a/example/newfilewithappauth/main.go +++ b/example/newfilewithappauth/main.go @@ -75,7 +75,7 @@ func main() { "example/foo.txt", &github.RepositoryContentFileOptions{ Content: []byte("foo"), - Message: github.Ptr("sample commit"), + Message: new("sample commit"), SHA: nil, }, ) diff --git a/github/github.go b/github/github.go index 68ba6ee4de1..52adada5880 100644 --- a/github/github.go +++ b/github/github.go @@ -1262,8 +1262,7 @@ func (c *Client) bareDo(caller *http.Client, req *http.Request) (*Response, erro } // If the error type is *url.Error, sanitize its URL before returning. - var e *url.Error - if errors.As(err, &e) { + if e, ok := errors.AsType[*url.Error](err); ok { if url, err := url.Parse(e.URL); err == nil { e.URL = sanitizeURL(url).String() return response, e @@ -1290,8 +1289,7 @@ func (c *Client) bareDo(caller *http.Client, req *http.Request) (*Response, erro // added to the AcceptedError and returned. // // Issue #1022 - var aerr *AcceptedError - if errors.As(err, &aerr) { + if aerr, ok := errors.AsType[*AcceptedError](err); ok { b, readErr := io.ReadAll(io.LimitReader(resp.Body, maxErrorBodySize)) if readErr != nil { return response, readErr @@ -1352,8 +1350,7 @@ var errInvalidLocation = errors.New("invalid or empty Location header in redirec func (c *Client) bareDoUntilFound(req *http.Request, maxRedirects int) (*url.URL, *Response, error) { response, err := c.bareDoIgnoreRedirects(req) if err != nil { - var rerr *RedirectionError - if errors.As(err, &rerr) { + if rerr, ok := errors.AsType[*RedirectionError](err); ok { // If we receive a 302, transform potential relative locations into absolute and return it. if rerr.StatusCode == http.StatusFound { if rerr.Location == nil { diff --git a/github/issue_import.go b/github/issue_import.go index 9916eb6fa17..95e61d03d98 100644 --- a/github/issue_import.go +++ b/github/issue_import.go @@ -86,8 +86,7 @@ func (s *IssueImportService) Create(ctx context.Context, owner, repo string, bod var i *IssueImportResponse resp, err := s.client.Do(req, &i) if err != nil { - var aerr *AcceptedError - if errors.As(err, &aerr) { + if aerr, ok := errors.AsType[*AcceptedError](err); ok { if err := json.Unmarshal(aerr.Raw, &i); err != nil { return i, resp, err } diff --git a/github/orgs_outside_collaborators_test.go b/github/orgs_outside_collaborators_test.go index 7ffe1897c35..f1fb3689f64 100644 --- a/github/orgs_outside_collaborators_test.go +++ b/github/orgs_outside_collaborators_test.go @@ -104,8 +104,7 @@ func TestOrganizationsService_RemoveOutsideCollaborator_NonMember(t *testing.T) ctx := t.Context() _, err := client.Organizations.RemoveOutsideCollaborator(ctx, "o", "u") - var rerr *ErrorResponse - if !errors.As(err, &rerr) { + if rerr, ok := errors.AsType[*ErrorResponse](err); !ok { t.Error("Organizations.RemoveOutsideCollaborator did not return an error") } else if rerr.Response.StatusCode != http.StatusNotFound { t.Error("Organizations.RemoveOutsideCollaborator did not return 404 status code") @@ -124,8 +123,7 @@ func TestOrganizationsService_RemoveOutsideCollaborator_Member(t *testing.T) { ctx := t.Context() _, err := client.Organizations.RemoveOutsideCollaborator(ctx, "o", "u") - var rerr *ErrorResponse - if !errors.As(err, &rerr) { + if rerr, ok := errors.AsType[*ErrorResponse](err); !ok { t.Error("Organizations.RemoveOutsideCollaborator did not return an error") } else if rerr.Response.StatusCode != http.StatusUnprocessableEntity { t.Error("Organizations.RemoveOutsideCollaborator did not return 422 status code") @@ -170,8 +168,7 @@ func TestOrganizationsService_ConvertMemberToOutsideCollaborator_NonMemberOrLast ctx := t.Context() _, err := client.Organizations.ConvertMemberToOutsideCollaborator(ctx, "o", "u") - var rerr *ErrorResponse - if !errors.As(err, &rerr) { + if rerr, ok := errors.AsType[*ErrorResponse](err); !ok { t.Error("Organizations.ConvertMemberToOutsideCollaborator did not return an error") } else if rerr.Response.StatusCode != http.StatusForbidden { t.Error("Organizations.ConvertMemberToOutsideCollaborator did not return 403 status code") diff --git a/github/repos_forks.go b/github/repos_forks.go index b4f2e226417..7d80f0858a6 100644 --- a/github/repos_forks.go +++ b/github/repos_forks.go @@ -83,8 +83,7 @@ func (s *RepositoriesService) CreateFork(ctx context.Context, owner, repo string resp, err := s.client.Do(req, &fork) if err != nil { // Persist AcceptedError's metadata to the Repository object. - var aerr *AcceptedError - if errors.As(err, &aerr) { + if aerr, ok := errors.AsType[*AcceptedError](err); ok { if err := json.Unmarshal(aerr.Raw, &fork); err != nil { return fork, resp, err } diff --git a/github/security_advisories.go b/github/security_advisories.go index f705d1adc5e..0b48469bd03 100644 --- a/github/security_advisories.go +++ b/github/security_advisories.go @@ -171,8 +171,7 @@ func (s *SecurityAdvisoriesService) CreateTemporaryPrivateFork(ctx context.Conte var fork *Repository resp, err := s.client.Do(req, &fork) if err != nil { - var aerr *AcceptedError - if errors.As(err, &aerr) { + if aerr, ok := errors.AsType[*AcceptedError](err); ok { if err := json.Unmarshal(aerr.Raw, &fork); err != nil { return fork, resp, err } diff --git a/otel/go.mod b/otel/go.mod index 3dbd4297a24..97e21ec1785 100644 --- a/otel/go.mod +++ b/otel/go.mod @@ -1,6 +1,6 @@ module github.com/google/go-github/otel/v90 -go 1.25.0 +go 1.26.0 require ( github.com/google/go-github/v90 v90.0.0 diff --git a/test/integration/activity_test.go b/test/integration/activity_test.go index 8b8e09c12e1..a2b05da8011 100644 --- a/test/integration/activity_test.go +++ b/test/integration/activity_test.go @@ -90,7 +90,7 @@ func deleteSubscription(t *testing.T) { func createSubscription(t *testing.T) { // watch the target repository - sub := &github.Subscription{Subscribed: github.Ptr(true)} + sub := &github.Subscription{Subscribed: new(true)} _, _, err := client.Activity.SetRepositorySubscription(t.Context(), owner, repo, sub) if err != nil { t.Fatalf("Activity.SetRepositorySubscription returned error: %v", err) diff --git a/test/integration/licences_test.go b/test/integration/licences_test.go index 1e3822f15fb..dc4a6ec4292 100644 --- a/test/integration/licences_test.go +++ b/test/integration/licences_test.go @@ -15,7 +15,7 @@ import ( func TestLicenses_ListIter(t *testing.T) { opts := &github.ListLicensesOptions{ - Featured: github.Ptr(true), + Featured: new(true), ListOptions: github.ListOptions{ Page: 1, PerPage: 1, diff --git a/test/integration/repos_test.go b/test/integration/repos_test.go index eb8294c3b8a..6914461c20f 100644 --- a/test/integration/repos_test.go +++ b/test/integration/repos_test.go @@ -22,7 +22,7 @@ func TestRepositories_CRUD(t *testing.T) { repo := createRandomTestRepository(t, "", true) // update the repository description - repo.Description = github.Ptr("description") + repo.Description = new("description") repo.DefaultBranch = nil // FIXME: this shouldn't be necessary _, _, err := client.Repositories.Edit(t.Context(), *repo.Owner.Login, *repo.Name, repo) if err != nil { @@ -99,9 +99,9 @@ func TestRepositories_EditBranches(t *testing.T) { // In order to be able to test these Restrictions, need to add support // for creating temporary organization repositories. Restrictions: nil, - BlockCreations: github.Ptr(false), - LockBranch: github.Ptr(false), - AllowForkSyncing: github.Ptr(false), + BlockCreations: new(false), + LockBranch: new(false), + AllowForkSyncing: new(false), } protection, _, err := client.Repositories.UpdateBranchProtection(t.Context(), *repo.Owner.Login, *repo.Name, "master", protectionRequest) @@ -119,18 +119,18 @@ func TestRepositories_EditBranches(t *testing.T) { RequiredApprovingReviewCount: 0, }, EnforceAdmins: &github.AdminEnforcement{ - URL: github.Ptr("https://api.github.com/repos/" + *repo.Owner.Login + "/" + *repo.Name + "/branches/master/protection/enforce_admins"), + URL: new("https://api.github.com/repos/" + *repo.Owner.Login + "/" + *repo.Name + "/branches/master/protection/enforce_admins"), Enabled: true, }, Restrictions: nil, BlockCreations: &github.BlockCreations{ - Enabled: github.Ptr(false), + Enabled: new(false), }, LockBranch: &github.LockBranch{ - Enabled: github.Ptr(false), + Enabled: new(false), }, AllowForkSyncing: &github.AllowForkSyncing{ - Enabled: github.Ptr(false), + Enabled: new(false), }, } if !cmp.Equal(protection, want) { @@ -192,7 +192,7 @@ func TestRepositories_Autolinks(t *testing.T) { body := github.CreateAutolinkRequest{ KeyPrefix: "TICKET-", URLTemplate: "https://example.com/TICKET?query=", - IsAlphanumeric: github.Ptr(false), + IsAlphanumeric: new(false), } actionlink, _, err := client.Repositories.CreateAutolink(t.Context(), *repo.Owner.Login, *repo.Name, body) diff --git a/test/integration/users_test.go b/test/integration/users_test.go index f490f4ac1c1..22c70bf9d35 100644 --- a/test/integration/users_test.go +++ b/test/integration/users_test.go @@ -181,7 +181,7 @@ func TestUsers_Keys(t *testing.T) { // Add new key _, _, err = client.Users.CreateKey(t.Context(), &github.Key{ - Title: github.Ptr("go-github test key"), + Title: new("go-github test key"), Key: &key, }) if err != nil { @@ -209,10 +209,10 @@ func TestUsers_Keys(t *testing.T) { // Verify that fetching individual key works k, _, err := client.Users.GetKey(t.Context(), id) if err != nil { - t.Fatalf("Users.GetKey(%q) returned error: %v", id, err) + t.Fatalf("Users.GetKey(%d) returned error: %v", id, err) } if *k.Key != key { - t.Fatalf("Users.GetKey(%q) returned key %v, want %v", id, *k.Key, key) + t.Fatalf("Users.GetKey(%d) returned key %v, want %v", id, *k.Key, key) } // Remove test key diff --git a/tools/go.mod b/tools/go.mod index 2b2bd53605b..7996dee6540 100644 --- a/tools/go.mod +++ b/tools/go.mod @@ -1,6 +1,6 @@ module tools -go 1.25.0 +go 1.26.0 require ( github.com/alecthomas/kong v1.16.1 diff --git a/tools/metadata/main_test.go b/tools/metadata/main_test.go index 6f224e3dc6e..46848b200a1 100644 --- a/tools/metadata/main_test.go +++ b/tools/metadata/main_test.go @@ -360,18 +360,18 @@ func newTestServer(t *testing.T, ref string, files map[string]any) *httptest.Ser server := httptest.NewServer(mux) mux.HandleFunc( path.Join(repoPath, "commits", ref), - jsonHandler(emptyQuery, &github.RepositoryCommit{SHA: github.Ptr("s")}), + jsonHandler(emptyQuery, &github.RepositoryCommit{SHA: new("s")}), ) var descriptionsContent []*github.RepositoryContent for name, content := range files { descriptionsContent = append(descriptionsContent, &github.RepositoryContent{ - Name: github.Ptr(path.Base(path.Dir(name))), + Name: new(path.Base(path.Dir(name))), }) mux.HandleFunc( path.Join(repoPath, "contents/descriptions", name), jsonHandler(refQuery, &github.RepositoryContent{ - Name: github.Ptr(path.Base(name)), - DownloadURL: github.Ptr(server.URL + "/dl/" + name), + Name: new(path.Base(name)), + DownloadURL: new(server.URL + "/dl/" + name), }), ) mux.HandleFunc(