1
0
mirror of https://github.com/go-gitea/gitea.git synced 2024-12-04 14:46:57 -05:00

Add test for api team orgnization (#24699)

Co-authored-by: Giteabot <teabot@gitea.io>
This commit is contained in:
Lunny Xiao 2023-05-14 05:26:35 +08:00 committed by GitHub
parent 8a8b753647
commit 68081c4721
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -29,6 +29,7 @@ func TestAPITeam(t *testing.T) {
teamUser := unittest.AssertExistsAndLoadBean(t, &organization.TeamUser{ID: 1}) teamUser := unittest.AssertExistsAndLoadBean(t, &organization.TeamUser{ID: 1})
team := unittest.AssertExistsAndLoadBean(t, &organization.Team{ID: teamUser.TeamID}) team := unittest.AssertExistsAndLoadBean(t, &organization.Team{ID: teamUser.TeamID})
org := unittest.AssertExistsAndLoadBean(t, &organization.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)
@ -40,6 +41,7 @@ func TestAPITeam(t *testing.T) {
DecodeJSON(t, resp, &apiTeam) DecodeJSON(t, resp, &apiTeam)
assert.EqualValues(t, team.ID, apiTeam.ID) assert.EqualValues(t, team.ID, apiTeam.ID)
assert.Equal(t, team.Name, apiTeam.Name) assert.Equal(t, team.Name, apiTeam.Name)
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, &organization.TeamUser{ID: 3})
@ -58,7 +60,7 @@ func TestAPITeam(t *testing.T) {
session = loginUser(t, user.Name) session = loginUser(t, user.Name)
token = getTokenForLoggedInUser(t, session, auth_model.AccessTokenScopeAdminOrg) token = getTokenForLoggedInUser(t, session, auth_model.AccessTokenScopeAdminOrg)
org := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 6}) org = unittest.AssertExistsAndLoadBean(t, &organization.Organization{ID: 6})
// Create team. // Create team.
teamToCreate := &api.CreateTeamOption{ teamToCreate := &api.CreateTeamOption{