You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
999 B

  1. // Copyright 2017 The Gitea Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. package integrations
  5. import (
  6. "net/http"
  7. "testing"
  8. "code.gitea.io/gitea/models"
  9. api "code.gitea.io/sdk/gitea"
  10. "github.com/stretchr/testify/assert"
  11. )
  12. func TestAPITeam(t *testing.T) {
  13. prepareTestEnv(t)
  14. teamUser := models.AssertExistsAndLoadBean(t, &models.TeamUser{}).(*models.TeamUser)
  15. team := models.AssertExistsAndLoadBean(t, &models.Team{ID: teamUser.TeamID}).(*models.Team)
  16. user := models.AssertExistsAndLoadBean(t, &models.User{ID: teamUser.UID}).(*models.User)
  17. session := loginUser(t, user.Name)
  18. token := getTokenForLoggedInUser(t, session)
  19. req := NewRequestf(t, "GET", "/api/v1/teams/%d?token="+token, teamUser.TeamID)
  20. resp := session.MakeRequest(t, req, http.StatusOK)
  21. var apiTeam api.Team
  22. DecodeJSON(t, resp, &apiTeam)
  23. assert.EqualValues(t, team.ID, apiTeam.ID)
  24. assert.Equal(t, team.Name, apiTeam.Name)
  25. }