Commit 08a83fa5 authored by aha's avatar aha

Adding DeletePipeline API call and test

parent eca1beae
......@@ -229,3 +229,23 @@ func (s *PipelinesService) CancelPipelineBuild(pid interface{}, pipelineID int,
return p, resp, err
}
// DeletePipeline deletes an existing pipeline.
//
// GitLab API docs:
// https://docs.gitlab.com/ce/api/pipelines.html#delete-a-pipeline
func (s *PipelinesService) DeletePipeline(pid interface{}, pipelineID int, options ...OptionFunc) (*Response, error) {
project, err := parseID(pid)
if err != nil {
return nil, err
}
u := fmt.Sprintf("projects/%s/pipelines/%d", url.QueryEscape(project), pipelineID)
req, err := s.client.NewRequest("DELETE", u, nil, options)
if err != nil {
return nil, err
}
return s.client.Do(req, nil)
}
......@@ -109,3 +109,19 @@ func TestCancelPipelineBuild(t *testing.T) {
t.Errorf("Pipelines.CancelPipelineBuild returned %+v, want %+v", pipeline, want)
}
}
func TestDeletePipeline(t *testing.T) {
mux, server, client := setup()
defer teardown(server)
mux.HandleFunc("/api/v4/projects/1/pipelines/5949167", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "DELETE")
})
_, err := client.Pipelines.DeletePipeline("1", 5949167)
if err != nil {
t.Errorf("Pipelines.DeletePipeline returned error: %v", err)
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment