@@ -21,6 +21,7 @@ func TestOrganizationsService_ListTeams(t *testing.T) {
21
21
22
22
mux .HandleFunc ("/orgs/o/teams" , func (w http.ResponseWriter , r * http.Request ) {
23
23
testMethod (t , r , "GET" )
24
+ testHeader (t , r , "Accept" , mediaTypeNestedTeamsPreview )
24
25
testFormValues (t , r , values {"page" : "2" })
25
26
fmt .Fprint (w , `[{"id":1}]` )
26
27
})
@@ -48,7 +49,8 @@ func TestOrganizationsService_GetTeam(t *testing.T) {
48
49
49
50
mux .HandleFunc ("/teams/1" , func (w http.ResponseWriter , r * http.Request ) {
50
51
testMethod (t , r , "GET" )
51
- fmt .Fprint (w , `{"id":1, "name":"n", "description": "d", "url":"u", "slug": "s", "permission":"p", "ldap_dn":"cn=n,ou=groups,dc=example,dc=com"}` )
52
+ testHeader (t , r , "Accept" , mediaTypeNestedTeamsPreview )
53
+ fmt .Fprint (w , `{"id":1, "name":"n", "description": "d", "url":"u", "slug": "s", "permission":"p", "ldap_dn":"cn=n,ou=groups,dc=example,dc=com", "parent":null}` )
52
54
})
53
55
54
56
team , _ , err := client .Organizations .GetTeam (context .Background (), 1 )
@@ -62,17 +64,41 @@ func TestOrganizationsService_GetTeam(t *testing.T) {
62
64
}
63
65
}
64
66
67
+ func TestOrganizationService_GetTeam_nestedTeams (t * testing.T ) {
68
+ setup ()
69
+ defer teardown ()
70
+
71
+ mux .HandleFunc ("/teams/1" , func (w http.ResponseWriter , r * http.Request ) {
72
+ testMethod (t , r , "GET" )
73
+ testHeader (t , r , "Accept" , mediaTypeNestedTeamsPreview )
74
+ fmt .Fprint (w , `{"id":1, "name":"n", "description": "d", "url":"u", "slug": "s", "permission":"p",
75
+ "parent": {"id":2, "name":"n", "description": "d", "parent": null}}` )
76
+ })
77
+
78
+ team , _ , err := client .Organizations .GetTeam (context .Background (), 1 )
79
+ if err != nil {
80
+ t .Errorf ("Organizations.GetTeam returned error: %v" , err )
81
+ }
82
+
83
+ want := & Team {ID : Int (1 ), Name : String ("n" ), Description : String ("d" ), URL : String ("u" ), Slug : String ("s" ), Permission : String ("p" ),
84
+ Parent : & Team {ID : Int (2 ), Name : String ("n" ), Description : String ("d" )},
85
+ }
86
+ if ! reflect .DeepEqual (team , want ) {
87
+ t .Errorf ("Organizations.GetTeam returned %+v, want %+v" , team , want )
88
+ }
89
+ }
90
+
65
91
func TestOrganizationsService_CreateTeam (t * testing.T ) {
66
92
setup ()
67
93
defer teardown ()
68
94
69
95
input := & Team {Name : String ("n" ), Privacy : String ("closed" )}
70
-
71
96
mux .HandleFunc ("/orgs/o/teams" , func (w http.ResponseWriter , r * http.Request ) {
72
97
v := new (Team )
73
98
json .NewDecoder (r .Body ).Decode (v )
74
99
75
100
testMethod (t , r , "POST" )
101
+ testHeader (t , r , "Accept" , mediaTypeNestedTeamsPreview )
76
102
if ! reflect .DeepEqual (v , input ) {
77
103
t .Errorf ("Request body = %+v, want %+v" , v , input )
78
104
}
@@ -487,6 +513,7 @@ func TestOrganizationsService_ListUserTeams(t *testing.T) {
487
513
488
514
mux .HandleFunc ("/user/teams" , func (w http.ResponseWriter , r * http.Request ) {
489
515
testMethod (t , r , "GET" )
516
+ testHeader (t , r , "Accept" , mediaTypeNestedTeamsPreview )
490
517
testFormValues (t , r , values {"page" : "1" })
491
518
fmt .Fprint (w , `[{"id":1}]` )
492
519
})
0 commit comments