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

api_team_test.go 1.0 kB

12345678910111213141516171819202122232425262728293031323334
  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. "fmt"
  7. "net/http"
  8. "testing"
  9. "code.gitea.io/gitea/models"
  10. api "code.gitea.io/sdk/gitea"
  11. "github.com/stretchr/testify/assert"
  12. )
  13. func TestAPITeam(t *testing.T) {
  14. prepareTestEnv(t)
  15. teamUser := models.AssertExistsAndLoadBean(t, &models.TeamUser{}).(*models.TeamUser)
  16. team := models.AssertExistsAndLoadBean(t, &models.Team{ID: teamUser.TeamID}).(*models.Team)
  17. user := models.AssertExistsAndLoadBean(t, &models.User{ID: teamUser.UID}).(*models.User)
  18. session := loginUser(t, user.Name)
  19. url := fmt.Sprintf("/api/v1/teams/%d", teamUser.TeamID)
  20. req := NewRequest(t, "GET", url)
  21. resp := session.MakeRequest(t, req)
  22. assert.EqualValues(t, http.StatusOK, resp.HeaderCode)
  23. var apiTeam api.Team
  24. DecodeJSON(t, resp, &apiTeam)
  25. assert.EqualValues(t, team.ID, apiTeam.ID)
  26. assert.Equal(t, team.Name, apiTeam.Name)
  27. }