Skip to content

Commit b7a4b69

Browse files
committed
Fix tests
1 parent a60f7c2 commit b7a4b69

File tree

4 files changed

+12
-13
lines changed

4 files changed

+12
-13
lines changed

integrations/api_team_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,6 @@ func TestAPITeam(t *testing.T) {
111111
checkTeamResponse(t, &apiTeam, teamRead.Name, *teamToEditDesc.Description, teamRead.IncludesAllRepositories,
112112
teamRead.Authorize.String(), teamRead.GetUnitNames(), teamRead.GetUnitsMap())
113113

114-
panic("")
115114
// Delete team.
116115
req = NewRequestf(t, "DELETE", "/api/v1/teams/%d?token="+token, teamID)
117116
session.MakeRequest(t, req, http.StatusNoContent)

models/org_team.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -446,15 +446,15 @@ func (t *Team) UnitEnabled(tp unit.Type) bool {
446446
}
447447

448448
func (t *Team) unitEnabled(e db.Engine, tp unit.Type) bool {
449-
return t.unitAccessMode(e, tp) > AccessModeNone
449+
return t.unitAccessMode(e, tp) > perm.AccessModeNone
450450
}
451451

452452
// UnitAccessMode returns if the team has the given unit type enabled
453-
func (t *Team) UnitAccessMode(tp unit.Type) AccessMode {
453+
func (t *Team) UnitAccessMode(tp unit.Type) perm.AccessMode {
454454
return t.unitAccessMode(db.GetEngine(db.DefaultContext), tp)
455455
}
456456

457-
func (t *Team) unitAccessMode(e db.Engine, tp unit.Type) AccessMode {
457+
func (t *Team) unitAccessMode(e db.Engine, tp unit.Type) perm.AccessMode {
458458
if err := t.getUnits(e); err != nil {
459459
log.Warn("Error loading team (ID: %d) units: %s", t.ID, err.Error())
460460
}
@@ -464,7 +464,7 @@ func (t *Team) unitAccessMode(e db.Engine, tp unit.Type) AccessMode {
464464
return unit.Authorize
465465
}
466466
}
467-
return AccessModeNone
467+
return perm.AccessModeNone
468468
}
469469

470470
// IsUsableTeamName tests if a name could be as team name
@@ -1037,7 +1037,7 @@ type TeamUnit struct {
10371037
OrgID int64 `xorm:"INDEX"`
10381038
TeamID int64 `xorm:"UNIQUE(s)"`
10391039
Type unit.Type `xorm:"UNIQUE(s)"`
1040-
Authorize AccessMode
1040+
Authorize perm.AccessMode
10411041
}
10421042

10431043
// Unit returns Unit

models/repo_permission.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ func getUserRepoPermission(e db.Engine, repo *Repository, user *user_model.User)
246246
var found bool
247247
for _, team := range teams {
248248
teamMode := team.unitAccessMode(e, u.Type)
249-
if teamMode > AccessModeNone {
249+
if teamMode > perm_model.AccessModeNone {
250250
m := perm.UnitsMode[u.Type]
251251
if m < teamMode {
252252
perm.UnitsMode[u.Type] = teamMode

routers/api/v1/org/team.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -162,21 +162,21 @@ func attachTeamUnits(team *models.Team, units []string) {
162162
}
163163
}
164164

165-
func convertUnitsMap(unitsMap map[string]string) map[unit_model.Type]models.AccessMode {
166-
var res = make(map[unit_model.Type]models.AccessMode, len(unitsMap))
167-
for unitKey, perm := range unitsMap {
168-
res[unit_model.TypeFromKey(unitKey)] = models.ParseAccessMode(perm)
165+
func convertUnitsMap(unitsMap map[string]string) map[unit_model.Type]perm.AccessMode {
166+
var res = make(map[unit_model.Type]perm.AccessMode, len(unitsMap))
167+
for unitKey, p := range unitsMap {
168+
res[unit_model.TypeFromKey(unitKey)] = perm.ParseAccessMode(p)
169169
}
170170
return res
171171
}
172172

173173
func attachTeamUnitsMap(team *models.Team, unitsMap map[string]string) {
174174
team.Units = make([]*models.TeamUnit, 0, len(unitsMap))
175-
for unitKey, perm := range unitsMap {
175+
for unitKey, p := range unitsMap {
176176
team.Units = append(team.Units, &models.TeamUnit{
177177
OrgID: team.OrgID,
178178
Type: unit_model.TypeFromKey(unitKey),
179-
Authorize: perm.ParseAccessMode(perm),
179+
Authorize: perm.ParseAccessMode(p),
180180
})
181181
}
182182
}

0 commit comments

Comments
 (0)