Skip to content

Commit

Permalink
Add DeleteDeployment for Repositories
Browse files Browse the repository at this point in the history
  • Loading branch information
Pablo Perez Schroder committed Jun 9, 2020
1 parent dbeb049 commit 78dfc53
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
12 changes: 12 additions & 0 deletions github/repos_deployments.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,18 @@ func (s *RepositoriesService) CreateDeployment(ctx context.Context, owner, repo
return d, resp, nil
}

// DeleteDeployment deletes an existing deployment for a repository.
//
// GitHub API docs: https://developer.github.com/v3/repos/deployments/#delete-a-deployment
func (s *RepositoriesService) DeleteDeployment(ctx context.Context, owner, repo string, deploymentID int64) (*Response, error) {
u := fmt.Sprintf("repos/%v/%v/deployments/%v", owner, repo, deploymentID)
req, err := s.client.NewRequest("DELETE", u, nil)
if err != nil {
return nil, err
}
return s.client.Do(ctx, req, nil)
}

// DeploymentStatus represents the status of a
// particular deployment.
type DeploymentStatus struct {
Expand Down
14 changes: 14 additions & 0 deletions github/repos_deployments_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,20 @@ func TestRepositoriesService_CreateDeployment(t *testing.T) {
}
}

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

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

_, err := client.Repositories.DeleteDeployment(context.Background(), "o", "r", 1)
if err != nil {
t.Errorf("Repositories.DeleteDeployment returned error: %v", err)
}
}

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

0 comments on commit 78dfc53

Please sign in to comment.