Commit d56ec0d0 authored by Sander van Harmelen's avatar Sander van Harmelen

Merge pull request #37 from MrArtichaut/master

Implements starred project listing
parents 7125de3e 1a337109
......@@ -141,6 +141,28 @@ func (s *ProjectsService) ListOwnedProjects(
return p, resp, err
}
// ListOwnedProjects gets a list of projects which are starred by the
// authenticated user.
//
// GitLab API docs:
// http://doc.gitlab.com/ce/api/projects.html#list-starred-projects
func (s *ProjectsService) ListStarredProjects(
opt *ListProjectsOptions) ([]*Project, *Response, error) {
req, err := s.client.NewRequest("GET", "projects/starred", opt)
if err != nil {
return nil, nil, err
}
var p []*Project
resp, err := s.client.Do(req, &p)
if err != nil {
return nil, resp, err
}
return p, resp, err
}
// ListAllProjects gets a list of all GitLab projects (admin only).
//
// GitLab API docs:
......
......@@ -69,6 +69,37 @@ func TestListOwnedProjects(t *testing.T) {
}
}
func TestListStarredProjects(t *testing.T) {
mux, server, client := setup()
defer teardown(server)
mux.HandleFunc("/projects/starred", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
testFormValues(t, r, values{
"page": "2",
"per_page": "3",
"archived": "true",
"order_by": "name",
"sort": "asc",
"search": "query",
"ci_enabled_first": "true",
})
fmt.Fprint(w, `[{"id":1},{"id":2}]`)
})
opt := &ListProjectsOptions{ListOptions{2, 3}, true, "name", "asc", "query", true}
projects, _, err := client.Projects.ListStarredProjects(opt)
if err != nil {
t.Errorf("Projects.ListStarredProjects returned error: %v", err)
}
want := []*Project{{ID: Int(1)},{ID: Int(2)}}
if !reflect.DeepEqual(want, projects) {
t.Errorf("Projects.ListStarredProjects returned %+v, want %+v", projects, want)
}
}
func TestListAllProjects(t *testing.T) {
mux, server, client := setup()
defer teardown(server)
......
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