forked from xanzy/go-gitlab
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtodos_test.go
62 lines (47 loc) · 1.37 KB
/
todos_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package gitlab
import (
"fmt"
"net/http"
"reflect"
"testing"
)
func TestListTodos(t *testing.T) {
mux, server, client := setup()
defer teardown(server)
mux.HandleFunc("/todos", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
fmt.Fprint(w, `[{"id":1,"state": "pending"},{"id":2,"state":"pending"}]`)
})
opts := &ListTodosOptions{}
todos, _, err := client.Todos.ListTodos(opts)
if err != nil {
t.Errorf("Todos.ListTodos returned error: %v", err)
}
want := []*Todo{{ID: 1, State: "pending"}, {ID: 2, State: "pending"}}
if !reflect.DeepEqual(want, todos) {
t.Errorf("Todos.ListTodos returned %+v, want %+v", todos, want)
}
}
func TestMarkAllTodosAsDone(t *testing.T) {
mux, server, client := setup()
defer teardown(server)
mux.HandleFunc("/todos/mark_as_done", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "POST")
w.WriteHeader(http.StatusNoContent)
})
_, err := client.Todos.MarkAllTodosAsDone()
if err != nil {
t.Fatalf("Todos.MarkTodosRead returns an error: %v", err)
}
}
func TestMarkTodoAsDone(t *testing.T) {
mux, server, client := setup()
defer teardown(server)
mux.HandleFunc("/todos/1/mark_as_done", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "POST")
})
_, err := client.Todos.MarkTodoAsDone(1)
if err != nil {
t.Fatalf("Todos.MarkTodoRead returns an error: %v", err)
}
}