Repository navigation
Expand file tree
/
Copy pathactivity_test.go
More file actions
131 lines (121 loc) · 3.81 KB
/
Copy pathactivity_test.go
File metadata and controls
131 lines (121 loc) · 3.81 KB
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
// Copyright 2016 The go-github AUTHORS. All rights reserved.
//
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package github
import (
"net/http"
"testing"
"github.com/google/go-cmp/cmp"
)
func TestActivityService_List(t *testing.T) {
t.Parallel()
client, mux, _ := setup(t)
mux.HandleFunc("/feeds", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
w.WriteHeader(http.StatusOK)
assertWrite(t, w, feedsJSON)
})
ctx := t.Context()
got, _, err := client.Activity.ListFeeds(ctx)
if err != nil {
t.Errorf("Activity.ListFeeds returned error: %v", err)
}
if want := wantFeeds; !cmp.Equal(got, want) {
t.Errorf("Activity.ListFeeds = %+v, want %+v", got, want)
}
const methodName = "ListFeeds"
testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
got, resp, err := client.Activity.ListFeeds(ctx)
if got != nil {
t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
}
return resp, err
})
}
var feedsJSON = []byte(`{
"timeline_url": "https://github.com/timeline",
"user_url": "https://github.com/{user}",
"current_user_public_url": "https://github.com/defunkt",
"current_user_url": "https://github.com/defunkt.private?token=abc123",
"current_user_actor_url": "https://github.com/defunkt.private.actor?token=abc123",
"current_user_organization_url": "",
"current_user_organization_urls": [
"https://github.com/organizations/github/defunkt.private.atom?token=abc123"
],
"_links": {
"timeline": {
"href": "https://github.com/timeline",
"type": "application/atom+xml"
},
"user": {
"href": "https://github.com/{user}",
"type": "application/atom+xml"
},
"current_user_public": {
"href": "https://github.com/defunkt",
"type": "application/atom+xml"
},
"current_user": {
"href": "https://github.com/defunkt.private?token=abc123",
"type": "application/atom+xml"
},
"current_user_actor": {
"href": "https://github.com/defunkt.private.actor?token=abc123",
"type": "application/atom+xml"
},
"current_user_organization": {
"href": "",
"type": ""
},
"current_user_organizations": [
{
"href": "https://github.com/organizations/github/defunkt.private.atom?token=abc123",
"type": "application/atom+xml"
}
]
}
}`)
var wantFeeds = &Feeds{
TimelineURL: new("https://github.com/timeline"),
UserURL: new("https://github.com/{user}"),
CurrentUserPublicURL: new("https://github.com/defunkt"),
CurrentUserURL: new("https://github.com/defunkt.private?token=abc123"),
CurrentUserActorURL: new("https://github.com/defunkt.private.actor?token=abc123"),
CurrentUserOrganizationURL: new(""),
CurrentUserOrganizationURLs: []string{
"https://github.com/organizations/github/defunkt.private.atom?token=abc123",
},
Links: &FeedLinks{
Timeline: &FeedLink{
HRef: new("https://github.com/timeline"),
Type: new("application/atom+xml"),
},
User: &FeedLink{
HRef: new("https://github.com/{user}"),
Type: new("application/atom+xml"),
},
CurrentUserPublic: &FeedLink{
HRef: new("https://github.com/defunkt"),
Type: new("application/atom+xml"),
},
CurrentUser: &FeedLink{
HRef: new("https://github.com/defunkt.private?token=abc123"),
Type: new("application/atom+xml"),
},
CurrentUserActor: &FeedLink{
HRef: new("https://github.com/defunkt.private.actor?token=abc123"),
Type: new("application/atom+xml"),
},
CurrentUserOrganization: &FeedLink{
HRef: new(""),
Type: new(""),
},
CurrentUserOrganizations: []*FeedLink{
{
HRef: new("https://github.com/organizations/github/defunkt.private.atom?token=abc123"),
Type: new("application/atom+xml"),
},
},
},
}