diff options
author | Derrick Anderson <derrick@andersonwebstudio.com> | 2018-04-17 09:37:20 -0400 |
---|---|---|
committer | Derrick Anderson <derrick@andersonwebstudio.com> | 2018-04-17 09:37:20 -0400 |
commit | 58e559da396ccb0f170c4304974c26d728cab637 (patch) | |
tree | a0e08fec9446ac58fb0e460f48446fc117fc3e66 /cmd/commands/user_test.go | |
parent | 885b8e51f3c0b0a4d98814b43917670c2193b3a4 (diff) | |
download | chat-58e559da396ccb0f170c4304974c26d728cab637.tar.gz chat-58e559da396ccb0f170c4304974c26d728cab637.tar.bz2 chat-58e559da396ccb0f170c4304974c26d728cab637.zip |
Add MM9720 changes back in for master merge
Diffstat (limited to 'cmd/commands/user_test.go')
-rw-r--r-- | cmd/commands/user_test.go | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/cmd/commands/user_test.go b/cmd/commands/user_test.go index 960ac3878..a1081c5d3 100644 --- a/cmd/commands/user_test.go +++ b/cmd/commands/user_test.go @@ -9,6 +9,7 @@ import ( "github.com/mattermost/mattermost-server/api" "github.com/mattermost/mattermost-server/cmd" "github.com/mattermost/mattermost-server/model" + "github.com/stretchr/testify/require" ) func TestCreateUserWithTeam(t *testing.T) { @@ -80,3 +81,30 @@ func TestMakeUserActiveAndInactive(t *testing.T) { // activate the inactive user cmd.CheckCommand(t, "user", "activate", th.BasicUser.Email) } + +func TestChangeUserEmail(t *testing.T) { + th := api.Setup().InitBasic() + defer th.TearDown() + + newEmail := model.NewId() + "@mattermost-test.com" + + cmd.CheckCommand(t, "user", "email", th.BasicUser.Username, newEmail) + if result := <-th.App.Srv.Store.User().GetByEmail(th.BasicUser.Email); result.Err == nil { + t.Fatal("should've updated to the new email") + } + if result := <-th.App.Srv.Store.User().GetByEmail(newEmail); result.Err != nil { + t.Fatal() + } else { + user := result.Data.(*model.User) + if user.Email != newEmail { + t.Fatal("should've updated to the new email") + } + } + + // should fail because using an invalid email + require.Error(t, cmd.RunCommand(t, "user", "email", th.BasicUser.Username, "wrong$email.com")) + + // should fail because user not found + require.Error(t, cmd.RunCommand(t, "user", "email", "invalidUser", newEmail)) + +} |