100% test coverage on account service!

This commit is contained in:
ari melody 2026-07-31 04:46:32 +01:00
parent 5a540184c9
commit 8be785cd8b
Signed by: ari
GPG key ID: CF99829C92678188
5 changed files with 76 additions and 31 deletions

View file

@ -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 {