mirror of
https://github.com/go-gitea/gitea
synced 2024-10-31 16:53:25 +01:00
d453533beb
* USER APIFormat -> ToUser * Migrate more and mark APIFormat deprecated * models.Comment APIFormat() -> convert.ToComment * models.Release APIFormat() -> convert.ToRelease * models.Attachments APIFormat() -> convert.ToReleaseAttachments * models.CommitStatus APIFormat() -> convert.ToCommitStatus * finish migration to convert.ToUser * Move Test * Imprufe Test * fix test Co-authored-by: techknowlogick <techknowlogick@gitea.io>
29 lines
722 B
Go
29 lines
722 B
Go
// Copyright 2020 The Gitea Authors. All rights reserved.
|
|
// Use of this source code is governed by a MIT-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package convert
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"code.gitea.io/gitea/models"
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestUser_ToUser(t *testing.T) {
|
|
|
|
user1 := models.AssertExistsAndLoadBean(t, &models.User{ID: 1, IsAdmin: true}).(*models.User)
|
|
|
|
apiUser := ToUser(user1, true, true)
|
|
assert.True(t, apiUser.IsAdmin)
|
|
|
|
user2 := models.AssertExistsAndLoadBean(t, &models.User{ID: 2, IsAdmin: false}).(*models.User)
|
|
|
|
apiUser = ToUser(user2, true, true)
|
|
assert.False(t, apiUser.IsAdmin)
|
|
|
|
apiUser = ToUser(user1, false, false)
|
|
assert.False(t, apiUser.IsAdmin)
|
|
}
|