0
0
Fork 0
mirror of https://github.com/go-gitea/gitea synced 2024-11-21 21:41:10 +01:00

Fix lint and test

This commit is contained in:
Lunny Xiao 2024-10-26 00:27:14 -07:00
parent 8e1cac1185
commit 253ec37632
No known key found for this signature in database
GPG key ID: C3B7C91B632F738A
5 changed files with 6 additions and 6 deletions

View file

@ -84,7 +84,7 @@ func TestUpdateTeam(t *testing.T) {
team.Name = "newName"
team.Description = strings.Repeat("A long description!", 100)
team.AccessMode = perm.AccessModeAdmin
assert.NoError(t, UpdateTeam(db.DefaultContext, team, true, false))
assert.NoError(t, UpdateTeam(db.DefaultContext, team, "authorize"))
team = unittest.AssertExistsAndLoadBean(t, &organization.Team{Name: "newName"})
assert.True(t, strings.HasPrefix(team.Description, "A long description!"))
@ -103,7 +103,7 @@ func TestUpdateTeam2(t *testing.T) {
team.LowerName = "owners"
team.Name = "Owners"
team.Description = strings.Repeat("A long description!", 100)
err := UpdateTeam(db.DefaultContext, team, true, false)
err := UpdateTeam(db.DefaultContext, team, "authorize")
assert.True(t, organization.IsErrTeamAlreadyExist(err))
unittest.CheckConsistencyFor(t, &organization.Team{ID: team.ID})

View file

@ -44,7 +44,7 @@ type EditTeamOption struct {
Description *string `json:"description" binding:"MaxSize(255)"`
IncludesAllRepositories *bool `json:"includes_all_repositories"`
// enum: read,write,admin
Permission string `json:"permission" binding:"`
Permission string `json:"permission" binding:"Required;In(read,write,admin)"`
// example: ["repo.code","repo.issues","repo.ext_issues","repo.wiki","repo.pulls","repo.releases","repo.projects","repo.ext_wiki"]
// Deprecated: This variable should be replaced by UnitsMap and will be dropped in later versions.
Units []string `json:"units"`

View file

@ -57,7 +57,7 @@ func (f *UpdateOrgSettingForm) Validate(req *http.Request, errs binding.Errors)
type CreateTeamForm struct {
TeamName string `binding:"Required;AlphaDashDot;MaxSize(255)"`
Description string `binding:"MaxSize(255)"`
Permission string `binding:"Required;In(admin, read)"`
Permission string `binding:"Required;In(read,write,admin)"`
RepoAccess string `binding:"Required;In(specified, all)"`
CanCreateOrgRepo bool
}

View file

@ -24,7 +24,7 @@ type UpdateTeamOptions struct {
func UpdateTeam(ctx context.Context, team *org_model.Team, opts UpdateTeamOptions) error {
var changedCols []string
newAccessMode := perm.AccessModeRead
var newAccessMode perm.AccessMode
if opts.IsAdmin {
newAccessMode = perm.AccessModeAdmin
} else {

View file

@ -111,7 +111,7 @@ func TestIncludesAllRepositoriesTeams(t *testing.T) {
teams[4].IncludesAllRepositories = true
teamRepos[4] = repoIDs
for i, team := range teams {
assert.NoError(t, models.UpdateTeam(db.DefaultContext, team, false, true), "%s: UpdateTeam", team.Name)
assert.NoError(t, models.UpdateTeam(db.DefaultContext, team, "includes_all_repositories"), "%s: UpdateTeam", team.Name)
testTeamRepositories(team.ID, teamRepos[i])
}