github.com/gigforks/mattermost-server@v4.9.1-0.20180619094218-800d97fa55d0+incompatible/api/command_echo_test.go (about)

     1  // Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
     2  // See License.txt for license information.
     3  
     4  package api
     5  
     6  import (
     7  	"testing"
     8  	"time"
     9  
    10  	"github.com/mattermost/mattermost-server/model"
    11  )
    12  
    13  func TestEchoCommand(t *testing.T) {
    14  	th := Setup().InitBasic()
    15  	defer th.TearDown()
    16  
    17  	Client := th.BasicClient
    18  	channel1 := th.BasicChannel
    19  
    20  	echoTestString := "/echo test"
    21  
    22  	if r1 := Client.Must(Client.Command(channel1.Id, echoTestString)).Data.(*model.CommandResponse); r1 == nil {
    23  		t.Fatal("Echo command failed to execute")
    24  	}
    25  
    26  	if r1 := Client.Must(Client.Command(channel1.Id, "/echo ")).Data.(*model.CommandResponse); r1 == nil {
    27  		t.Fatal("Echo command failed to execute")
    28  	}
    29  
    30  	time.Sleep(100 * time.Millisecond)
    31  
    32  	p1 := Client.Must(Client.GetPosts(channel1.Id, 0, 2, "")).Data.(*model.PostList)
    33  	if len(p1.Order) != 2 {
    34  		t.Fatal("Echo command failed to send")
    35  	}
    36  }