Commit 3c94cb66 authored by jorcau's avatar jorcau Committed by Sander van Harmelen

Add unshare project from group (#382)

* Add unshare project from group support

* Add tests for share and unshare projects from group

* Change reference to CE doc instead of EE

* Rename UnshareProjectFromGroup to DeleteSharedProjectFromGroup
parent 26124831
......@@ -646,6 +646,24 @@ func (s *ProjectsService) ShareProjectWithGroup(pid interface{}, opt *ShareWithG
return s.client.Do(req, nil)
}
// DeleteSharedProjectFromGroup allows to unshare a project from a group.
//
// GitLab API docs: https://docs.gitlab.com/ce/api/projects.html#delete-a-shared-project-link-within-a-group
func (s *ProjectsService) DeleteSharedProjectFromGroup(pid interface{}, groupID int, options ...OptionFunc) (*Response, error) {
project, err := parseID(pid)
if err != nil {
return nil, err
}
u := fmt.Sprintf("projects/%s/share/%d", url.QueryEscape(project), groupID)
req, err := s.client.NewRequest("DELETE", u, nil, options)
if err != nil {
return nil, err
}
return s.client.Do(req, nil)
}
// ProjectMember represents a project member.
//
// GitLab API docs:
......
......@@ -318,3 +318,36 @@ func TestListProjectForks(t *testing.T) {
t.Errorf("Projects.ListProjects returned %+v, want %+v", projects, want)
}
}
func TestShareProjectWithGroup(t *testing.T) {
mux, server, client := setup()
defer teardown(server)
mux.HandleFunc("/projects/1/share", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "POST")
})
opt := &ShareWithGroupOptions{
GroupID: Int(1),
GroupAccess: AccessLevel(AccessLevelValue(50)),
}
_, err := client.Projects.ShareProjectWithGroup(1, opt)
if err != nil {
t.Errorf("Projects.ShareProjectWithGroup returned error: %v", err)
}
}
func TestDeleteSharedProjectFromGroup(t *testing.T) {
mux, server, client := setup()
defer teardown(server)
mux.HandleFunc("/projects/1/share/2", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "DELETE")
})
_, err := client.Projects.DeleteSharedProjectFromGroup(1, 2)
if err != nil {
t.Errorf("Projects.DeleteSharedProjectFromGroup 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