diff options
author | George Goldberg <george@gberg.me> | 2017-10-04 19:08:59 +0100 |
---|---|---|
committer | Chris <ccbrown112@gmail.com> | 2017-10-04 11:08:59 -0700 |
commit | f3fc6d11fa11c9b8c73554c79ca55470073bb098 (patch) | |
tree | 1c0fa5181315bf2da312f7c832ae16f360d43d16 /app/command_test.go | |
parent | e16bdf8d1d4d2972be4e89cbc9c4dbef134895ba (diff) | |
download | chat-f3fc6d11fa11c9b8c73554c79ca55470073bb098.tar.gz chat-f3fc6d11fa11c9b8c73554c79ca55470073bb098.tar.bz2 chat-f3fc6d11fa11c9b8c73554c79ca55470073bb098.zip |
PLT-7218: CLI to move slash commands between teams. (#7574)
Diffstat (limited to 'app/command_test.go')
-rw-r--r-- | app/command_test.go | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/app/command_test.go b/app/command_test.go new file mode 100644 index 000000000..be1da3ac7 --- /dev/null +++ b/app/command_test.go @@ -0,0 +1,46 @@ +// Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved. +// See License.txt for license information. + +package app + +import ( + "testing" + + "github.com/stretchr/testify/assert" + + "github.com/mattermost/mattermost-server/model" +) + +func TestMoveCommand(t *testing.T) { + th := Setup().InitBasic() + + sourceTeam := th.CreateTeam() + targetTeam := th.CreateTeam() + + command := &model.Command{} + command.CreatorId = model.NewId() + command.Method = model.COMMAND_METHOD_POST + command.TeamId = sourceTeam.Id + command.URL = "http://nowhere.com/" + command.Trigger = "trigger1" + + command, err := th.App.CreateCommand(command) + assert.Nil(t, err) + + defer func() { + th.App.PermanentDeleteTeam(sourceTeam) + th.App.PermanentDeleteTeam(targetTeam) + }() + + // Move a command and check the team is updated. + assert.Nil(t, th.App.MoveCommand(targetTeam, command)) + retrievedCommand, err := th.App.GetCommand(command.Id) + assert.Nil(t, err) + assert.EqualValues(t, targetTeam.Id, retrievedCommand.TeamId) + + // Move it to the team it's already in. Nothing should change. + assert.Nil(t, th.App.MoveCommand(targetTeam, command)) + retrievedCommand, err = th.App.GetCommand(command.Id) + assert.Nil(t, err) + assert.EqualValues(t, targetTeam.Id, retrievedCommand.TeamId) +} |