From 7f90e3615b98816c5eafcdf4623e66d03bc7085f Mon Sep 17 00:00:00 2001 From: Timo Volkmann Date: Thu, 12 Aug 2021 15:13:15 +0200 Subject: [PATCH] Auth: Add tests for finding users by uid #98 --- internal/entity/user_test.go | 39 ++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/internal/entity/user_test.go b/internal/entity/user_test.go index d2ce499e0..f4f29d19f 100644 --- a/internal/entity/user_test.go +++ b/internal/entity/user_test.go @@ -183,6 +183,45 @@ func TestFindUserByUID(t *testing.T) { t.Fatal("result should be nil") } }) + + t.Run("alice", func(t *testing.T) { + m := FindUserByUID("uqxetse3cy5eo9z2") + + if m == nil { + t.Fatal("result should not be nil") + } + + assert.Equal(t, 5, m.ID) + assert.Equal(t, "uqxetse3cy5eo9z2", m.UserUID) + assert.Equal(t, "alice", m.UserName) + assert.Equal(t, "Alice", m.FullName) + assert.Equal(t, "alice@example.com", m.PrimaryEmail) + assert.True(t, m.RoleAdmin) + assert.False(t, m.RoleGuest) + assert.False(t, m.UserDisabled) + assert.NotEmpty(t, m.CreatedAt) + assert.NotEmpty(t, m.UpdatedAt) + }) + + t.Run("bob", func(t *testing.T) { + m := FindUserByUID("uqxc08w3d0ej2283") + + if m == nil { + t.Fatal("result should not be nil") + } + + assert.Equal(t, 7, m.ID) + assert.Equal(t, "uqxc08w3d0ej2283", m.UserUID) + assert.Equal(t, "bob", m.UserName) + assert.Equal(t, "Bob", m.FullName) + assert.Equal(t, "bob@example.com", m.PrimaryEmail) + assert.False(t, m.RoleAdmin) + assert.False(t, m.RoleGuest) + assert.False(t, m.UserDisabled) + assert.NotEmpty(t, m.CreatedAt) + assert.NotEmpty(t, m.UpdatedAt) + }) + } func TestUser_String(t *testing.T) {