forked from xanzy/go-gitlab
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathresource_weight_events_test.go
55 lines (48 loc) · 1.36 KB
/
resource_weight_events_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
package gitlab
import (
"fmt"
"net/http"
"testing"
"time"
"github.com/stretchr/testify/require"
)
func TestResourceWeightEventsService_ListIssueWightEvents(t *testing.T) {
mux, client := setup(t)
mux.HandleFunc("/api/v4/projects/5/issues/11/resource_weight_events", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, http.MethodGet)
fmt.Fprintf(w, `[
{
"id": 142,
"user": {
"id": 1,
"name": "Administrator",
"username": "root",
"state": "active",
"avatar_url": "https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
"web_url": "http://gitlab.example.com/root"
},
"created_at": "2018-08-20T13:38:20.077Z",
"issue_id": 253,
"weight": 3
}
]`)
})
opt := &ListWeightEventsOptions{ListOptions{Page: 1, PerPage: 10}}
wes, _, err := client.ResourceWeightEvents.ListIssueWeightEvents(5, 11, opt)
require.NoError(t, err)
want := []*WeightEvent{{
ID: 142,
User: &BasicUser{
ID: 1,
Username: "root",
Name: "Administrator",
State: "active",
AvatarURL: "https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
WebURL: "http://gitlab.example.com/root",
},
CreatedAt: Ptr(time.Date(2018, time.August, 20, 13, 38, 20, 77000000, time.UTC)),
IssueID: 253,
Weight: 3,
}}
require.Equal(t, want, wes)
}