1
0
Fork 0

Add integration tests for users

This commit is contained in:
Frédéric Guillot 2017-11-25 12:44:32 -08:00
parent 142e8b3e0c
commit ec0f642d5d
11 changed files with 267 additions and 33 deletions

View file

@ -27,6 +27,7 @@ func NewUser() *User {
return &User{Extra: make(map[string]string)}
}
// ValidateUserCreation validates new user.
func (u User) ValidateUserCreation() error {
if err := u.ValidateUserLogin(); err != nil {
return err
@ -39,6 +40,7 @@ func (u User) ValidateUserCreation() error {
return nil
}
// ValidateUserModification validates user for modification.
func (u User) ValidateUserModification() error {
if u.Username == "" {
return errors.New("The username is mandatory")
@ -48,9 +50,14 @@ func (u User) ValidateUserModification() error {
return err
}
if err := ValidateTheme(u.Theme); err != nil {
return err
}
return nil
}
// ValidateUserLogin validates user credential requirements.
func (u User) ValidateUserLogin() error {
if u.Username == "" {
return errors.New("The username is mandatory")
@ -63,6 +70,7 @@ func (u User) ValidateUserLogin() error {
return nil
}
// ValidatePassword validates user password requirements.
func (u User) ValidatePassword() error {
if u.Password != "" && len(u.Password) < 6 {
return errors.New("The password must have at least 6 characters")