Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
go-gitlab
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
go-gitlab
Commits
d56ec0d0
Commit
d56ec0d0
authored
Mar 02, 2016
by
Sander van Harmelen
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #37 from MrArtichaut/master
Implements starred project listing
parents
7125de3e
1a337109
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
53 additions
and
0 deletions
+53
-0
projects.go
projects.go
+22
-0
projects_test.go
projects_test.go
+31
-0
No files found.
projects.go
View file @
d56ec0d0
...
@@ -141,6 +141,28 @@ func (s *ProjectsService) ListOwnedProjects(
...
@@ -141,6 +141,28 @@ func (s *ProjectsService) ListOwnedProjects(
return
p
,
resp
,
err
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).
// ListAllProjects gets a list of all GitLab projects (admin only).
//
//
// GitLab API docs:
// GitLab API docs:
...
...
projects_test.go
View file @
d56ec0d0
...
@@ -69,6 +69,37 @@ func TestListOwnedProjects(t *testing.T) {
...
@@ -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
)
{
func
TestListAllProjects
(
t
*
testing
.
T
)
{
mux
,
server
,
client
:=
setup
()
mux
,
server
,
client
:=
setup
()
defer
teardown
(
server
)
defer
teardown
(
server
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment