+
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions github/orgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,19 @@ func (s *OrganizationsService) Edit(ctx context.Context, name string, org *Organ
return o, resp, nil
}

// Delete an organization by name.
//
// GitHub API docs: https://docs.github.com/en/rest/orgs/orgs#delete-an-organization
func (s *OrganizationsService) Delete(ctx context.Context, org string) (*Response, error) {
u := fmt.Sprintf("orgs/%v", org)
req, err := s.client.NewRequest("DELETE", u, nil)
if err != nil {
return nil, err
}

return s.client.Do(ctx, req, nil)
}

// ListInstallations lists installations for an organization.
//
// GitHub API docs: https://docs.github.com/en/rest/orgs/orgs#list-app-installations-for-an-organization
Expand Down
25 changes: 25 additions & 0 deletions github/orgs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,31 @@ func TestOrganizationsService_Edit_invalidOrg(t *testing.T) {
testURLParseError(t, err)
}

func TestOrganizationsService_Delete(t *testing.T) {
client, mux, _, teardown := setup()
defer teardown()

mux.HandleFunc("/orgs/o", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "DELETE")
})

ctx := context.Background()
_, err := client.Organizations.Delete(ctx, "o")
if err != nil {
t.Errorf("Organizations.Delete returned error: %v", err)
}

const methodName = "Delete"
testBadOptions(t, methodName, func() (err error) {
_, err = client.Organizations.Delete(ctx, "\n")
return err
})

testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
return client.Organizations.Delete(ctx, "o")
})
}

func TestOrganizationsService_ListInstallations(t *testing.T) {
client, mux, _, teardown := setup()
defer teardown()
Expand Down
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载