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.

35 lines
1.0 KiB

  1. // Copyright 2019 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. "time"
  9. "code.gitea.io/gitea/models"
  10. "code.gitea.io/gitea/modules/convert"
  11. api "code.gitea.io/gitea/modules/structs"
  12. "github.com/stretchr/testify/assert"
  13. )
  14. func TestAPITeamUser(t *testing.T) {
  15. prepareTestEnv(t)
  16. normalUsername := "user2"
  17. session := loginUser(t, normalUsername)
  18. token := getTokenForLoggedInUser(t, session)
  19. req := NewRequest(t, "GET", "/api/v1/teams/1/members/user1?token="+token)
  20. session.MakeRequest(t, req, http.StatusNotFound)
  21. req = NewRequest(t, "GET", "/api/v1/teams/1/members/user2?token="+token)
  22. resp := session.MakeRequest(t, req, http.StatusOK)
  23. var user2 *api.User
  24. DecodeJSON(t, resp, &user2)
  25. user2.Created = user2.Created.In(time.Local)
  26. user := models.AssertExistsAndLoadBean(t, &models.User{Name: "user2"}).(*models.User)
  27. assert.Equal(t, convert.ToUser(user, true, false), user2)
  28. }