photoprism/internal/entity/auth_user_fixtures_test.go
Michael Mayer 85561547cc Auth: Add "PHOTOPRISM_ADMIN_USER" option and refactor user table #98
Signed-off-by: Michael Mayer <michael@photoprism.app>
2022-09-02 21:30:50 +02:00

35 lines
872 B
Go

package entity
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestUserMap_Get(t *testing.T) {
t.Run("get existing user", func(t *testing.T) {
r := UserFixtures.Get("alice")
assert.Equal(t, "alice", r.Username)
assert.Equal(t, "alice", r.UserName())
assert.IsType(t, User{}, r)
})
t.Run("get not existing user", func(t *testing.T) {
r := UserFixtures.Get("monstera")
assert.Equal(t, "", r.Username)
assert.Equal(t, "", r.UserName())
assert.IsType(t, User{}, r)
})
}
func TestUserMap_Pointer(t *testing.T) {
t.Run("get existing user", func(t *testing.T) {
r := UserFixtures.Pointer("alice")
assert.Equal(t, "alice", r.Username)
assert.IsType(t, &User{}, r)
})
t.Run("get not existing user", func(t *testing.T) {
r := UserFixtures.Pointer("monstera")
assert.Equal(t, "", r.Username)
assert.IsType(t, &User{}, r)
})
}