2021-08-26 18:02:53 +02:00
|
|
|
package entity
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
2021-08-28 13:55:37 +02:00
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
2021-08-26 18:02:53 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestUserMap_Get(t *testing.T) {
|
|
|
|
t.Run("get existing user", func(t *testing.T) {
|
|
|
|
r := UserFixtures.Get("alice")
|
2022-09-02 21:30:50 +02:00
|
|
|
assert.Equal(t, "alice", r.Username)
|
|
|
|
assert.Equal(t, "alice", r.UserName())
|
2021-08-26 18:02:53 +02:00
|
|
|
assert.IsType(t, User{}, r)
|
|
|
|
})
|
|
|
|
t.Run("get not existing user", func(t *testing.T) {
|
|
|
|
r := UserFixtures.Get("monstera")
|
2022-09-02 21:30:50 +02:00
|
|
|
assert.Equal(t, "", r.Username)
|
|
|
|
assert.Equal(t, "", r.UserName())
|
2021-08-26 18:02:53 +02:00
|
|
|
assert.IsType(t, User{}, r)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestUserMap_Pointer(t *testing.T) {
|
|
|
|
t.Run("get existing user", func(t *testing.T) {
|
|
|
|
r := UserFixtures.Pointer("alice")
|
2022-09-02 21:30:50 +02:00
|
|
|
assert.Equal(t, "alice", r.Username)
|
2021-08-26 18:02:53 +02:00
|
|
|
assert.IsType(t, &User{}, r)
|
|
|
|
})
|
|
|
|
t.Run("get not existing user", func(t *testing.T) {
|
|
|
|
r := UserFixtures.Pointer("monstera")
|
2022-09-02 21:30:50 +02:00
|
|
|
assert.Equal(t, "", r.Username)
|
2021-08-26 18:02:53 +02:00
|
|
|
assert.IsType(t, &User{}, r)
|
|
|
|
})
|
|
|
|
}
|