diff options
author | Derrick Anderson <derrick@andersonwebstudio.com> | 2018-05-15 11:19:27 -0400 |
---|---|---|
committer | Derrick Anderson <derrick@andersonwebstudio.com> | 2018-05-15 11:19:27 -0400 |
commit | 228bc4bd1dc84bf741978711b680a06dd9d67613 (patch) | |
tree | 5dae4ebc13fca2749b4278bba772ec13c0924e03 /cmd/commands | |
parent | a1656dffa98fbc8865e476b214e4e0c562547d39 (diff) | |
parent | 9301e575c880970dc5642605adcc37903d176227 (diff) | |
download | chat-228bc4bd1dc84bf741978711b680a06dd9d67613.tar.gz chat-228bc4bd1dc84bf741978711b680a06dd9d67613.tar.bz2 chat-228bc4bd1dc84bf741978711b680a06dd9d67613.zip |
Merge remote-tracking branch 'origin/release-4.10' into merge410rc5
Diffstat (limited to 'cmd/commands')
-rw-r--r-- | cmd/commands/user.go | 6 | ||||
-rw-r--r-- | cmd/commands/user_test.go | 12 |
2 files changed, 17 insertions, 1 deletions
diff --git a/cmd/commands/user.go b/cmd/commands/user.go index da3fb454b..7397cfb2e 100644 --- a/cmd/commands/user.go +++ b/cmd/commands/user.go @@ -422,6 +422,10 @@ func updateUserEmailCmdF(command *cobra.Command, args []string) error { } defer a.Shutdown() + if len(args) != 2 { + return errors.New("Expected two arguments. See help text for details.") + } + newEmail := args[1] if !model.IsValidEmail(newEmail) { @@ -440,7 +444,7 @@ func updateUserEmailCmdF(command *cobra.Command, args []string) error { user.Email = newEmail _, errUpdate := a.UpdateUser(user, true) if errUpdate != nil { - return errUpdate + return errors.New(errUpdate.Message) } return nil diff --git a/cmd/commands/user_test.go b/cmd/commands/user_test.go index a1081c5d3..8691ac803 100644 --- a/cmd/commands/user_test.go +++ b/cmd/commands/user_test.go @@ -104,7 +104,19 @@ func TestChangeUserEmail(t *testing.T) { // should fail because using an invalid email require.Error(t, cmd.RunCommand(t, "user", "email", th.BasicUser.Username, "wrong$email.com")) + // should fail because missing one parameter + require.Error(t, cmd.RunCommand(t, "user", "email", th.BasicUser.Username)) + + // should fail because missing both parameters + require.Error(t, cmd.RunCommand(t, "user", "email")) + + // should fail because have more than 2 parameters + require.Error(t, cmd.RunCommand(t, "user", "email", th.BasicUser.Username, "new@email.com", "extra!")) + // should fail because user not found require.Error(t, cmd.RunCommand(t, "user", "email", "invalidUser", newEmail)) + // should fail because email already in use + require.Error(t, cmd.RunCommand(t, "user", "email", th.BasicUser.Username, th.BasicUser2.Email)) + } |