github.com/gigforks/mattermost-server@v4.9.1-0.20180619094218-800d97fa55d0+incompatible/api/command_me_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 TestMeCommand(t *testing.T) {
    14  	th := Setup().InitBasic()
    15  	defer th.TearDown()
    16  
    17  	Client := th.BasicClient
    18  	channel := th.BasicChannel
    19  
    20  	testString := "/me hello"
    21  
    22  	r1 := Client.Must(Client.Command(channel.Id, testString)).Data.(*model.CommandResponse)
    23  	if r1 == nil {
    24  		t.Fatal("Command failed to execute")
    25  	}
    26  
    27  	time.Sleep(100 * time.Millisecond)
    28  
    29  	p1 := Client.Must(Client.GetPosts(channel.Id, 0, 2, "")).Data.(*model.PostList)
    30  	if len(p1.Order) != 2 {
    31  		t.Fatal("Command failed to send")
    32  	} else {
    33  		if p1.Posts[p1.Order[0]].Message != `*hello*` {
    34  			t.Log(p1.Posts[p1.Order[0]].Message)
    35  			t.Fatal("invalid shrug response")
    36  		}
    37  	}
    38  }