github.com/coincircle/mattermost-server@v4.8.1-0.20180321182714-9d701c704416+incompatible/api/command_shrug_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 TestShrugCommand(t *testing.T) {
    14  	th := Setup().InitBasic()
    15  	defer th.TearDown()
    16  
    17  	Client := th.BasicClient
    18  	channel := th.BasicChannel
    19  
    20  	testString := "/shrug"
    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 != `¯\\\_(ツ)\_/¯` {
    34  			t.Log(p1.Posts[p1.Order[0]].Message)
    35  			t.Fatal("invalid shrug reponse")
    36  		}
    37  	}
    38  }