@@ -12,6 +12,7 @@ import (
12
12
auth_model "code.gitea.io/gitea/models/auth"
13
13
"code.gitea.io/gitea/models/db"
14
14
"code.gitea.io/gitea/models/organization"
15
+ "code.gitea.io/gitea/models/perm"
15
16
"code.gitea.io/gitea/models/repo"
16
17
"code.gitea.io/gitea/models/unit"
17
18
"code.gitea.io/gitea/models/unittest"
@@ -189,6 +190,36 @@ func TestAPITeam(t *testing.T) {
189
190
req = NewRequestf (t , "DELETE" , "/api/v1/teams/%d?token=" + token , teamID )
190
191
MakeRequest (t , req , http .StatusNoContent )
191
192
unittest .AssertNotExistsBean (t , & organization.Team {ID : teamID })
193
+
194
+ // Create admin team
195
+ teamToCreate = & api.CreateTeamOption {
196
+ Name : "teamadmin" ,
197
+ Description : "team admin" ,
198
+ IncludesAllRepositories : true ,
199
+ Permission : "admin" ,
200
+ }
201
+ req = NewRequestWithJSON (t , "POST" , fmt .Sprintf ("/api/v1/orgs/%s/teams?token=%s" , org .Name , token ), teamToCreate )
202
+ resp = MakeRequest (t , req , http .StatusCreated )
203
+ apiTeam = api.Team {}
204
+ DecodeJSON (t , resp , & apiTeam )
205
+ for _ , ut := range unit .AllRepoUnitTypes {
206
+ up := perm .AccessModeAdmin
207
+ if ut == unit .TypeExternalTracker || ut == unit .TypeExternalWiki {
208
+ up = perm .AccessModeRead
209
+ }
210
+ unittest .AssertExistsAndLoadBean (t , & organization.TeamUnit {
211
+ OrgID : org .ID ,
212
+ TeamID : apiTeam .ID ,
213
+ Type : ut ,
214
+ AccessMode : up ,
215
+ })
216
+ }
217
+ teamID = apiTeam .ID
218
+
219
+ // Delete team.
220
+ req = NewRequestf (t , "DELETE" , "/api/v1/teams/%d?token=" + token , teamID )
221
+ MakeRequest (t , req , http .StatusNoContent )
222
+ unittest .AssertNotExistsBean (t , & organization.Team {ID : teamID })
192
223
}
193
224
194
225
func checkTeamResponse (t * testing.T , testName string , apiTeam * api.Team , name , description string , includesAllRepositories bool , permission string , units []string , unitsMap map [string ]string ) {
0 commit comments