diff --git a/.golangci.yml b/.golangci.yml index bde31c4bc7a..6108f59edd9 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -237,9 +237,6 @@ linters: - SCIMUserAttributes - SourceImportAuthor - Subscription - - TeamAddTeamMembershipOptions - - TeamAddTeamRepoOptions - - TeamProjectOptions - UpdateDefaultSetupConfigurationOptions - UpdateProjectItemOptions - UserSuspendOptions @@ -261,9 +258,6 @@ linters: - RepositoryAddCollaboratorOptions - RepositoryContentFileOptions - RepositoryCreateForkOptions - - TeamAddTeamMembershipOptions - - TeamAddTeamRepoOptions - - TeamProjectOptions - UpdateCheckRunOptions - UpdateDefaultSetupConfigurationOptions - UpdateProjectItemOptions @@ -444,8 +438,6 @@ linters: - SearchOptions.AdvancedSearch - Secret.SelectedRepositoriesURL # TODO: Actions - Secret.Visibility # TODO: Actions - - TeamAddTeamMembershipOptions.Role # TODO: Teams - - TeamAddTeamRepoOptions.Permission # TODO: Teams - UpdateRuleParameters.UpdateAllowsFetchAndMerge # TODO: Rules - UsageReportOptions.Day - UsageReportOptions.Hour diff --git a/github/github-accessors.go b/github/github-accessors.go index d97a20b0522..77b36e28ddf 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -734,6 +734,30 @@ func (a *AddResourcesToCostCenterResponse) GetReassignedResources() []*Reassigne return a.ReassignedResources } +// GetRole returns the Role field if it's non-nil, zero value otherwise. +func (a *AddTeamMembershipRequest) GetRole() string { + if a == nil || a.Role == nil { + return "" + } + return *a.Role +} + +// GetPermission returns the Permission field if it's non-nil, zero value otherwise. +func (a *AddTeamProjectRequest) GetPermission() string { + if a == nil || a.Permission == nil { + return "" + } + return *a.Permission +} + +// GetPermission returns the Permission field if it's non-nil, zero value otherwise. +func (a *AddTeamRepoRequest) GetPermission() string { + if a == nil || a.Permission == nil { + return "" + } + return *a.Permission +} + // GetFrom returns the From field if it's non-nil, zero value otherwise. func (a *AdminEnforcedChanges) GetFrom() bool { if a == nil || a.From == nil { @@ -44294,22 +44318,6 @@ func (t *TeamAddEvent) GetTeam() *Team { return t.Team } -// GetRole returns the Role field. -func (t *TeamAddTeamMembershipOptions) GetRole() string { - if t == nil { - return "" - } - return t.Role -} - -// GetPermission returns the Permission field. -func (t *TeamAddTeamRepoOptions) GetPermission() string { - if t == nil { - return "" - } - return t.Permission -} - // GetDescription returns the Description field. func (t *TeamChange) GetDescription() *TeamDescription { if t == nil { @@ -44686,14 +44694,6 @@ func (t *TeamPrivacy) GetFrom() string { return *t.From } -// GetPermission returns the Permission field if it's non-nil, zero value otherwise. -func (t *TeamProjectOptions) GetPermission() string { - if t == nil || t.Permission == nil { - return "" - } - return *t.Permission -} - // GetPermissions returns the Permissions field. func (t *TeamRepository) GetPermissions() *TeamPermissions { if t == nil { diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go index 252e5fae46f..1a290aea831 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -921,6 +921,39 @@ func TestAddResourcesToCostCenterResponse_GetReassignedResources(tt *testing.T) a.GetReassignedResources() } +func TestAddTeamMembershipRequest_GetRole(tt *testing.T) { + tt.Parallel() + var zeroValue string + a := &AddTeamMembershipRequest{Role: &zeroValue} + a.GetRole() + a = &AddTeamMembershipRequest{} + a.GetRole() + a = nil + a.GetRole() +} + +func TestAddTeamProjectRequest_GetPermission(tt *testing.T) { + tt.Parallel() + var zeroValue string + a := &AddTeamProjectRequest{Permission: &zeroValue} + a.GetPermission() + a = &AddTeamProjectRequest{} + a.GetPermission() + a = nil + a.GetPermission() +} + +func TestAddTeamRepoRequest_GetPermission(tt *testing.T) { + tt.Parallel() + var zeroValue string + a := &AddTeamRepoRequest{Permission: &zeroValue} + a.GetPermission() + a = &AddTeamRepoRequest{} + a.GetPermission() + a = nil + a.GetPermission() +} + func TestAdminEnforcedChanges_GetFrom(tt *testing.T) { tt.Parallel() var zeroValue bool @@ -55191,22 +55224,6 @@ func TestTeamAddEvent_GetTeam(tt *testing.T) { t.GetTeam() } -func TestTeamAddTeamMembershipOptions_GetRole(tt *testing.T) { - tt.Parallel() - t := &TeamAddTeamMembershipOptions{} - t.GetRole() - t = nil - t.GetRole() -} - -func TestTeamAddTeamRepoOptions_GetPermission(tt *testing.T) { - tt.Parallel() - t := &TeamAddTeamRepoOptions{} - t.GetPermission() - t = nil - t.GetPermission() -} - func TestTeamChange_GetDescription(tt *testing.T) { tt.Parallel() t := &TeamChange{} @@ -55682,17 +55699,6 @@ func TestTeamPrivacy_GetFrom(tt *testing.T) { t.GetFrom() } -func TestTeamProjectOptions_GetPermission(tt *testing.T) { - tt.Parallel() - var zeroValue string - t := &TeamProjectOptions{Permission: &zeroValue} - t.GetPermission() - t = &TeamProjectOptions{} - t.GetPermission() - t = nil - t.GetPermission() -} - func TestTeamRepository_GetPermissions(tt *testing.T) { tt.Parallel() t := &TeamRepository{} diff --git a/github/teams.go b/github/teams.go index 9856b615a29..fe88b8888f9 100644 --- a/github/teams.go +++ b/github/teams.go @@ -516,9 +516,8 @@ func (s *TeamsService) IsTeamRepoBySlug(ctx context.Context, org, slug, owner, r return repository, resp, nil } -// TeamAddTeamRepoOptions specifies the optional parameters to the -// TeamsService.AddTeamRepoByID and TeamsService.AddTeamRepoBySlug methods. -type TeamAddTeamRepoOptions struct { +// AddTeamRepoRequest represents a request to add or update a team's permissions on a repository. +type AddTeamRepoRequest struct { // Permission specifies the permission to grant the team on this repository. // Possible values are: // pull - team members can pull, but not push to or administer this repository @@ -528,7 +527,7 @@ type TeamAddTeamRepoOptions struct { // triage - team members can proactively manage issues and pull requests without write access. // // If not specified, the team's permission attribute will be used. - Permission string `json:"permission,omitempty"` + Permission *string `json:"permission,omitempty"` } // AddTeamRepoByID adds a repository to be managed by the specified team given the team ID. @@ -538,7 +537,7 @@ type TeamAddTeamRepoOptions struct { // GitHub API docs: https://docs.github.com/rest/teams/teams?apiVersion=2022-11-28#add-or-update-team-repository-permissions // //meta:operation PUT /organizations/{organization_id}/team/{team_id}/repos/{owner}/{repo} -func (s *TeamsService) AddTeamRepoByID(ctx context.Context, orgID, teamID int64, owner, repo string, body *TeamAddTeamRepoOptions) (*Response, error) { +func (s *TeamsService) AddTeamRepoByID(ctx context.Context, orgID, teamID int64, owner, repo string, body AddTeamRepoRequest) (*Response, error) { u := fmt.Sprintf("organizations/%v/team/%v/repos/%v/%v", orgID, teamID, owner, repo) req, err := s.client.NewRequest(ctx, "PUT", u, body) if err != nil { @@ -555,7 +554,7 @@ func (s *TeamsService) AddTeamRepoByID(ctx context.Context, orgID, teamID int64, // GitHub API docs: https://docs.github.com/rest/teams/teams?apiVersion=2022-11-28#add-or-update-team-repository-permissions // //meta:operation PUT /orgs/{org}/teams/{team_slug}/repos/{owner}/{repo} -func (s *TeamsService) AddTeamRepoBySlug(ctx context.Context, org, slug, owner, repo string, body *TeamAddTeamRepoOptions) (*Response, error) { +func (s *TeamsService) AddTeamRepoBySlug(ctx context.Context, org, slug, owner, repo string, body AddTeamRepoRequest) (*Response, error) { u := fmt.Sprintf("orgs/%v/teams/%v/repos/%v/%v", org, slug, owner, repo) req, err := s.client.NewRequest(ctx, "PUT", u, body) if err != nil { @@ -729,9 +728,8 @@ func (s *TeamsService) ReviewTeamProjectsBySlug(ctx context.Context, org, slug s return projects, resp, nil } -// TeamProjectOptions specifies the optional parameters to the -// TeamsService.AddTeamProject method. -type TeamProjectOptions struct { +// AddTeamProjectRequest represents a request to add or update a team's permissions on a project. +type AddTeamProjectRequest struct { // Permission specifies the permission to grant to the team for this project. // Possible values are: // "read" - team members can read, but not write to or administer this project. @@ -750,7 +748,7 @@ type TeamProjectOptions struct { // GitHub API docs: https://docs.github.com/enterprise-server@3.16/rest/teams/teams#add-or-update-team-project-permissions // //meta:operation PUT /organizations/{organization_id}/team/{team_id}/projects/{project_id} -func (s *TeamsService) AddTeamProjectByID(ctx context.Context, orgID, teamID, projectID int64, body *TeamProjectOptions) (*Response, error) { +func (s *TeamsService) AddTeamProjectByID(ctx context.Context, orgID, teamID, projectID int64, body AddTeamProjectRequest) (*Response, error) { u := fmt.Sprintf("organizations/%v/team/%v/projects/%v", orgID, teamID, projectID) req, err := s.client.NewRequest(ctx, "PUT", u, body) if err != nil { @@ -771,7 +769,7 @@ func (s *TeamsService) AddTeamProjectByID(ctx context.Context, orgID, teamID, pr // GitHub API docs: https://docs.github.com/enterprise-server@3.16/rest/teams/teams#add-or-update-team-project-permissions // //meta:operation PUT /orgs/{org}/teams/{team_slug}/projects/{project_id} -func (s *TeamsService) AddTeamProjectBySlug(ctx context.Context, org, slug string, projectID int64, body *TeamProjectOptions) (*Response, error) { +func (s *TeamsService) AddTeamProjectBySlug(ctx context.Context, org, slug string, projectID int64, body AddTeamProjectRequest) (*Response, error) { u := fmt.Sprintf("orgs/%v/teams/%v/projects/%v", org, slug, projectID) req, err := s.client.NewRequest(ctx, "PUT", u, body) if err != nil { diff --git a/github/teams_members.go b/github/teams_members.go index 184ab06bbcb..75bbba0db4f 100644 --- a/github/teams_members.go +++ b/github/teams_members.go @@ -118,9 +118,8 @@ func (s *TeamsService) GetTeamMembershipBySlug(ctx context.Context, org, slug, u return t, resp, nil } -// TeamAddTeamMembershipOptions specifies the optional -// parameters to the TeamsService.AddTeamMembership method. -type TeamAddTeamMembershipOptions struct { +// AddTeamMembershipRequest represents a request to add or update a user's membership in a team. +type AddTeamMembershipRequest struct { // Role specifies the role the user should have in the team. Possible // values are: // member - a normal member of the team @@ -129,7 +128,7 @@ type TeamAddTeamMembershipOptions struct { // maintainer, and edit the team’s name and description // // Default value is "member". - Role string `json:"role,omitempty"` + Role *string `json:"role,omitempty"` } // AddTeamMembershipByID adds or invites a user to a team, given a specified @@ -138,7 +137,7 @@ type TeamAddTeamMembershipOptions struct { // GitHub API docs: https://docs.github.com/rest/teams/members?apiVersion=2022-11-28#add-or-update-team-membership-for-a-user // //meta:operation PUT /organizations/{organization_id}/team/{team_id}/memberships/{username} -func (s *TeamsService) AddTeamMembershipByID(ctx context.Context, orgID, teamID int64, user string, body *TeamAddTeamMembershipOptions) (*Membership, *Response, error) { +func (s *TeamsService) AddTeamMembershipByID(ctx context.Context, orgID, teamID int64, user string, body AddTeamMembershipRequest) (*Membership, *Response, error) { u := fmt.Sprintf("organizations/%v/team/%v/memberships/%v", orgID, teamID, user) req, err := s.client.NewRequest(ctx, "PUT", u, body) if err != nil { @@ -160,7 +159,7 @@ func (s *TeamsService) AddTeamMembershipByID(ctx context.Context, orgID, teamID // GitHub API docs: https://docs.github.com/rest/teams/members?apiVersion=2022-11-28#add-or-update-team-membership-for-a-user // //meta:operation PUT /orgs/{org}/teams/{team_slug}/memberships/{username} -func (s *TeamsService) AddTeamMembershipBySlug(ctx context.Context, org, slug, user string, body *TeamAddTeamMembershipOptions) (*Membership, *Response, error) { +func (s *TeamsService) AddTeamMembershipBySlug(ctx context.Context, org, slug, user string, body AddTeamMembershipRequest) (*Membership, *Response, error) { u := fmt.Sprintf("orgs/%v/teams/%v/memberships/%v", org, slug, user) req, err := s.client.NewRequest(ctx, "PUT", u, body) if err != nil { diff --git a/github/teams_members_test.go b/github/teams_members_test.go index 1bae792cbab..240fb6c176f 100644 --- a/github/teams_members_test.go +++ b/github/teams_members_test.go @@ -327,16 +327,16 @@ func TestTeamsService_AddTeamMembershipByID(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - opt := &TeamAddTeamMembershipOptions{Role: "maintainer"} + input := AddTeamMembershipRequest{Role: new("maintainer")} mux.HandleFunc("/organizations/1/team/2/memberships/u", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "PUT") - testJSONBody(t, r, opt) + testJSONBody(t, r, input) fmt.Fprint(w, `{"url":"u", "state":"pending"}`) }) ctx := t.Context() - membership, _, err := client.Teams.AddTeamMembershipByID(ctx, 1, 2, "u", opt) + membership, _, err := client.Teams.AddTeamMembershipByID(ctx, 1, 2, "u", input) if err != nil { t.Errorf("Teams.AddTeamMembershipByID returned error: %v", err) } @@ -348,12 +348,12 @@ func TestTeamsService_AddTeamMembershipByID(t *testing.T) { const methodName = "AddTeamMembershipByID" testBadOptions(t, methodName, func() (err error) { - _, _, err = client.Teams.AddTeamMembershipByID(ctx, -1, -2, "\n", opt) + _, _, err = client.Teams.AddTeamMembershipByID(ctx, -1, -2, "\n", input) return err }) testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { - got, resp, err := client.Teams.AddTeamMembershipByID(ctx, 1, 2, "u", opt) + got, resp, err := client.Teams.AddTeamMembershipByID(ctx, 1, 2, "u", input) if got != nil { t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got) } @@ -365,16 +365,16 @@ func TestTeamsService_AddTeamMembershipByID_notFound(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - opt := &TeamAddTeamMembershipOptions{Role: "maintainer"} + input := AddTeamMembershipRequest{Role: new("maintainer")} mux.HandleFunc("/organizations/1/team/2/memberships/u", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "PUT") - testJSONBody(t, r, opt) + testJSONBody(t, r, input) w.WriteHeader(http.StatusNotFound) }) ctx := t.Context() - membership, resp, err := client.Teams.AddTeamMembershipByID(ctx, 1, 2, "u", opt) + membership, resp, err := client.Teams.AddTeamMembershipByID(ctx, 1, 2, "u", input) if err == nil { t.Error("Expected HTTP 404 response") } @@ -387,12 +387,12 @@ func TestTeamsService_AddTeamMembershipByID_notFound(t *testing.T) { const methodName = "AddTeamMembershipByID" testBadOptions(t, methodName, func() (err error) { - _, _, err = client.Teams.AddTeamMembershipByID(ctx, 1, 2, "u", opt) + _, _, err = client.Teams.AddTeamMembershipByID(ctx, 1, 2, "u", input) return err }) testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { - got, resp, err := client.Teams.AddTeamMembershipByID(ctx, 1, 2, "u", opt) + got, resp, err := client.Teams.AddTeamMembershipByID(ctx, 1, 2, "u", input) if got != nil { t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got) } @@ -404,16 +404,16 @@ func TestTeamsService_AddTeamMembershipBySlug(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - opt := &TeamAddTeamMembershipOptions{Role: "maintainer"} + input := AddTeamMembershipRequest{Role: new("maintainer")} mux.HandleFunc("/orgs/o/teams/s/memberships/u", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "PUT") - testJSONBody(t, r, opt) + testJSONBody(t, r, input) fmt.Fprint(w, `{"url":"u", "state":"pending"}`) }) ctx := t.Context() - membership, _, err := client.Teams.AddTeamMembershipBySlug(ctx, "o", "s", "u", opt) + membership, _, err := client.Teams.AddTeamMembershipBySlug(ctx, "o", "s", "u", input) if err != nil { t.Errorf("Teams.AddTeamMembershipBySlug returned error: %v", err) } @@ -425,12 +425,12 @@ func TestTeamsService_AddTeamMembershipBySlug(t *testing.T) { const methodName = "AddTeamMembershipBySlug" testBadOptions(t, methodName, func() (err error) { - _, _, err = client.Teams.AddTeamMembershipBySlug(ctx, "\n", "\n", "\n", opt) + _, _, err = client.Teams.AddTeamMembershipBySlug(ctx, "\n", "\n", "\n", input) return err }) testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { - got, resp, err := client.Teams.AddTeamMembershipBySlug(ctx, "o", "s", "u", opt) + got, resp, err := client.Teams.AddTeamMembershipBySlug(ctx, "o", "s", "u", input) if got != nil { t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got) } @@ -442,16 +442,16 @@ func TestTeamsService_AddTeamMembershipBySlug_notFound(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - opt := &TeamAddTeamMembershipOptions{Role: "maintainer"} + input := AddTeamMembershipRequest{Role: new("maintainer")} mux.HandleFunc("/orgs/o/teams/s/memberships/u", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "PUT") - testJSONBody(t, r, opt) + testJSONBody(t, r, input) w.WriteHeader(http.StatusNotFound) }) ctx := t.Context() - membership, resp, err := client.Teams.AddTeamMembershipBySlug(ctx, "o", "s", "u", opt) + membership, resp, err := client.Teams.AddTeamMembershipBySlug(ctx, "o", "s", "u", input) if err == nil { t.Error("Expected HTTP 404 response") } @@ -464,12 +464,12 @@ func TestTeamsService_AddTeamMembershipBySlug_notFound(t *testing.T) { const methodName = "AddTeamMembershipBySlug" testBadOptions(t, methodName, func() (err error) { - _, _, err = client.Teams.AddTeamMembershipBySlug(ctx, "o", "s", "u", opt) + _, _, err = client.Teams.AddTeamMembershipBySlug(ctx, "o", "s", "u", input) return err }) testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { - got, resp, err := client.Teams.AddTeamMembershipBySlug(ctx, "o", "s", "u", opt) + got, resp, err := client.Teams.AddTeamMembershipBySlug(ctx, "o", "s", "u", input) if got != nil { t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got) } @@ -482,7 +482,7 @@ func TestTeamsService_AddTeamMembershipBySlug_invalidOrg(t *testing.T) { client, _, _ := setup(t) ctx := t.Context() - _, _, err := client.Teams.AddTeamMembershipBySlug(ctx, "%", "s", "u", nil) + _, _, err := client.Teams.AddTeamMembershipBySlug(ctx, "%", "s", "u", AddTeamMembershipRequest{}) testURLParseError(t, err) } diff --git a/github/teams_test.go b/github/teams_test.go index 066663c7221..7067070d142 100644 --- a/github/teams_test.go +++ b/github/teams_test.go @@ -737,28 +737,28 @@ func TestTeamsService_AddTeamRepoByID(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - opt := &TeamAddTeamRepoOptions{Permission: "admin"} + input := AddTeamRepoRequest{Permission: new("admin")} mux.HandleFunc("/organizations/1/team/1/repos/owner/repo", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "PUT") - testJSONBody(t, r, opt) + testJSONBody(t, r, input) w.WriteHeader(http.StatusNoContent) }) ctx := t.Context() - _, err := client.Teams.AddTeamRepoByID(ctx, 1, 1, "owner", "repo", opt) + _, err := client.Teams.AddTeamRepoByID(ctx, 1, 1, "owner", "repo", input) if err != nil { t.Errorf("Teams.AddTeamRepoByID returned error: %v", err) } const methodName = "AddTeamRepoByID" testBadOptions(t, methodName, func() (err error) { - _, err = client.Teams.AddTeamRepoByID(ctx, 1, 1, "\n", "\n", opt) + _, err = client.Teams.AddTeamRepoByID(ctx, 1, 1, "\n", "\n", input) return err }) testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { - return client.Teams.AddTeamRepoByID(ctx, 1, 1, "owner", "repo", opt) + return client.Teams.AddTeamRepoByID(ctx, 1, 1, "owner", "repo", input) }) } @@ -766,28 +766,28 @@ func TestTeamsService_AddTeamRepoBySlug(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - opt := &TeamAddTeamRepoOptions{Permission: "admin"} + input := AddTeamRepoRequest{Permission: new("admin")} mux.HandleFunc("/orgs/org/teams/slug/repos/owner/repo", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "PUT") - testJSONBody(t, r, opt) + testJSONBody(t, r, input) w.WriteHeader(http.StatusNoContent) }) ctx := t.Context() - _, err := client.Teams.AddTeamRepoBySlug(ctx, "org", "slug", "owner", "repo", opt) + _, err := client.Teams.AddTeamRepoBySlug(ctx, "org", "slug", "owner", "repo", input) if err != nil { t.Errorf("Teams.AddTeamRepoBySlug returned error: %v", err) } const methodName = "AddTeamRepoBySlug" testBadOptions(t, methodName, func() (err error) { - _, err = client.Teams.AddTeamRepoBySlug(ctx, "\n", "\n", "\n", "\n", opt) + _, err = client.Teams.AddTeamRepoBySlug(ctx, "\n", "\n", "\n", "\n", input) return err }) testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { - return client.Teams.AddTeamRepoBySlug(ctx, "org", "slug", "owner", "repo", opt) + return client.Teams.AddTeamRepoBySlug(ctx, "org", "slug", "owner", "repo", input) }) } @@ -801,7 +801,7 @@ func TestTeamsService_AddTeamRepoByID_noAccess(t *testing.T) { }) ctx := t.Context() - _, err := client.Teams.AddTeamRepoByID(ctx, 1, 1, "owner", "repo", nil) + _, err := client.Teams.AddTeamRepoByID(ctx, 1, 1, "owner", "repo", AddTeamRepoRequest{}) if err == nil { t.Error("Expected error to be returned") } @@ -817,7 +817,7 @@ func TestTeamsService_AddTeamRepoBySlug_noAccess(t *testing.T) { }) ctx := t.Context() - _, err := client.Teams.AddTeamRepoBySlug(ctx, "org", "slug", "owner", "repo", nil) + _, err := client.Teams.AddTeamRepoBySlug(ctx, "org", "slug", "owner", "repo", AddTeamRepoRequest{}) if err == nil { t.Error("Expected error to be returned") } @@ -828,7 +828,7 @@ func TestTeamsService_AddTeamRepoByID_invalidOwner(t *testing.T) { client, _, _ := setup(t) ctx := t.Context() - _, err := client.Teams.AddTeamRepoByID(ctx, 1, 1, "%", "r", nil) + _, err := client.Teams.AddTeamRepoByID(ctx, 1, 1, "%", "r", AddTeamRepoRequest{}) testURLParseError(t, err) } @@ -837,7 +837,7 @@ func TestTeamsService_AddTeamRepoBySlug_invalidOwner(t *testing.T) { client, _, _ := setup(t) ctx := t.Context() - _, err := client.Teams.AddTeamRepoBySlug(ctx, "o", "s", "%", "r", nil) + _, err := client.Teams.AddTeamRepoBySlug(ctx, "o", "s", "%", "r", AddTeamRepoRequest{}) testURLParseError(t, err) } @@ -1091,31 +1091,31 @@ func TestTeamsService_AddTeamProjectByID(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - opt := &TeamProjectOptions{ + input := AddTeamProjectRequest{ Permission: new("admin"), } mux.HandleFunc("/organizations/1/team/1/projects/1", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "PUT") testHeader(t, r, "Accept", mediaTypeProjectsPreview) - testJSONBody(t, r, opt) + testJSONBody(t, r, input) w.WriteHeader(http.StatusNoContent) }) ctx := t.Context() - _, err := client.Teams.AddTeamProjectByID(ctx, 1, 1, 1, opt) + _, err := client.Teams.AddTeamProjectByID(ctx, 1, 1, 1, input) if err != nil { t.Errorf("Teams.AddTeamProjectByID returned error: %v", err) } const methodName = "AddTeamProjectByID" testBadOptions(t, methodName, func() (err error) { - _, err = client.Teams.AddTeamProjectByID(ctx, -1, -1, -1, opt) + _, err = client.Teams.AddTeamProjectByID(ctx, -1, -1, -1, input) return err }) testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { - return client.Teams.AddTeamProjectByID(ctx, 1, 1, 1, opt) + return client.Teams.AddTeamProjectByID(ctx, 1, 1, 1, input) }) } @@ -1123,31 +1123,31 @@ func TestTeamsService_AddTeamProjectBySlug(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - opt := &TeamProjectOptions{ + input := AddTeamProjectRequest{ Permission: new("admin"), } mux.HandleFunc("/orgs/o/teams/s/projects/1", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "PUT") testHeader(t, r, "Accept", mediaTypeProjectsPreview) - testJSONBody(t, r, opt) + testJSONBody(t, r, input) w.WriteHeader(http.StatusNoContent) }) ctx := t.Context() - _, err := client.Teams.AddTeamProjectBySlug(ctx, "o", "s", 1, opt) + _, err := client.Teams.AddTeamProjectBySlug(ctx, "o", "s", 1, input) if err != nil { t.Errorf("Teams.AddTeamProjectBySlug returned error: %v", err) } const methodName = "AddTeamProjectBySlug" testBadOptions(t, methodName, func() (err error) { - _, err = client.Teams.AddTeamProjectBySlug(ctx, "\n", "\n", -1, opt) + _, err = client.Teams.AddTeamProjectBySlug(ctx, "\n", "\n", -1, input) return err }) testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { - return client.Teams.AddTeamProjectBySlug(ctx, "o", "s", 1, opt) + return client.Teams.AddTeamProjectBySlug(ctx, "o", "s", 1, input) }) }