Skip to content

Commit 793bccb

Browse files
committed
implement project removing
1 parent cf7f33f commit 793bccb

File tree

4 files changed

+30
-1
lines changed

4 files changed

+30
-1
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ go-gitlab-client is a simple client written in golang to consume gitlab API.
1212
###Projects [gitlab api doc](http://api.gitlab.org/projects.html)
1313
* list projects
1414
* get single project
15+
* remove project
1516

1617
*
1718
###Repositories [gitlab api doc](http://api.gitlab.org/repositories.html)
@@ -69,4 +70,4 @@ Visit the docs at http://godoc.org/github.com/plouc/go-gitlab-client
6970
You can play with the examples located in the `examples` directory
7071

7172
* [projects](https://github.com/plouc/go-gitlab-client/tree/master/examples/projects)
72-
* [repositories](https://github.com/plouc/go-gitlab-client/tree/master/examples/repositories)
73+
* [repositories](https://github.com/plouc/go-gitlab-client/tree/master/examples/repositories)

projects.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package gogitlab
22

33
import (
44
"encoding/json"
5+
"strconv"
56
)
67

78
const (
@@ -71,6 +72,22 @@ func (g *Gitlab) Projects() ([]*Project, error) {
7172
return projects, err
7273
}
7374

75+
/*
76+
Remove a project.
77+
*/
78+
func (g *Gitlab) RemoveProject(id string) (bool, error) {
79+
80+
url, opaque := g.ResourceUrlRaw(project_url, map[string]string{":id": id})
81+
result := false
82+
83+
contents, err := g.buildAndExecRequestRaw("DELETE", url, opaque, nil)
84+
if err == nil {
85+
result, err = strconv.ParseBool(string(contents[:]))
86+
}
87+
88+
return result, err
89+
}
90+
7491
/*
7592
Get a specific project, identified by project ID or NAME,
7693
which is owned by the authentication user.

projects_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,13 @@ func TestProjectBranches(t *testing.T) {
3333
assert.Equal(t, len(branches), 2)
3434
defer ts.Close()
3535
}
36+
37+
func TestRemoveProject(t *testing.T) {
38+
ts, gitlab := Stub("stubs/projects/remove.json")
39+
defer ts.Close()
40+
41+
result, err := gitlab.RemoveProject("1")
42+
43+
assert.Equal(t, err, nil)
44+
assert.Equal(t, result, true)
45+
}

stubs/projects/remove.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
true

0 commit comments

Comments
 (0)