feat(API): optional display name on users
This commit is contained in:
1 parent
792aba433d
commit
7aae704d0a
22 files changed
+1051
-40
No files matched your search
@@ -44,6 +44,8 @@ type mockUserRepo struct {
|
||||
resetPasswordCalls int
|
||||
lastResetPasswordUserId uint32
|
||||
lastResetPasswordHash string
|
||||
updateDisplayNameCalls int
|
||||
lastUpdateDisplayName string
|
||||
}
|
||||
|
||||
func newMockUserRepo() *mockUserRepo {
|
||||
@@ -210,6 +212,21 @@ func (m *mockUserRepo) ResetPassword(userId uint32, hashedPassword string) (user
|
||||
return u, nil
|
||||
}
|
||||
|
||||
func (m *mockUserRepo) UpdateDisplayName(userId uint32, displayName string) (user.User, error) {
|
||||
m.updateDisplayNameCalls++
|
||||
m.lastUpdateDisplayName = displayName
|
||||
if err := m.fail.trigger("UpdateDisplayName"); err != nil {
|
||||
return user.User{}, err
|
||||
}
|
||||
u, ok := m.users[userId]
|
||||
if !ok {
|
||||
return user.User{}, user.ErrUserNotFound
|
||||
}
|
||||
u.DisplayName = displayName
|
||||
m.users[userId] = u
|
||||
return u, nil
|
||||
}
|
||||
|
||||
var _ user.Repository = &mockUserRepo{}
|
||||
|
||||
func TestCreateUser(t *testing.T) {
|
||||
|
||||
Reference in new issue
Block a user