Commit 109fd962 authored by James Ramsay's avatar James Ramsay Committed by Sander van Harmelen

Update ListPipelineJobs to return array of pointers (#364)

Most list functions return array of pointers, not values. Updated for
consistency.
parent 114e2ebc
......@@ -100,7 +100,7 @@ func (s *JobsService) ListProjectJobs(pid interface{}, opts *ListJobsOptions, op
//
// GitLab API docs:
// https://docs.gitlab.com/ce/api/jobs.html#list-pipeline-jobs
func (s *JobsService) ListPipelineJobs(pid interface{}, pipelineID int, opts *ListJobsOptions, options ...OptionFunc) ([]Job, *Response, error) {
func (s *JobsService) ListPipelineJobs(pid interface{}, pipelineID int, opts *ListJobsOptions, options ...OptionFunc) ([]*Job, *Response, error) {
project, err := parseID(pid)
if err != nil {
return nil, nil, err
......@@ -112,7 +112,7 @@ func (s *JobsService) ListPipelineJobs(pid interface{}, pipelineID int, opts *Li
return nil, nil, err
}
var jobs []Job
var jobs []*Job
resp, err := s.client.Do(req, &jobs)
if err != nil {
return nil, resp, err
......
package gitlab
import (
"fmt"
"net/http"
"reflect"
"testing"
)
func TestListPipelineJobs(t *testing.T) {
mux, server, client := setup()
defer teardown(server)
mux.HandleFunc("/projects/1/pipelines/1/jobs", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
fmt.Fprint(w, `[{"id":1},{"id":2}]`)
})
jobs, _, err := client.Jobs.ListPipelineJobs(1, 1, nil)
if err != nil {
t.Errorf("Jobs.ListPipelineJobs returned error: %v", err)
}
want := []*Job{{ID: 1}, {ID: 2}}
if !reflect.DeepEqual(want, jobs) {
t.Errorf("Jobs.ListPipelineJobs returned %+v, want %+v", jobs, want)
}
}
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