100% test coverage on account service!
This commit is contained in:
parent
5a540184c9
commit
8be785cd8b
5 changed files with 76 additions and 31 deletions
|
|
@ -60,26 +60,6 @@ func (s *AccountService) Create(
|
|||
return id, nil
|
||||
}
|
||||
|
||||
// Intended for large profile updates. For smaller adjusments,
|
||||
// more specialised Change* and Remove* functions should be used.
|
||||
func (s *AccountService) Update(
|
||||
id string,
|
||||
username string,
|
||||
password string,
|
||||
email *string,
|
||||
avatarUrl *string,
|
||||
) error {
|
||||
if len(username) == 0 { return errors.New("Username cannot be empty") }
|
||||
if len(password) == 0 { return errors.New("Password cannot be empty") }
|
||||
if email != nil && len(*email) == 0 { return errors.New("Email cannot be empty") }
|
||||
|
||||
if err := s.repo.Update(id, username, password, email, avatarUrl); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
s.log.Printf("Updated account '%s' (%s)", username, id)
|
||||
return nil
|
||||
}
|
||||
func (s *AccountService) ChangeUsername(id string, username string) error {
|
||||
if len(username) == 0 { return errors.New("Username cannot be empty") }
|
||||
if err := s.repo.ChangeUsername(id, username); err != nil {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue