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.

user_test.go 722B

12345678910111213141516171819202122232425262728
  1. // Copyright 2020 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 convert
  5. import (
  6. "testing"
  7. "code.gitea.io/gitea/models"
  8. "github.com/stretchr/testify/assert"
  9. )
  10. func TestUser_ToUser(t *testing.T) {
  11. user1 := models.AssertExistsAndLoadBean(t, &models.User{ID: 1, IsAdmin: true}).(*models.User)
  12. apiUser := ToUser(user1, true, true)
  13. assert.True(t, apiUser.IsAdmin)
  14. user2 := models.AssertExistsAndLoadBean(t, &models.User{ID: 2, IsAdmin: false}).(*models.User)
  15. apiUser = ToUser(user2, true, true)
  16. assert.False(t, apiUser.IsAdmin)
  17. apiUser = ToUser(user1, false, false)
  18. assert.False(t, apiUser.IsAdmin)
  19. }