Skip to content

Commit 928b430

Browse files
committed
add test
1 parent 358ab99 commit 928b430

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

tests/integration/api_team_test.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
auth_model "code.gitea.io/gitea/models/auth"
1313
"code.gitea.io/gitea/models/db"
1414
"code.gitea.io/gitea/models/organization"
15+
"code.gitea.io/gitea/models/perm"
1516
"code.gitea.io/gitea/models/repo"
1617
"code.gitea.io/gitea/models/unit"
1718
"code.gitea.io/gitea/models/unittest"
@@ -189,6 +190,36 @@ func TestAPITeam(t *testing.T) {
189190
req = NewRequestf(t, "DELETE", "/api/v1/teams/%d?token="+token, teamID)
190191
MakeRequest(t, req, http.StatusNoContent)
191192
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})
192223
}
193224

194225
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

Comments
 (0)