@@ -11,6 +11,7 @@ import (
11
11
"testing"
12
12
13
13
"code.gitea.io/gitea/models"
14
+ "code.gitea.io/gitea/models/unit"
14
15
"code.gitea.io/gitea/models/unittest"
15
16
user_model "code.gitea.io/gitea/models/user"
16
17
"code.gitea.io/gitea/modules/convert"
@@ -65,6 +66,7 @@ func TestAPITeam(t *testing.T) {
65
66
}
66
67
req = NewRequestWithJSON (t , "POST" , fmt .Sprintf ("/api/v1/orgs/%s/teams?token=%s" , org .Name , token ), teamToCreate )
67
68
resp = session .MakeRequest (t , req , http .StatusCreated )
69
+ apiTeam = api.Team {}
68
70
DecodeJSON (t , resp , & apiTeam )
69
71
checkTeamResponse (t , & apiTeam , teamToCreate .Name , teamToCreate .Description , teamToCreate .IncludesAllRepositories ,
70
72
teamToCreate .Permission , teamToCreate .Units , nil )
@@ -85,28 +87,31 @@ func TestAPITeam(t *testing.T) {
85
87
86
88
req = NewRequestWithJSON (t , "PATCH" , fmt .Sprintf ("/api/v1/teams/%d?token=%s" , teamID , token ), teamToEdit )
87
89
resp = session .MakeRequest (t , req , http .StatusOK )
90
+ apiTeam = api.Team {}
88
91
DecodeJSON (t , resp , & apiTeam )
89
92
checkTeamResponse (t , & apiTeam , teamToEdit .Name , * teamToEdit .Description , * teamToEdit .IncludesAllRepositories ,
90
- teamToEdit .Permission , teamToEdit . Units , nil )
93
+ teamToEdit .Permission , unit . AllUnitKeyNames () , nil )
91
94
checkTeamBean (t , apiTeam .ID , teamToEdit .Name , * teamToEdit .Description , * teamToEdit .IncludesAllRepositories ,
92
- teamToEdit .Permission , teamToEdit . Units , nil )
95
+ teamToEdit .Permission , unit . AllUnitKeyNames () , nil )
93
96
94
97
// Edit team Description only
95
98
editDescription = "first team"
96
99
teamToEditDesc := api.EditTeamOption {Description : & editDescription }
97
100
req = NewRequestWithJSON (t , "PATCH" , fmt .Sprintf ("/api/v1/teams/%d?token=%s" , teamID , token ), teamToEditDesc )
98
101
resp = session .MakeRequest (t , req , http .StatusOK )
102
+ apiTeam = api.Team {}
99
103
DecodeJSON (t , resp , & apiTeam )
100
104
checkTeamResponse (t , & apiTeam , teamToEdit .Name , * teamToEditDesc .Description , * teamToEdit .IncludesAllRepositories ,
101
- teamToEdit .Permission , teamToEdit . Units , nil )
105
+ teamToEdit .Permission , unit . AllUnitKeyNames () , nil )
102
106
checkTeamBean (t , apiTeam .ID , teamToEdit .Name , * teamToEditDesc .Description , * teamToEdit .IncludesAllRepositories ,
103
- teamToEdit .Permission , teamToEdit . Units , nil )
107
+ teamToEdit .Permission , unit . AllUnitKeyNames () , nil )
104
108
105
109
// Read team.
106
110
teamRead := unittest .AssertExistsAndLoadBean (t , & models.Team {ID : teamID }).(* models.Team )
107
111
assert .NoError (t , teamRead .GetUnits ())
108
112
req = NewRequestf (t , "GET" , "/api/v1/teams/%d?token=" + token , teamID )
109
113
resp = session .MakeRequest (t , req , http .StatusOK )
114
+ apiTeam = api.Team {}
110
115
DecodeJSON (t , resp , & apiTeam )
111
116
checkTeamResponse (t , & apiTeam , teamRead .Name , * teamToEditDesc .Description , teamRead .IncludesAllRepositories ,
112
117
teamRead .Authorize .String (), teamRead .GetUnitNames (), teamRead .GetUnitsMap ())
@@ -127,11 +132,12 @@ func TestAPITeam(t *testing.T) {
127
132
}
128
133
req = NewRequestWithJSON (t , "POST" , fmt .Sprintf ("/api/v1/orgs/%s/teams?token=%s" , org .Name , token ), teamToCreate )
129
134
resp = session .MakeRequest (t , req , http .StatusCreated )
135
+ apiTeam = api.Team {}
130
136
DecodeJSON (t , resp , & apiTeam )
131
137
checkTeamResponse (t , & apiTeam , teamToCreate .Name , teamToCreate .Description , teamToCreate .IncludesAllRepositories ,
132
- teamToCreate . Permission , nil , teamToCreate .UnitsMap )
138
+ "read" , nil , teamToCreate .UnitsMap )
133
139
checkTeamBean (t , apiTeam .ID , teamToCreate .Name , teamToCreate .Description , teamToCreate .IncludesAllRepositories ,
134
- teamToCreate . Permission , nil , teamToCreate .UnitsMap )
140
+ "read" , nil , teamToCreate .UnitsMap )
135
141
teamID = apiTeam .ID
136
142
137
143
// Edit team.
@@ -147,28 +153,32 @@ func TestAPITeam(t *testing.T) {
147
153
148
154
req = NewRequestWithJSON (t , "PATCH" , fmt .Sprintf ("/api/v1/teams/%d?token=%s" , teamID , token ), teamToEdit )
149
155
resp = session .MakeRequest (t , req , http .StatusOK )
156
+ apiTeam = api.Team {}
150
157
DecodeJSON (t , resp , & apiTeam )
151
158
checkTeamResponse (t , & apiTeam , teamToEdit .Name , * teamToEdit .Description , * teamToEdit .IncludesAllRepositories ,
152
- teamToEdit . Permission , nil , teamToEdit .UnitsMap )
159
+ "read" , nil , teamToEdit .UnitsMap )
153
160
checkTeamBean (t , apiTeam .ID , teamToEdit .Name , * teamToEdit .Description , * teamToEdit .IncludesAllRepositories ,
154
- teamToEdit . Permission , nil , teamToEdit .UnitsMap )
161
+ "read" , nil , teamToEdit .UnitsMap )
155
162
156
163
// Edit team Description only
157
164
editDescription = "second team"
158
165
teamToEditDesc = api.EditTeamOption {Description : & editDescription }
159
166
req = NewRequestWithJSON (t , "PATCH" , fmt .Sprintf ("/api/v1/teams/%d?token=%s" , teamID , token ), teamToEditDesc )
160
167
resp = session .MakeRequest (t , req , http .StatusOK )
168
+ apiTeam = api.Team {}
161
169
DecodeJSON (t , resp , & apiTeam )
162
170
checkTeamResponse (t , & apiTeam , teamToEdit .Name , * teamToEditDesc .Description , * teamToEdit .IncludesAllRepositories ,
163
- teamToEdit . Permission , nil , teamToEdit .UnitsMap )
171
+ "read" , nil , teamToEdit .UnitsMap )
164
172
checkTeamBean (t , apiTeam .ID , teamToEdit .Name , * teamToEditDesc .Description , * teamToEdit .IncludesAllRepositories ,
165
- teamToEdit . Permission , nil , teamToEdit .UnitsMap )
173
+ "read" , nil , teamToEdit .UnitsMap )
166
174
167
175
// Read team.
168
176
teamRead = unittest .AssertExistsAndLoadBean (t , & models.Team {ID : teamID }).(* models.Team )
169
177
req = NewRequestf (t , "GET" , "/api/v1/teams/%d?token=" + token , teamID )
170
178
resp = session .MakeRequest (t , req , http .StatusOK )
179
+ apiTeam = api.Team {}
171
180
DecodeJSON (t , resp , & apiTeam )
181
+ assert .NoError (t , teamRead .GetUnits ())
172
182
checkTeamResponse (t , & apiTeam , teamRead .Name , * teamToEditDesc .Description , teamRead .IncludesAllRepositories ,
173
183
teamRead .Authorize .String (), teamRead .GetUnitNames (), teamRead .GetUnitsMap ())
174
184
0 commit comments