summaryrefslogtreecommitdiffstats
path: root/api/command_test.go
diff options
context:
space:
mode:
authorBrian Olecki <bolecki019@gmail.com>2016-11-15 10:43:16 -0500
committerenahum <nahumhbl@gmail.com>2016-11-15 12:43:16 -0300
commit6297922ab9561dbf774ab5d51619abfc4a411e40 (patch)
tree84bbced4d8282f5e8af957164d6e92ae50238011 /api/command_test.go
parent1f241af48a9554b6865d1ac79b4261341ab9b3f3 (diff)
downloadchat-6297922ab9561dbf774ab5d51619abfc4a411e40.tar.gz
chat-6297922ab9561dbf774ab5d51619abfc4a411e40.tar.bz2
chat-6297922ab9561dbf774ab5d51619abfc4a411e40.zip
Add support for editing slash commands (#4335)
Diffstat (limited to 'api/command_test.go')
-rw-r--r--api/command_test.go39
1 files changed, 39 insertions, 0 deletions
diff --git a/api/command_test.go b/api/command_test.go
index 7a78d350d..45268a9a5 100644
--- a/api/command_test.go
+++ b/api/command_test.go
@@ -120,6 +120,45 @@ func TestListTeamCommands(t *testing.T) {
}
}
+func TestUpdateCommand(t *testing.T) {
+ th := Setup().InitSystemAdmin()
+ Client := th.SystemAdminClient
+ user := th.SystemAdminUser
+ team := th.SystemAdminTeam
+
+ enableCommands := *utils.Cfg.ServiceSettings.EnableCommands
+ defer func() {
+ utils.Cfg.ServiceSettings.EnableCommands = &enableCommands
+ }()
+ *utils.Cfg.ServiceSettings.EnableCommands = true
+
+ cmd1 := &model.Command{
+ CreatorId: user.Id,
+ TeamId: team.Id,
+ URL: "http://nowhere.com",
+ Method: model.COMMAND_METHOD_POST,
+ Trigger: "trigger"}
+
+ cmd1 = Client.Must(Client.CreateCommand(cmd1)).Data.(*model.Command)
+
+ cmd2 := &model.Command{
+ CreatorId: user.Id,
+ TeamId: team.Id,
+ URL: "http://nowhere.com",
+ Method: model.COMMAND_METHOD_POST,
+ Trigger: "trigger2",
+ Token: cmd1.Token,
+ Id: cmd1.Id}
+
+ if result, err := Client.UpdateCommand(cmd2); err != nil {
+ t.Fatal(err)
+ } else {
+ if result.Data.(*model.Command).Trigger == cmd1.Trigger {
+ t.Fatal("update didn't work properly")
+ }
+ }
+}
+
func TestRegenToken(t *testing.T) {
th := Setup().InitSystemAdmin()
Client := th.SystemAdminClient