Skip to content

Commit 1a69bbf

Browse files
committed
fix: update ToggleInstallationRepositories to return Installation instead of ListRepositories and adjust its test expectations.
1 parent da913d0 commit 1a69bbf

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

github/enterprise_apps.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ type EnterpriseInstallationRepositoriesToggleOptions struct {
2424
SelectedRepositoryIDs []int64 `json:"selected_repository_ids,omitempty"`
2525
}
2626

27-
28-
2927
// ListRepositoriesForOrgInstallation lists the repositories that an enterprise app installation
3028
// has access to on an organization.
3129
//
@@ -59,14 +57,14 @@ func (s *EnterpriseService) ListRepositoriesForOrgInstallation(ctx context.Conte
5957
// GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/enterprise-admin/organization-installations#toggle-installation-repository-access-between-selected-and-all-repositories
6058
//
6159
//meta:operation PATCH /enterprises/{enterprise}/apps/organizations/{org}/installations/{installation_id}/repositories
62-
func (s *EnterpriseService) ToggleInstallationRepositories(ctx context.Context, enterprise, org string, installationID int64, opts EnterpriseInstallationRepositoriesToggleOptions) (*ListRepositories, *Response, error) {
60+
func (s *EnterpriseService) ToggleInstallationRepositories(ctx context.Context, enterprise, org string, installationID int64, opts EnterpriseInstallationRepositoriesToggleOptions) (*Installation, *Response, error) {
6361
u := fmt.Sprintf("enterprises/%v/apps/organizations/%v/installations/%v/repositories", enterprise, org, installationID)
6462
req, err := s.client.NewRequest("PATCH", u, opts)
6563
if err != nil {
6664
return nil, nil, err
6765
}
6866

69-
var r *ListRepositories
67+
var r *Installation
7068
resp, err := s.client.Do(ctx, req, &r)
7169
if err != nil {
7270
return nil, resp, err

github/enterprise_apps_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,17 +58,17 @@ func TestEnterpriseService_ToggleInstallationRepositories(t *testing.T) {
5858
mux.HandleFunc("/enterprises/e/apps/organizations/o/installations/1/repositories", func(w http.ResponseWriter, r *http.Request) {
5959
testMethod(t, r, "PATCH")
6060
testBody(t, r, `{"repository_selection":"selected","selected_repository_ids":[1,2]}`+"\n")
61-
fmt.Fprint(w, `{"total_count":2, "repositories":[{"id":1},{"id":2}]}`)
61+
fmt.Fprint(w, `{"id":1, "repository_selection":"selected"}`)
6262
})
6363

6464
ctx := t.Context()
65-
repos, _, err := client.Enterprise.ToggleInstallationRepositories(ctx, "e", "o", 1, input)
65+
inst, _, err := client.Enterprise.ToggleInstallationRepositories(ctx, "e", "o", 1, input)
6666
if err != nil {
6767
t.Errorf("Enterprise.ToggleInstallationRepositories returned error: %v", err)
6868
}
6969

70-
want := &ListRepositories{TotalCount: Ptr(2), Repositories: []*Repository{{ID: Ptr(int64(1))}, {ID: Ptr(int64(2))}}}
71-
if diff := cmp.Diff(repos, want); diff != "" {
70+
want := &Installation{ID: Ptr(int64(1)), RepositorySelection: Ptr("selected")}
71+
if diff := cmp.Diff(inst, want); diff != "" {
7272
t.Errorf("Enterprise.ToggleInstallationRepositories returned diff (-want +got):\n%v", diff)
7373
}
7474

0 commit comments

Comments
 (0)