@@ -10,6 +10,7 @@ import (
10
10
"fmt"
11
11
"net/http"
12
12
"testing"
13
+ "time"
13
14
14
15
"github.com/google/go-cmp/cmp"
15
16
)
@@ -20,7 +21,30 @@ func TestOrganizationsService_ListRoles(t *testing.T) {
20
21
21
22
mux .HandleFunc ("/orgs/o/organization-roles" , func (w http.ResponseWriter , r * http.Request ) {
22
23
testMethod (t , r , "GET" )
23
- fmt .Fprint (w , `{"total_count": 1, "roles": [{ "id": 1, "name": "Auditor", "permissions": ["read_audit_logs"]}]}` )
24
+ fmt .Fprint (w , `{"total_count": 1, "roles": [
25
+ {
26
+ "id": 1,
27
+ "name": "Auditor",
28
+ "permissions": ["read_audit_logs"],
29
+ "organization": {
30
+ "login": "l",
31
+ "id": 1,
32
+ "node_id": "n",
33
+ "avatar_url": "a",
34
+ "html_url": "h",
35
+ "name": "n",
36
+ "company": "c",
37
+ "blog": "b",
38
+ "location": "l",
39
+ "email": "e"
40
+ },
41
+ "created_at": "2024-07-21T19:33:08Z",
42
+ "updated_at": "2024-07-21T19:33:08Z",
43
+ "source": "Organization",
44
+ "base_role": "admin"
45
+ }
46
+ ]
47
+ }` )
24
48
})
25
49
26
50
ctx := context .Background ()
@@ -29,7 +53,32 @@ func TestOrganizationsService_ListRoles(t *testing.T) {
29
53
t .Errorf ("Organizations.ListRoles returned error: %v" , err )
30
54
}
31
55
32
- want := & OrganizationCustomRoles {TotalCount : Int (1 ), CustomRepoRoles : []* CustomOrgRoles {{ID : Int64 (1 ), Name : String ("Auditor" ), Permissions : []string {"read_audit_logs" }}}}
56
+ want := & OrganizationCustomRoles {
57
+ TotalCount : Int (1 ),
58
+ CustomRepoRoles : []* CustomOrgRoles {
59
+ {
60
+ ID : Int64 (1 ),
61
+ Name : String ("Auditor" ),
62
+ Permissions : []string {"read_audit_logs" },
63
+ Org : & Organization {
64
+ Login : String ("l" ),
65
+ ID : Int64 (1 ),
66
+ NodeID : String ("n" ),
67
+ AvatarURL : String ("a" ),
68
+ HTMLURL : String ("h" ),
69
+ Name : String ("n" ),
70
+ Company : String ("c" ),
71
+ Blog : String ("b" ),
72
+ Location : String ("l" ),
73
+ Email : String ("e" ),
74
+ },
75
+ CreatedAt : & Timestamp {time .Date (2024 , time .July , 21 , 19 , 33 , 8 , 0 , time .UTC )},
76
+ UpdatedAt : & Timestamp {time .Date (2024 , time .July , 21 , 19 , 33 , 8 , 0 , time .UTC )},
77
+ Source : String ("Organization" ),
78
+ BaseRole : String ("admin" ),
79
+ },
80
+ },
81
+ }
33
82
if ! cmp .Equal (apps , want ) {
34
83
t .Errorf ("Organizations.ListRoles returned %+v, want %+v" , apps , want )
35
84
}
@@ -169,7 +218,29 @@ func TestOrganizationsService_ListCustomRepoRoles(t *testing.T) {
169
218
170
219
mux .HandleFunc ("/orgs/o/custom-repository-roles" , func (w http.ResponseWriter , r * http.Request ) {
171
220
testMethod (t , r , "GET" )
172
- fmt .Fprint (w , `{"total_count": 1, "custom_roles": [{ "id": 1, "name": "Developer", "base_role": "write", "permissions": ["delete_alerts_code_scanning"]}]}` )
221
+ fmt .Fprint (w , `{"total_count": 1, "custom_roles": [
222
+ {
223
+ "id": 1,
224
+ "name": "Developer",
225
+ "base_role": "write",
226
+ "permissions": ["delete_alerts_code_scanning"],
227
+ "organization": {
228
+ "login": "l",
229
+ "id": 1,
230
+ "node_id": "n",
231
+ "avatar_url": "a",
232
+ "html_url": "h",
233
+ "name": "n",
234
+ "company": "c",
235
+ "blog": "b",
236
+ "location": "l",
237
+ "email": "e"
238
+ },
239
+ "created_at": "2024-07-21T19:33:08Z",
240
+ "updated_at": "2024-07-21T19:33:08Z"
241
+ }
242
+ ]
243
+ }` )
173
244
})
174
245
175
246
ctx := context .Background ()
@@ -178,7 +249,31 @@ func TestOrganizationsService_ListCustomRepoRoles(t *testing.T) {
178
249
t .Errorf ("Organizations.ListCustomRepoRoles returned error: %v" , err )
179
250
}
180
251
181
- want := & OrganizationCustomRepoRoles {TotalCount : Int (1 ), CustomRepoRoles : []* CustomRepoRoles {{ID : Int64 (1 ), Name : String ("Developer" ), BaseRole : String ("write" ), Permissions : []string {"delete_alerts_code_scanning" }}}}
252
+ want := & OrganizationCustomRepoRoles {
253
+ TotalCount : Int (1 ),
254
+ CustomRepoRoles : []* CustomRepoRoles {
255
+ {
256
+ ID : Int64 (1 ),
257
+ Name : String ("Developer" ),
258
+ BaseRole : String ("write" ),
259
+ Permissions : []string {"delete_alerts_code_scanning" },
260
+ Org : & Organization {
261
+ Login : String ("l" ),
262
+ ID : Int64 (1 ),
263
+ NodeID : String ("n" ),
264
+ AvatarURL : String ("a" ),
265
+ HTMLURL : String ("h" ),
266
+ Name : String ("n" ),
267
+ Company : String ("c" ),
268
+ Blog : String ("b" ),
269
+ Location : String ("l" ),
270
+ Email : String ("e" ),
271
+ },
272
+ CreatedAt : & Timestamp {time .Date (2024 , time .July , 21 , 19 , 33 , 8 , 0 , time .UTC )},
273
+ UpdatedAt : & Timestamp {time .Date (2024 , time .July , 21 , 19 , 33 , 8 , 0 , time .UTC )},
274
+ },
275
+ },
276
+ }
182
277
if ! cmp .Equal (apps , want ) {
183
278
t .Errorf ("Organizations.ListCustomRepoRoles returned %+v, want %+v" , apps , want )
184
279
}
0 commit comments