Commit 72694947 authored by Bryan Sazon's avatar Bryan Sazon Committed by Sander van Harmelen

ListGroupProjectOptions should be created as type ListProjectOptions (#408)

* Fixes https://github.com/xanzy/go-gitlab/issues/407
* Add the first groups unit test
parent 76a84455
...@@ -239,13 +239,13 @@ func (s *GroupsService) SearchGroup(query string, options ...OptionFunc) ([]*Gro ...@@ -239,13 +239,13 @@ func (s *GroupsService) SearchGroup(query string, options ...OptionFunc) ([]*Gro
// options. // options.
// //
// GitLab API docs: // GitLab API docs:
// https://docs.gitlab.com/ce/api/groups.html#list-a-group-s-projects // https://docs.gitlab.com/ce/api/groups.html#list-a-group-39-s-projects
type ListGroupProjectsOptions ListOptions type ListGroupProjectsOptions ListProjectsOptions
// ListGroupProjects get a list of group projects // ListGroupProjects get a list of group projects
// //
// GitLab API docs: // GitLab API docs:
// https://docs.gitlab.com/ce/api/groups.html#list-a-group-s-projects // https://docs.gitlab.com/ce/api/groups.html#list-a-group-39-s-projects
func (s *GroupsService) ListGroupProjects(gid interface{}, opt *ListGroupProjectsOptions, options ...OptionFunc) ([]*Project, *Response, error) { func (s *GroupsService) ListGroupProjects(gid interface{}, opt *ListGroupProjectsOptions, options ...OptionFunc) ([]*Project, *Response, error) {
group, err := parseID(gid) group, err := parseID(gid)
if err != nil { if err != nil {
......
package gitlab
import (
"fmt"
"net/http"
"reflect"
"testing"
)
func TestListGroupProjects(t *testing.T) {
mux, server, client := setup()
defer teardown(server)
mux.HandleFunc("/api/v4/groups/22/projects",
func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
fmt.Fprint(w, `[{"id":1},{"id":2}]`)
})
opt := &ListGroupProjectsOptions{
ListOptions: ListOptions{2, 3},
Archived: Bool(true),
OrderBy: String("name"),
Sort: String("asc"),
Search: String("query"),
Simple: Bool(true),
Visibility: Visibility(PublicVisibility),
}
projects, _, err := client.Groups.ListGroupProjects(22, opt)
if err != nil {
t.Errorf("Groups.ListGroupProjects returned error: %v", err)
}
want := []*Project{{ID: 1}, {ID: 2}}
if !reflect.DeepEqual(want, projects) {
t.Errorf("Groups.ListGroupProjects returned %+v, want %+v", projects, 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