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.

31 lines
940 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. req := NewRequestf(t, "GET", "/api/v1/teams/%d", teamUser.TeamID)
  19. resp := session.MakeRequest(t, req, http.StatusOK)
  20. var apiTeam api.Team
  21. DecodeJSON(t, resp, &apiTeam)
  22. assert.EqualValues(t, team.ID, apiTeam.ID)
  23. assert.Equal(t, team.Name, apiTeam.Name)
  24. }