mirror of
https://github.com/go-gitea/gitea
synced 2024-11-21 18:22:13 +01:00
Fix lint
This commit is contained in:
parent
e1fe318179
commit
9c0cc9b394
2 changed files with 15 additions and 17 deletions
|
@ -11,7 +11,6 @@ import (
|
||||||
|
|
||||||
auth_model "code.gitea.io/gitea/models/auth"
|
auth_model "code.gitea.io/gitea/models/auth"
|
||||||
"code.gitea.io/gitea/models/db"
|
"code.gitea.io/gitea/models/db"
|
||||||
"code.gitea.io/gitea/models/organization"
|
|
||||||
org_model "code.gitea.io/gitea/models/organization"
|
org_model "code.gitea.io/gitea/models/organization"
|
||||||
"code.gitea.io/gitea/models/perm"
|
"code.gitea.io/gitea/models/perm"
|
||||||
"code.gitea.io/gitea/models/repo"
|
"code.gitea.io/gitea/models/repo"
|
||||||
|
@ -28,9 +27,9 @@ import (
|
||||||
func TestAPITeam(t *testing.T) {
|
func TestAPITeam(t *testing.T) {
|
||||||
defer tests.PrepareTestEnv(t)()
|
defer tests.PrepareTestEnv(t)()
|
||||||
|
|
||||||
teamUser := unittest.AssertExistsAndLoadBean(t, &organization.TeamUser{ID: 1})
|
teamUser := unittest.AssertExistsAndLoadBean(t, &org_model.TeamUser{ID: 1})
|
||||||
team := unittest.AssertExistsAndLoadBean(t, &organization.Team{ID: teamUser.TeamID})
|
team := unittest.AssertExistsAndLoadBean(t, &org_model.Team{ID: teamUser.TeamID})
|
||||||
org := unittest.AssertExistsAndLoadBean(t, &organization.Organization{ID: teamUser.OrgID})
|
org := unittest.AssertExistsAndLoadBean(t, &org_model.Organization{ID: teamUser.OrgID})
|
||||||
user := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: teamUser.UID})
|
user := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: teamUser.UID})
|
||||||
|
|
||||||
session := loginUser(t, user.Name)
|
session := loginUser(t, user.Name)
|
||||||
|
@ -47,7 +46,7 @@ func TestAPITeam(t *testing.T) {
|
||||||
assert.EqualValues(t, convert.ToOrganization(db.DefaultContext, org), apiTeam.Organization)
|
assert.EqualValues(t, convert.ToOrganization(db.DefaultContext, org), apiTeam.Organization)
|
||||||
|
|
||||||
// non team member user will not access the teams details
|
// non team member user will not access the teams details
|
||||||
teamUser2 := unittest.AssertExistsAndLoadBean(t, &organization.TeamUser{ID: 3})
|
teamUser2 := unittest.AssertExistsAndLoadBean(t, &org_model.TeamUser{ID: 3})
|
||||||
user2 := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: teamUser2.UID})
|
user2 := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: teamUser2.UID})
|
||||||
|
|
||||||
session = loginUser(t, user2.Name)
|
session = loginUser(t, user2.Name)
|
||||||
|
@ -61,7 +60,7 @@ func TestAPITeam(t *testing.T) {
|
||||||
|
|
||||||
// Get an admin user able to create, update and delete teams.
|
// Get an admin user able to create, update and delete teams.
|
||||||
user = unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 1})
|
user = unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 1})
|
||||||
org = unittest.AssertExistsAndLoadBean(t, &organization.Organization{ID: 6})
|
org = unittest.AssertExistsAndLoadBean(t, &org_model.Organization{ID: 6})
|
||||||
session = loginUser(t, user.Name)
|
session = loginUser(t, user.Name)
|
||||||
token = getTokenForLoggedInUser(t, session, auth_model.AccessTokenScopeWriteOrganization)
|
token = getTokenForLoggedInUser(t, session, auth_model.AccessTokenScopeWriteOrganization)
|
||||||
|
|
||||||
|
@ -140,7 +139,7 @@ func TestAPITeam(t *testing.T) {
|
||||||
teamToEdit.Permission, unit.AllUnitKeyNames(), nil)
|
teamToEdit.Permission, unit.AllUnitKeyNames(), nil)
|
||||||
|
|
||||||
// Read team.
|
// Read team.
|
||||||
teamRead := unittest.AssertExistsAndLoadBean(t, &organization.Team{ID: teamID})
|
teamRead := unittest.AssertExistsAndLoadBean(t, &org_model.Team{ID: teamID})
|
||||||
assert.NoError(t, teamRead.LoadUnits(db.DefaultContext))
|
assert.NoError(t, teamRead.LoadUnits(db.DefaultContext))
|
||||||
req = NewRequestf(t, "GET", "/api/v1/teams/%d", teamID).
|
req = NewRequestf(t, "GET", "/api/v1/teams/%d", teamID).
|
||||||
AddTokenAuth(token)
|
AddTokenAuth(token)
|
||||||
|
@ -154,7 +153,7 @@ func TestAPITeam(t *testing.T) {
|
||||||
req = NewRequestf(t, "DELETE", "/api/v1/teams/%d", teamID).
|
req = NewRequestf(t, "DELETE", "/api/v1/teams/%d", teamID).
|
||||||
AddTokenAuth(token)
|
AddTokenAuth(token)
|
||||||
MakeRequest(t, req, http.StatusNoContent)
|
MakeRequest(t, req, http.StatusNoContent)
|
||||||
unittest.AssertNotExistsBean(t, &organization.Team{ID: teamID})
|
unittest.AssertNotExistsBean(t, &org_model.Team{ID: teamID})
|
||||||
|
|
||||||
// create team again via UnitsMap
|
// create team again via UnitsMap
|
||||||
// Create team.
|
// Create team.
|
||||||
|
@ -211,7 +210,7 @@ func TestAPITeam(t *testing.T) {
|
||||||
"read", nil, teamToEdit.UnitsMap)
|
"read", nil, teamToEdit.UnitsMap)
|
||||||
|
|
||||||
// Read team.
|
// Read team.
|
||||||
teamRead = unittest.AssertExistsAndLoadBean(t, &organization.Team{ID: teamID})
|
teamRead = unittest.AssertExistsAndLoadBean(t, &org_model.Team{ID: teamID})
|
||||||
req = NewRequestf(t, "GET", "/api/v1/teams/%d", teamID).
|
req = NewRequestf(t, "GET", "/api/v1/teams/%d", teamID).
|
||||||
AddTokenAuth(token)
|
AddTokenAuth(token)
|
||||||
resp = MakeRequest(t, req, http.StatusOK)
|
resp = MakeRequest(t, req, http.StatusOK)
|
||||||
|
@ -225,7 +224,7 @@ func TestAPITeam(t *testing.T) {
|
||||||
req = NewRequestf(t, "DELETE", "/api/v1/teams/%d", teamID).
|
req = NewRequestf(t, "DELETE", "/api/v1/teams/%d", teamID).
|
||||||
AddTokenAuth(token)
|
AddTokenAuth(token)
|
||||||
MakeRequest(t, req, http.StatusNoContent)
|
MakeRequest(t, req, http.StatusNoContent)
|
||||||
unittest.AssertNotExistsBean(t, &organization.Team{ID: teamID})
|
unittest.AssertNotExistsBean(t, &org_model.Team{ID: teamID})
|
||||||
|
|
||||||
// Create admin team
|
// Create admin team
|
||||||
teamToCreate = &api.CreateTeamOption{
|
teamToCreate = &api.CreateTeamOption{
|
||||||
|
@ -244,7 +243,7 @@ func TestAPITeam(t *testing.T) {
|
||||||
if ut == unit.TypeExternalTracker || ut == unit.TypeExternalWiki {
|
if ut == unit.TypeExternalTracker || ut == unit.TypeExternalWiki {
|
||||||
up = perm.AccessModeRead
|
up = perm.AccessModeRead
|
||||||
}
|
}
|
||||||
unittest.AssertExistsAndLoadBean(t, &organization.TeamUnit{
|
unittest.AssertExistsAndLoadBean(t, &org_model.TeamUnit{
|
||||||
OrgID: org.ID,
|
OrgID: org.ID,
|
||||||
TeamID: apiTeam.ID,
|
TeamID: apiTeam.ID,
|
||||||
Type: ut,
|
Type: ut,
|
||||||
|
@ -257,7 +256,7 @@ func TestAPITeam(t *testing.T) {
|
||||||
req = NewRequestf(t, "DELETE", "/api/v1/teams/%d", teamID).
|
req = NewRequestf(t, "DELETE", "/api/v1/teams/%d", teamID).
|
||||||
AddTokenAuth(token)
|
AddTokenAuth(token)
|
||||||
MakeRequest(t, req, http.StatusNoContent)
|
MakeRequest(t, req, http.StatusNoContent)
|
||||||
unittest.AssertNotExistsBean(t, &organization.Team{ID: teamID})
|
unittest.AssertNotExistsBean(t, &org_model.Team{ID: teamID})
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkTeamResponse(t *testing.T, testName string, apiTeam *api.Team, name, description string, includesAllRepositories bool, permission string, units []string, unitsMap map[string]string) {
|
func checkTeamResponse(t *testing.T, testName string, apiTeam *api.Team, name, description string, includesAllRepositories bool, permission string, units []string, unitsMap map[string]string) {
|
||||||
|
@ -278,7 +277,7 @@ func checkTeamResponse(t *testing.T, testName string, apiTeam *api.Team, name, d
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkTeamBean(t *testing.T, id int64, name, description string, includesAllRepositories bool, permission string, units []string, unitsMap map[string]string) {
|
func checkTeamBean(t *testing.T, id int64, name, description string, includesAllRepositories bool, permission string, units []string, unitsMap map[string]string) {
|
||||||
team := unittest.AssertExistsAndLoadBean(t, &organization.Team{ID: id})
|
team := unittest.AssertExistsAndLoadBean(t, &org_model.Team{ID: id})
|
||||||
assert.NoError(t, team.LoadUnits(db.DefaultContext), "LoadUnits")
|
assert.NoError(t, team.LoadUnits(db.DefaultContext), "LoadUnits")
|
||||||
apiTeam, err := convert.ToTeam(db.DefaultContext, team)
|
apiTeam, err := convert.ToTeam(db.DefaultContext, team)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
@ -321,7 +320,7 @@ func TestAPIGetTeamRepo(t *testing.T) {
|
||||||
|
|
||||||
user := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 15})
|
user := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 15})
|
||||||
teamRepo := unittest.AssertExistsAndLoadBean(t, &repo.Repository{ID: 24})
|
teamRepo := unittest.AssertExistsAndLoadBean(t, &repo.Repository{ID: 24})
|
||||||
team := unittest.AssertExistsAndLoadBean(t, &organization.Team{ID: 5})
|
team := unittest.AssertExistsAndLoadBean(t, &org_model.Team{ID: 5})
|
||||||
|
|
||||||
var results api.Repository
|
var results api.Repository
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,6 @@ import (
|
||||||
|
|
||||||
auth_model "code.gitea.io/gitea/models/auth"
|
auth_model "code.gitea.io/gitea/models/auth"
|
||||||
"code.gitea.io/gitea/models/db"
|
"code.gitea.io/gitea/models/db"
|
||||||
"code.gitea.io/gitea/models/organization"
|
|
||||||
org_model "code.gitea.io/gitea/models/organization"
|
org_model "code.gitea.io/gitea/models/organization"
|
||||||
"code.gitea.io/gitea/models/perm"
|
"code.gitea.io/gitea/models/perm"
|
||||||
"code.gitea.io/gitea/models/unittest"
|
"code.gitea.io/gitea/models/unittest"
|
||||||
|
@ -230,7 +229,7 @@ func TestOwnerTeamsEdit(t *testing.T) {
|
||||||
org := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 3, Type: user_model.UserTypeOrganization})
|
org := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 3, Type: user_model.UserTypeOrganization})
|
||||||
session := loginUser(t, user1.Name)
|
session := loginUser(t, user1.Name)
|
||||||
|
|
||||||
team := unittest.AssertExistsAndLoadBean(t, &organization.Team{OrgID: org.ID, Name: org_model.OwnerTeamName})
|
team := unittest.AssertExistsAndLoadBean(t, &org_model.Team{OrgID: org.ID, Name: org_model.OwnerTeamName})
|
||||||
assert.EqualValues(t, perm.AccessModeOwner, team.AccessMode)
|
assert.EqualValues(t, perm.AccessModeOwner, team.AccessMode)
|
||||||
assert.EqualValues(t, "", team.Description)
|
assert.EqualValues(t, "", team.Description)
|
||||||
assert.NoError(t, team.LoadUnits(db.DefaultContext))
|
assert.NoError(t, team.LoadUnits(db.DefaultContext))
|
||||||
|
@ -247,7 +246,7 @@ func TestOwnerTeamsEdit(t *testing.T) {
|
||||||
session.MakeRequest(t, req, http.StatusSeeOther)
|
session.MakeRequest(t, req, http.StatusSeeOther)
|
||||||
|
|
||||||
// reload team
|
// reload team
|
||||||
team = unittest.AssertExistsAndLoadBean(t, &organization.Team{ID: team.ID})
|
team = unittest.AssertExistsAndLoadBean(t, &org_model.Team{ID: team.ID})
|
||||||
assert.EqualValues(t, perm.AccessModeOwner, team.AccessMode)
|
assert.EqualValues(t, perm.AccessModeOwner, team.AccessMode)
|
||||||
assert.EqualValues(t, org_model.OwnerTeamName, team.Name)
|
assert.EqualValues(t, org_model.OwnerTeamName, team.Name)
|
||||||
assert.EqualValues(t, "Just a description", team.Description)
|
assert.EqualValues(t, "Just a description", team.Description)
|
||||||
|
|
Loading…
Reference in a new issue