100% test coverage on account service!
This commit is contained in:
parent
5a540184c9
commit
8be785cd8b
5 changed files with 76 additions and 31 deletions
|
|
@ -99,20 +99,27 @@ func (repo *AccountRepositoryMemory) ChangeUsername(id string, username string)
|
|||
} else if account != nil && account.ID != id {
|
||||
return errors.New("Account with this username already exists")
|
||||
}
|
||||
|
||||
account, err := repo.GetByID(id)
|
||||
if err != nil { return err }
|
||||
if account == nil { return errors.New("Account does not exist") }
|
||||
|
||||
account.Username = username
|
||||
return nil
|
||||
}
|
||||
func (repo *AccountRepositoryMemory) ChangePassword(id string, password string) error {
|
||||
account, err := repo.GetByID(id)
|
||||
if err != nil { return err }
|
||||
if account == nil { return errors.New("Account does not exist") }
|
||||
|
||||
account.Password = password
|
||||
return nil
|
||||
}
|
||||
func (repo *AccountRepositoryMemory) ChangeEmail(id string, email string) error {
|
||||
account, err := repo.GetByID(id)
|
||||
if err != nil { return err }
|
||||
if account == nil { return errors.New("Account does not exist") }
|
||||
|
||||
account.Email.Valid = true
|
||||
account.Email.String = email
|
||||
return nil
|
||||
|
|
@ -120,6 +127,8 @@ func (repo *AccountRepositoryMemory) ChangeEmail(id string, email string) error
|
|||
func (repo *AccountRepositoryMemory) RemoveEmail(id string) error {
|
||||
account, err := repo.GetByID(id)
|
||||
if err != nil { return err }
|
||||
if account == nil { return errors.New("Account does not exist") }
|
||||
|
||||
account.Email.Valid = false
|
||||
account.Email.String = ""
|
||||
return nil
|
||||
|
|
@ -127,6 +136,8 @@ func (repo *AccountRepositoryMemory) RemoveEmail(id string) error {
|
|||
func (repo *AccountRepositoryMemory) ChangeAvatarURL(id string, avatarURL string) error {
|
||||
account, err := repo.GetByID(id)
|
||||
if err != nil { return err }
|
||||
if account == nil { return errors.New("Account does not exist") }
|
||||
|
||||
account.AvatarURL.Valid = true
|
||||
account.AvatarURL.String = avatarURL
|
||||
return nil
|
||||
|
|
@ -134,6 +145,8 @@ func (repo *AccountRepositoryMemory) ChangeAvatarURL(id string, avatarURL string
|
|||
func (repo *AccountRepositoryMemory) RemoveAvatar(id string) error {
|
||||
account, err := repo.GetByID(id)
|
||||
if err != nil { return err }
|
||||
if account == nil { return errors.New("Account does not exist") }
|
||||
|
||||
account.AvatarURL.Valid = false
|
||||
account.AvatarURL.String = ""
|
||||
return nil
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue