Fork to maintain patches against the official gitea for https://code.ceondo.com https://github.com/go-gitea/gitea

api_team_test.go 940B

1234567891011121314151617181920212223242526272829303132
  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. }