diff --git a/db/users/create.go b/db/users/create.go index b48546cd..aa940df1 100644 --- a/db/users/create.go +++ b/db/users/create.go @@ -22,7 +22,7 @@ func CreateUser(ctx context.Context, app, addonUUID, username string, readonly b return nil } - if usernameValidation, ok := IsUsernameValid(username); !ok { + if usernameValidation, ok := isUsernameValid(username); !ok { io.Error(usernameValidation) return nil } diff --git a/db/users/update_password.go b/db/users/update_password.go index 328cafa9..6d893581 100644 --- a/db/users/update_password.go +++ b/db/users/update_password.go @@ -21,7 +21,7 @@ func UpdateUserPassword(ctx context.Context, app, addonUUID, username string) er return nil } - if usernameValidation, ok := IsUsernameValid(username); !ok { + if usernameValidation, ok := isUsernameValid(username); !ok { io.Error(usernameValidation) return nil } diff --git a/db/users/utils.go b/db/users/utils.go index c5439b4e..0cb3efc0 100644 --- a/db/users/utils.go +++ b/db/users/utils.go @@ -49,7 +49,7 @@ func askForPasswordWithRetry(ctx context.Context, remainingRetries int) (string, return "", "", errors.Wrap(ctx, err, "ask for password") } - passwordValidation, ok := IsPasswordValid(password, confirmedPassword) + passwordValidation, ok := isPasswordValid(password, confirmedPassword) if !ok { if remainingRetries == 1 { return "", "", errors.Newf(ctx, "%s. Too many retries", passwordValidation) @@ -79,7 +79,7 @@ func askForPassword(ctx context.Context) (string, string, error) { return string(password), string(confirmedPassword), nil } -func IsPasswordValid(password, confirmedPassword string) (string, bool) { +func isPasswordValid(password, confirmedPassword string) (string, bool) { if password == "" && confirmedPassword == "" { return "", true } @@ -93,7 +93,7 @@ func IsPasswordValid(password, confirmedPassword string) (string, bool) { return "", true } -func IsUsernameValid(username string) (string, bool) { +func isUsernameValid(username string) (string, bool) { if len(username) < 6 || len(username) > 32 { return "Name must contain between 6 and 32 characters", false } diff --git a/db/users/utils_test.go b/db/users/utils_test.go index ce74e16a..18bc87fc 100644 --- a/db/users/utils_test.go +++ b/db/users/utils_test.go @@ -1,14 +1,12 @@ -package users_test +package users import ( "testing" "github.com/stretchr/testify/assert" - - "github.com/Scalingo/cli/db/users" ) -func Test_IsPasswordValid(t *testing.T) { +func Test_isPasswordValid(t *testing.T) { testPasswords := map[string]struct { password string confirmation string @@ -55,7 +53,7 @@ func Test_IsPasswordValid(t *testing.T) { for name, testCase := range testPasswords { t.Run(name, func(t *testing.T) { - message, isValid := users.IsPasswordValid(testCase.password, testCase.confirmation) + message, isValid := isPasswordValid(testCase.password, testCase.confirmation) assert.Equal(t, testCase.expectedValidity, isValid) assert.Equal(t, testCase.expectedMessage, message) @@ -63,7 +61,7 @@ func Test_IsPasswordValid(t *testing.T) { } } -func Test_IsUsernameValid(t *testing.T) { +func Test_isUsernameValid(t *testing.T) { testPasswords := map[string]struct { username string expectedValidity bool @@ -98,7 +96,7 @@ func Test_IsUsernameValid(t *testing.T) { for name, testCase := range testPasswords { t.Run(name, func(t *testing.T) { - message, isValid := users.IsUsernameValid(testCase.username) + message, isValid := isUsernameValid(testCase.username) assert.Equal(t, testCase.expectedValidity, isValid) assert.Equal(t, testCase.expectedMessage, message)