mirror of
https://github.com/go-gitea/gitea
synced 2025-02-01 17:57:47 +01:00
Fix lint and test
This commit is contained in:
parent
8e1cac1185
commit
253ec37632
@ -84,7 +84,7 @@ func TestUpdateTeam(t *testing.T) {
|
|||||||
team.Name = "newName"
|
team.Name = "newName"
|
||||||
team.Description = strings.Repeat("A long description!", 100)
|
team.Description = strings.Repeat("A long description!", 100)
|
||||||
team.AccessMode = perm.AccessModeAdmin
|
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"})
|
team = unittest.AssertExistsAndLoadBean(t, &organization.Team{Name: "newName"})
|
||||||
assert.True(t, strings.HasPrefix(team.Description, "A long description!"))
|
assert.True(t, strings.HasPrefix(team.Description, "A long description!"))
|
||||||
@ -103,7 +103,7 @@ func TestUpdateTeam2(t *testing.T) {
|
|||||||
team.LowerName = "owners"
|
team.LowerName = "owners"
|
||||||
team.Name = "Owners"
|
team.Name = "Owners"
|
||||||
team.Description = strings.Repeat("A long description!", 100)
|
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))
|
assert.True(t, organization.IsErrTeamAlreadyExist(err))
|
||||||
|
|
||||||
unittest.CheckConsistencyFor(t, &organization.Team{ID: team.ID})
|
unittest.CheckConsistencyFor(t, &organization.Team{ID: team.ID})
|
||||||
|
@ -44,7 +44,7 @@ type EditTeamOption struct {
|
|||||||
Description *string `json:"description" binding:"MaxSize(255)"`
|
Description *string `json:"description" binding:"MaxSize(255)"`
|
||||||
IncludesAllRepositories *bool `json:"includes_all_repositories"`
|
IncludesAllRepositories *bool `json:"includes_all_repositories"`
|
||||||
// enum: read,write,admin
|
// 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"]
|
// 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.
|
// Deprecated: This variable should be replaced by UnitsMap and will be dropped in later versions.
|
||||||
Units []string `json:"units"`
|
Units []string `json:"units"`
|
||||||
|
@ -57,7 +57,7 @@ func (f *UpdateOrgSettingForm) Validate(req *http.Request, errs binding.Errors)
|
|||||||
type CreateTeamForm struct {
|
type CreateTeamForm struct {
|
||||||
TeamName string `binding:"Required;AlphaDashDot;MaxSize(255)"`
|
TeamName string `binding:"Required;AlphaDashDot;MaxSize(255)"`
|
||||||
Description string `binding:"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)"`
|
RepoAccess string `binding:"Required;In(specified, all)"`
|
||||||
CanCreateOrgRepo bool
|
CanCreateOrgRepo bool
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@ type UpdateTeamOptions struct {
|
|||||||
func UpdateTeam(ctx context.Context, team *org_model.Team, opts UpdateTeamOptions) error {
|
func UpdateTeam(ctx context.Context, team *org_model.Team, opts UpdateTeamOptions) error {
|
||||||
var changedCols []string
|
var changedCols []string
|
||||||
|
|
||||||
newAccessMode := perm.AccessModeRead
|
var newAccessMode perm.AccessMode
|
||||||
if opts.IsAdmin {
|
if opts.IsAdmin {
|
||||||
newAccessMode = perm.AccessModeAdmin
|
newAccessMode = perm.AccessModeAdmin
|
||||||
} else {
|
} else {
|
||||||
|
@ -111,7 +111,7 @@ func TestIncludesAllRepositoriesTeams(t *testing.T) {
|
|||||||
teams[4].IncludesAllRepositories = true
|
teams[4].IncludesAllRepositories = true
|
||||||
teamRepos[4] = repoIDs
|
teamRepos[4] = repoIDs
|
||||||
for i, team := range teams {
|
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])
|
testTeamRepositories(team.ID, teamRepos[i])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user