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
a4e9e6c4
Unverified
Commit
a4e9e6c4
authored
Jul 14, 2019
by
Sander van Harmelen
Committed by
GitHub
Jul 14, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #651 from ZJvandeWeg/zj-todos-list-opts
ListTodo allows for ListOptions
parents
6af500e1
8ac669f5
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
19 deletions
+27
-19
list_todos.json
testdata/list_todos.json
+18
-0
todos.go
todos.go
+1
-0
todos_test.go
todos_test.go
+8
-19
No files found.
testdata/list_todos.json
0 → 100644
View file @
a4e9e6c4
[
{
"id"
:
1
,
"state"
:
"pending"
,
"target"
:
{
"id"
:
1
,
"approvals_before_merge"
:
2
}
},
{
"id"
:
2
,
"state"
:
"pending"
,
"target"
:
{
"id"
:
2
,
"approvals_before_merge"
:
null
}
}
]
todos.go
View file @
a4e9e6c4
...
...
@@ -121,6 +121,7 @@ func (t Todo) String() string {
//
// GitLab API docs: https://docs.gitlab.com/ce/api/todos.html#get-a-list-of-todos
type
ListTodosOptions
struct
{
ListOptions
Action
*
TodoAction
`url:"action,omitempty" json:"action,omitempty"`
AuthorID
*
int
`url:"author_id,omitempty" json:"author_id,omitempty"`
ProjectID
*
int
`url:"project_id,omitempty" json:"project_id,omitempty"`
...
...
todos_test.go
View file @
a4e9e6c4
package
gitlab
import
(
"fmt"
"net/http"
"reflect"
"testing"
"github.com/stretchr/testify/require"
)
func
TestListTodos
(
t
*
testing
.
T
)
{
...
...
@@ -13,21 +13,16 @@ func TestListTodos(t *testing.T) {
mux
.
HandleFunc
(
"/api/v4/todos"
,
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
testMethod
(
t
,
r
,
"GET"
)
fmt
.
Fprint
(
w
,
`[{"id":1,"state": "pending","target":{"id":1,"approvals_before_merge":2}},{"id":2,"state":"pending","target":{"id":2,"approvals_before_merge":null}}]`
)
mustWriteHTTPResponse
(
t
,
w
,
"testdata/list_todos.json"
)
})
opts
:=
&
ListTodosOptions
{}
opts
:=
&
ListTodosOptions
{
ListOptions
:
ListOptions
{
PerPage
:
2
}
}
todos
,
_
,
err
:=
client
.
Todos
.
ListTodos
(
opts
)
if
err
!=
nil
{
t
.
Errorf
(
"Todos.ListTodos returned error: %v"
,
err
)
}
require
.
NoError
(
t
,
err
)
want
:=
[]
*
Todo
{{
ID
:
1
,
State
:
"pending"
,
Target
:
TodoTarget
{
ID
:
1
,
ApprovalsBeforeMerge
:
2
}},
{
ID
:
2
,
State
:
"pending"
,
Target
:
TodoTarget
{
ID
:
2
}}}
if
!
reflect
.
DeepEqual
(
want
,
todos
)
{
t
.
Errorf
(
"Todos.ListTodos returned %+v, want %+v"
,
todos
,
want
)
}
require
.
Equal
(
t
,
want
,
todos
)
}
func
TestMarkAllTodosAsDone
(
t
*
testing
.
T
)
{
...
...
@@ -40,10 +35,7 @@ func TestMarkAllTodosAsDone(t *testing.T) {
})
_
,
err
:=
client
.
Todos
.
MarkAllTodosAsDone
()
if
err
!=
nil
{
t
.
Fatalf
(
"Todos.MarkTodosRead returns an error: %v"
,
err
)
}
require
.
NoError
(
t
,
err
)
}
func
TestMarkTodoAsDone
(
t
*
testing
.
T
)
{
...
...
@@ -55,8 +47,5 @@ func TestMarkTodoAsDone(t *testing.T) {
})
_
,
err
:=
client
.
Todos
.
MarkTodoAsDone
(
1
)
if
err
!=
nil
{
t
.
Fatalf
(
"Todos.MarkTodoRead returns an error: %v"
,
err
)
}
require
.
NoError
(
t
,
err
)
}
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