PLT-1527 Add a slash command to set yourself away (#3752)
* added handlers for slash commands * added manual status persistance * added tests * removed extra debug output and comments * rebase - fixing the PR * making echo messages after slash commands ephemeral
Этот коммит содержится в:
коммит произвёл
Joram Wilander
родитель
db660bdf9c
Коммит
dc09b7781a
40
api/command_statuses_test.go
Обычный файл
40
api/command_statuses_test.go
Обычный файл
@@ -0,0 +1,40 @@
|
||||
// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved.
|
||||
// See License.txt for license information.
|
||||
|
||||
package api
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/mattermost/platform/model"
|
||||
)
|
||||
|
||||
func TestStatusCommands(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
commandAndTest(t, th, "away")
|
||||
commandAndTest(t, th, "offline")
|
||||
commandAndTest(t, th, "online")
|
||||
}
|
||||
|
||||
func commandAndTest(t *testing.T, th *TestHelper, status string) {
|
||||
Client := th.BasicClient
|
||||
channel := th.BasicChannel
|
||||
user := th.BasicUser
|
||||
|
||||
r1 := Client.Must(Client.Command(channel.Id, "/"+status, false)).Data.(*model.CommandResponse)
|
||||
if r1 == nil {
|
||||
t.Fatal("Command failed to execute")
|
||||
}
|
||||
|
||||
time.Sleep(300 * time.Millisecond)
|
||||
|
||||
statuses := Client.Must(Client.GetStatuses()).Data.(map[string]string)
|
||||
|
||||
if status == "offline" {
|
||||
status = ""
|
||||
}
|
||||
if statuses[user.Id] != status {
|
||||
t.Fatal("Error setting status " + status)
|
||||
}
|
||||
}
|
||||
Ссылка в новой задаче
Block a user