Commit f0166434 authored by Pablo Carranza's avatar Pablo Carranza

Fix formatting, add test

parent 3ee60e77
......@@ -562,8 +562,8 @@ func (s *ProjectsService) EditProject(pid interface{}, opt *EditProjectOptions,
// GitLab API docs: https://docs.gitlab.com/ce/api/projects.html#fork-project
type ForkProjectOptions struct {
Namespace *string `url:"namespace,omitempty" json:"namespace,omitempty"`
Name *string`url:"name,omitempty" json:"name,omitempty" `
Path *string`url:"path,omitempty" json:"path,omitempty"`
Name *string `url:"name,omitempty" json:"name,omitempty" `
Path *string `url:"path,omitempty" json:"path,omitempty"`
}
// ForkProject forks a project into the user namespace of the authenticated
......
......@@ -522,3 +522,32 @@ func TestChangeAllowedApprovers(t *testing.T) {
t.Errorf("Projects.ChangeAllowedApprovers returned %+v, want %+v", approvals, want)
}
}
func TestForkProject(t *testing.T) {
mux, server, client := setup()
defer teardown(server)
namespace := "mynamespace"
name := "myreponame"
path := "myrepopath"
mux.HandleFunc("/api/v4/projects/1/fork", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "POST")
testBody(t, r, fmt.Sprintf(`{"namespace":"%s","name":"%s","path":"%s"}`, namespace, name, path))
fmt.Fprint(w, `{"id":2}`)
})
project, _, err := client.Projects.ForkProject(1, &ForkProjectOptions{
Namespace: &namespace,
Name: &name,
Path: &path,
})
if err != nil {
t.Errorf("Projects.ForkProject returned error: %v", err)
}
want := &Project{ID: 2}
if !reflect.DeepEqual(want, project) {
t.Errorf("Projects.ForProject returned %+v, want %+v", project, 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