commands_test: use testify (#12950)
Этот коммит содержится в:
коммит произвёл
Ben Schumacher
родитель
2bcb4d9913
Коммит
f6f7a65659
@@ -9,6 +9,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/mattermost/mattermost-server/model"
|
"github.com/mattermost/mattermost-server/model"
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestEchoCommand(t *testing.T) {
|
func TestEchoCommand(t *testing.T) {
|
||||||
@@ -20,20 +21,16 @@ func TestEchoCommand(t *testing.T) {
|
|||||||
|
|
||||||
echoTestString := "/echo test"
|
echoTestString := "/echo test"
|
||||||
|
|
||||||
if r1 := Client.Must(Client.ExecuteCommand(channel1.Id, echoTestString)).(*model.CommandResponse); r1 == nil {
|
r1 := Client.Must(Client.ExecuteCommand(channel1.Id, echoTestString)).(*model.CommandResponse)
|
||||||
t.Fatal("Echo command failed to execute")
|
require.NotNil(t, r1, "Echo command failed to execute")
|
||||||
}
|
|
||||||
|
|
||||||
if r1 := Client.Must(Client.ExecuteCommand(channel1.Id, "/echo ")).(*model.CommandResponse); r1 == nil {
|
r1 = Client.Must(Client.ExecuteCommand(channel1.Id, "/echo ")).(*model.CommandResponse)
|
||||||
t.Fatal("Echo command failed to execute")
|
require.NotNil(t, r1, "Echo command failed to execute")
|
||||||
}
|
|
||||||
|
|
||||||
time.Sleep(100 * time.Millisecond)
|
time.Sleep(100 * time.Millisecond)
|
||||||
|
|
||||||
p1 := Client.Must(Client.GetPostsForChannel(channel1.Id, 0, 2, "")).(*model.PostList)
|
p1 := Client.Must(Client.GetPostsForChannel(channel1.Id, 0, 2, "")).(*model.PostList)
|
||||||
if len(p1.Order) != 2 {
|
require.Len(t, p1.Order, 2, "Echo command failed to send")
|
||||||
t.Fatal("Echo command failed to send")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGroupmsgCommands(t *testing.T) {
|
func TestGroupmsgCommands(t *testing.T) {
|
||||||
@@ -57,25 +54,18 @@ func TestGroupmsgCommands(t *testing.T) {
|
|||||||
rs1 := Client.Must(Client.ExecuteCommand(th.BasicChannel.Id, "/groupmsg "+user2.Username+","+user3.Username)).(*model.CommandResponse)
|
rs1 := Client.Must(Client.ExecuteCommand(th.BasicChannel.Id, "/groupmsg "+user2.Username+","+user3.Username)).(*model.CommandResponse)
|
||||||
|
|
||||||
group1 := model.GetGroupNameFromUserIds([]string{user1.Id, user2.Id, user3.Id})
|
group1 := model.GetGroupNameFromUserIds([]string{user1.Id, user2.Id, user3.Id})
|
||||||
|
require.True(t, strings.HasSuffix(rs1.GotoLocation, "/"+team.Name+"/channels/"+group1), "failed to create group channel")
|
||||||
if !strings.HasSuffix(rs1.GotoLocation, "/"+team.Name+"/channels/"+group1) {
|
|
||||||
t.Fatal("failed to create group channel")
|
|
||||||
}
|
|
||||||
|
|
||||||
rs2 := Client.Must(Client.ExecuteCommand(th.BasicChannel.Id, "/groupmsg "+user3.Username+","+user4.Username+" foobar")).(*model.CommandResponse)
|
rs2 := Client.Must(Client.ExecuteCommand(th.BasicChannel.Id, "/groupmsg "+user3.Username+","+user4.Username+" foobar")).(*model.CommandResponse)
|
||||||
group2 := model.GetGroupNameFromUserIds([]string{user1.Id, user3.Id, user4.Id})
|
group2 := model.GetGroupNameFromUserIds([]string{user1.Id, user3.Id, user4.Id})
|
||||||
|
|
||||||
if !strings.HasSuffix(rs2.GotoLocation, "/"+team.Name+"/channels/"+group2) {
|
require.True(t, strings.HasSuffix(rs2.GotoLocation, "/"+team.Name+"/channels/"+group2), "failed to create second direct channel")
|
||||||
t.Fatal("failed to create second direct channel")
|
|
||||||
}
|
result := Client.Must(Client.SearchPosts(team.Id, "foobar", false)).(*model.PostList)
|
||||||
if result := Client.Must(Client.SearchPosts(team.Id, "foobar", false)).(*model.PostList); len(result.Order) == 0 {
|
require.NotEqual(t, 0, len(result.Order), "post did not get sent to direct message")
|
||||||
t.Fatal("post did not get sent to direct message")
|
|
||||||
}
|
|
||||||
|
|
||||||
rs3 := Client.Must(Client.ExecuteCommand(th.BasicChannel.Id, "/groupmsg "+user2.Username+","+user3.Username)).(*model.CommandResponse)
|
rs3 := Client.Must(Client.ExecuteCommand(th.BasicChannel.Id, "/groupmsg "+user2.Username+","+user3.Username)).(*model.CommandResponse)
|
||||||
if !strings.HasSuffix(rs3.GotoLocation, "/"+team.Name+"/channels/"+group1) {
|
require.True(t, strings.HasSuffix(rs3.GotoLocation, "/"+team.Name+"/channels/"+group1), "failed to go back to existing group channel")
|
||||||
t.Fatal("failed to go back to existing group channel")
|
|
||||||
}
|
|
||||||
|
|
||||||
Client.Must(Client.ExecuteCommand(th.BasicChannel.Id, "/groupmsg "+user2.Username+" foobar"))
|
Client.Must(Client.ExecuteCommand(th.BasicChannel.Id, "/groupmsg "+user2.Username+" foobar"))
|
||||||
Client.Must(Client.ExecuteCommand(th.BasicChannel.Id, "/groupmsg "+user2.Username+","+user3.Username+","+user4.Username+","+user5.Username+","+user6.Username+","+user7.Username+","+user8.Username+","+user9.Username+" foobar"))
|
Client.Must(Client.ExecuteCommand(th.BasicChannel.Id, "/groupmsg "+user2.Username+","+user3.Username+","+user4.Username+","+user5.Username+","+user6.Username+","+user7.Username+","+user8.Username+","+user9.Username+" foobar"))
|
||||||
@@ -91,19 +81,13 @@ func TestInvitePeopleCommand(t *testing.T) {
|
|||||||
channel := th.BasicChannel
|
channel := th.BasicChannel
|
||||||
|
|
||||||
r1 := Client.Must(Client.ExecuteCommand(channel.Id, "/invite_people test@example.com")).(*model.CommandResponse)
|
r1 := Client.Must(Client.ExecuteCommand(channel.Id, "/invite_people test@example.com")).(*model.CommandResponse)
|
||||||
if r1 == nil {
|
require.NotNil(t, r1, "Command failed to execute")
|
||||||
t.Fatal("Command failed to execute")
|
|
||||||
}
|
|
||||||
|
|
||||||
r2 := Client.Must(Client.ExecuteCommand(channel.Id, "/invite_people test1@example.com test2@example.com")).(*model.CommandResponse)
|
r2 := Client.Must(Client.ExecuteCommand(channel.Id, "/invite_people test1@example.com test2@example.com")).(*model.CommandResponse)
|
||||||
if r2 == nil {
|
require.NotNil(t, r2, "Command failed to execute")
|
||||||
t.Fatal("Command failed to execute")
|
|
||||||
}
|
|
||||||
|
|
||||||
r3 := Client.Must(Client.ExecuteCommand(channel.Id, "/invite_people")).(*model.CommandResponse)
|
r3 := Client.Must(Client.ExecuteCommand(channel.Id, "/invite_people")).(*model.CommandResponse)
|
||||||
if r3 == nil {
|
require.NotNil(t, r3, "Command failed to execute")
|
||||||
t.Fatal("Command failed to execute")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// also used to test /open (see command_open_test.go)
|
// also used to test /open (see command_open_test.go)
|
||||||
@@ -129,14 +113,10 @@ func testJoinCommands(t *testing.T, alias string) {
|
|||||||
channel3 := Client.Must(Client.CreateDirectChannel(th.BasicUser.Id, user2.Id)).(*model.Channel)
|
channel3 := Client.Must(Client.CreateDirectChannel(th.BasicUser.Id, user2.Id)).(*model.Channel)
|
||||||
|
|
||||||
rs5 := Client.Must(Client.ExecuteCommand(channel0.Id, "/"+alias+" "+channel2.Name)).(*model.CommandResponse)
|
rs5 := Client.Must(Client.ExecuteCommand(channel0.Id, "/"+alias+" "+channel2.Name)).(*model.CommandResponse)
|
||||||
if !strings.HasSuffix(rs5.GotoLocation, "/"+team.Name+"/channels/"+channel2.Name) {
|
require.True(t, strings.HasSuffix(rs5.GotoLocation, "/"+team.Name+"/channels/"+channel2.Name), "failed to join channel")
|
||||||
t.Fatal("failed to join channel")
|
|
||||||
}
|
|
||||||
|
|
||||||
rs6 := Client.Must(Client.ExecuteCommand(channel0.Id, "/"+alias+" "+channel3.Name)).(*model.CommandResponse)
|
rs6 := Client.Must(Client.ExecuteCommand(channel0.Id, "/"+alias+" "+channel3.Name)).(*model.CommandResponse)
|
||||||
if strings.HasSuffix(rs6.GotoLocation, "/"+team.Name+"/channels/"+channel3.Name) {
|
require.False(t, strings.HasSuffix(rs6.GotoLocation, "/"+team.Name+"/channels/"+channel3.Name), "should not have joined direct message channel")
|
||||||
t.Fatal("should not have joined direct message channel")
|
|
||||||
}
|
|
||||||
|
|
||||||
c1 := Client.Must(Client.GetChannelsForTeamForUser(th.BasicTeam.Id, th.BasicUser.Id, "")).([]*model.Channel)
|
c1 := Client.Must(Client.GetChannelsForTeamForUser(th.BasicTeam.Id, th.BasicUser.Id, "")).([]*model.Channel)
|
||||||
|
|
||||||
@@ -146,10 +126,7 @@ func testJoinCommands(t *testing.T, alias string) {
|
|||||||
found = true
|
found = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
require.True(t, found, "did not join channel")
|
||||||
if !found {
|
|
||||||
t.Fatal("did not join channel")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestJoinCommands(t *testing.T) {
|
func TestJoinCommands(t *testing.T) {
|
||||||
@@ -171,9 +148,7 @@ func TestLoadTestHelpCommands(t *testing.T) {
|
|||||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableTesting = true })
|
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableTesting = true })
|
||||||
|
|
||||||
rs := Client.Must(Client.ExecuteCommand(channel.Id, "/test help")).(*model.CommandResponse)
|
rs := Client.Must(Client.ExecuteCommand(channel.Id, "/test help")).(*model.CommandResponse)
|
||||||
if !strings.Contains(rs.Text, "Mattermost testing commands to help") {
|
require.True(t, strings.Contains(rs.Text, "Mattermost testing commands to help"), rs.Text)
|
||||||
t.Fatal(rs.Text)
|
|
||||||
}
|
|
||||||
|
|
||||||
time.Sleep(2 * time.Second)
|
time.Sleep(2 * time.Second)
|
||||||
}
|
}
|
||||||
@@ -193,9 +168,7 @@ func TestLoadTestSetupCommands(t *testing.T) {
|
|||||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableTesting = true })
|
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableTesting = true })
|
||||||
|
|
||||||
rs := Client.Must(Client.ExecuteCommand(channel.Id, "/test setup fuzz 1 1 1")).(*model.CommandResponse)
|
rs := Client.Must(Client.ExecuteCommand(channel.Id, "/test setup fuzz 1 1 1")).(*model.CommandResponse)
|
||||||
if rs.Text != "Created environment" {
|
require.Equal(t, "Created environment", rs.Text, rs.Text)
|
||||||
t.Fatal(rs.Text)
|
|
||||||
}
|
|
||||||
|
|
||||||
time.Sleep(2 * time.Second)
|
time.Sleep(2 * time.Second)
|
||||||
}
|
}
|
||||||
@@ -215,9 +188,7 @@ func TestLoadTestUsersCommands(t *testing.T) {
|
|||||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableTesting = true })
|
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableTesting = true })
|
||||||
|
|
||||||
rs := Client.Must(Client.ExecuteCommand(channel.Id, "/test users fuzz 1 2")).(*model.CommandResponse)
|
rs := Client.Must(Client.ExecuteCommand(channel.Id, "/test users fuzz 1 2")).(*model.CommandResponse)
|
||||||
if rs.Text != "Added users" {
|
require.Equal(t, "Added users", rs.Text, rs.Text)
|
||||||
t.Fatal(rs.Text)
|
|
||||||
}
|
|
||||||
|
|
||||||
time.Sleep(2 * time.Second)
|
time.Sleep(2 * time.Second)
|
||||||
}
|
}
|
||||||
@@ -237,9 +208,7 @@ func TestLoadTestChannelsCommands(t *testing.T) {
|
|||||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableTesting = true })
|
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableTesting = true })
|
||||||
|
|
||||||
rs := Client.Must(Client.ExecuteCommand(channel.Id, "/test channels fuzz 1 2")).(*model.CommandResponse)
|
rs := Client.Must(Client.ExecuteCommand(channel.Id, "/test channels fuzz 1 2")).(*model.CommandResponse)
|
||||||
if rs.Text != "Added channels" {
|
require.Equal(t, "Added channels", rs.Text, rs.Text)
|
||||||
t.Fatal(rs.Text)
|
|
||||||
}
|
|
||||||
|
|
||||||
time.Sleep(2 * time.Second)
|
time.Sleep(2 * time.Second)
|
||||||
}
|
}
|
||||||
@@ -259,9 +228,7 @@ func TestLoadTestPostsCommands(t *testing.T) {
|
|||||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableTesting = true })
|
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableTesting = true })
|
||||||
|
|
||||||
rs := Client.Must(Client.ExecuteCommand(channel.Id, "/test posts fuzz 2 3 2")).(*model.CommandResponse)
|
rs := Client.Must(Client.ExecuteCommand(channel.Id, "/test posts fuzz 2 3 2")).(*model.CommandResponse)
|
||||||
if rs.Text != "Added posts" {
|
require.Equal(t, "Added posts", rs.Text, rs.Text)
|
||||||
t.Fatal(rs.Text)
|
|
||||||
}
|
|
||||||
|
|
||||||
time.Sleep(2 * time.Second)
|
time.Sleep(2 * time.Second)
|
||||||
}
|
}
|
||||||
@@ -286,19 +253,13 @@ func TestLeaveCommands(t *testing.T) {
|
|||||||
channel3 := Client.Must(Client.CreateDirectChannel(th.BasicUser.Id, user2.Id)).(*model.Channel)
|
channel3 := Client.Must(Client.CreateDirectChannel(th.BasicUser.Id, user2.Id)).(*model.Channel)
|
||||||
|
|
||||||
rs1 := Client.Must(Client.ExecuteCommand(channel1.Id, "/leave")).(*model.CommandResponse)
|
rs1 := Client.Must(Client.ExecuteCommand(channel1.Id, "/leave")).(*model.CommandResponse)
|
||||||
if !strings.HasSuffix(rs1.GotoLocation, "/"+team.Name+"/channels/"+model.DEFAULT_CHANNEL) {
|
require.True(t, strings.HasSuffix(rs1.GotoLocation, "/"+team.Name+"/channels/"+model.DEFAULT_CHANNEL), "failed to leave open channel 1")
|
||||||
t.Fatal("failed to leave open channel 1")
|
|
||||||
}
|
|
||||||
|
|
||||||
rs2 := Client.Must(Client.ExecuteCommand(channel2.Id, "/leave")).(*model.CommandResponse)
|
rs2 := Client.Must(Client.ExecuteCommand(channel2.Id, "/leave")).(*model.CommandResponse)
|
||||||
if !strings.HasSuffix(rs2.GotoLocation, "/"+team.Name+"/channels/"+model.DEFAULT_CHANNEL) {
|
require.True(t, strings.HasSuffix(rs2.GotoLocation, "/"+team.Name+"/channels/"+model.DEFAULT_CHANNEL), "failed to leave private channel 1")
|
||||||
t.Fatal("failed to leave private channel 1")
|
|
||||||
}
|
|
||||||
|
|
||||||
_, err := Client.ExecuteCommand(channel3.Id, "/leave")
|
_, err := Client.ExecuteCommand(channel3.Id, "/leave")
|
||||||
if err == nil {
|
require.NotNil(t, err, "should fail leaving direct channel")
|
||||||
t.Fatal("should fail leaving direct channel")
|
|
||||||
}
|
|
||||||
|
|
||||||
cdata := Client.Must(Client.GetChannelsForTeamForUser(th.BasicTeam.Id, th.BasicUser.Id, "")).([]*model.Channel)
|
cdata := Client.Must(Client.GetChannelsForTeamForUser(th.BasicTeam.Id, th.BasicUser.Id, "")).([]*model.Channel)
|
||||||
|
|
||||||
@@ -308,16 +269,12 @@ func TestLeaveCommands(t *testing.T) {
|
|||||||
found = true
|
found = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
require.False(t, found, "did not leave right channels")
|
||||||
if found {
|
|
||||||
t.Fatal("did not leave right channels")
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, c := range cdata {
|
for _, c := range cdata {
|
||||||
if c.Name == model.DEFAULT_CHANNEL {
|
if c.Name == model.DEFAULT_CHANNEL {
|
||||||
if _, err := Client.RemoveUserFromChannel(c.Id, th.BasicUser.Id); err == nil {
|
_, err := Client.RemoveUserFromChannel(c.Id, th.BasicUser.Id)
|
||||||
t.Fatal("should have errored on leaving default channel")
|
require.NotNil(t, err, "should have errored on leaving default channel")
|
||||||
}
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -340,28 +297,19 @@ func TestMeCommand(t *testing.T) {
|
|||||||
testString := "/me hello"
|
testString := "/me hello"
|
||||||
|
|
||||||
r1 := Client.Must(Client.ExecuteCommand(channel.Id, testString)).(*model.CommandResponse)
|
r1 := Client.Must(Client.ExecuteCommand(channel.Id, testString)).(*model.CommandResponse)
|
||||||
if r1 == nil {
|
require.NotNil(t, r1, "Command failed to execute")
|
||||||
t.Fatal("Command failed to execute")
|
|
||||||
}
|
|
||||||
|
|
||||||
time.Sleep(100 * time.Millisecond)
|
time.Sleep(100 * time.Millisecond)
|
||||||
|
|
||||||
p1 := Client.Must(Client.GetPostsForChannel(channel.Id, 0, 2, "")).(*model.PostList)
|
p1 := Client.Must(Client.GetPostsForChannel(channel.Id, 0, 2, "")).(*model.PostList)
|
||||||
if len(p1.Order) != 2 {
|
require.Len(t, p1.Order, 2, "Command failed to send")
|
||||||
t.Fatal("Command failed to send")
|
|
||||||
} else {
|
pt := p1.Posts[p1.Order[0]].Type
|
||||||
pt := p1.Posts[p1.Order[0]].Type
|
require.Equal(t, model.POST_ME, pt, "invalid post type")
|
||||||
if pt != model.POST_ME {
|
|
||||||
t.Log(pt)
|
msg := p1.Posts[p1.Order[0]].Message
|
||||||
t.Fatalf("invalid post type, got '%s', wanted '%s'", pt, model.POST_ME)
|
want := "*hello*"
|
||||||
}
|
require.Equal(t, want, msg, "invalid me response")
|
||||||
msg := p1.Posts[p1.Order[0]].Message
|
|
||||||
want := "*hello*"
|
|
||||||
if msg != want {
|
|
||||||
t.Log(msg)
|
|
||||||
t.Fatalf("invalid me response message, got '%s', wanted '%s'", msg, want)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestMsgCommands(t *testing.T) {
|
func TestMsgCommands(t *testing.T) {
|
||||||
@@ -379,22 +327,25 @@ func TestMsgCommands(t *testing.T) {
|
|||||||
Client.Must(Client.CreateDirectChannel(th.BasicUser.Id, user3.Id))
|
Client.Must(Client.CreateDirectChannel(th.BasicUser.Id, user3.Id))
|
||||||
|
|
||||||
rs1 := Client.Must(Client.ExecuteCommand(th.BasicChannel.Id, "/msg "+user2.Username)).(*model.CommandResponse)
|
rs1 := Client.Must(Client.ExecuteCommand(th.BasicChannel.Id, "/msg "+user2.Username)).(*model.CommandResponse)
|
||||||
if !strings.HasSuffix(rs1.GotoLocation, "/"+team.Name+"/channels/"+user1.Id+"__"+user2.Id) && !strings.HasSuffix(rs1.GotoLocation, "/"+team.Name+"/channels/"+user2.Id+"__"+user1.Id) {
|
require.Condition(t, func() bool {
|
||||||
t.Fatal("failed to create direct channel")
|
return strings.HasSuffix(rs1.GotoLocation, "/"+team.Name+"/channels/"+user1.Id+"__"+user2.Id) ||
|
||||||
}
|
strings.HasSuffix(rs1.GotoLocation, "/"+team.Name+"/channels/"+user2.Id+"__"+user1.Id)
|
||||||
|
}, "failed to create direct channel")
|
||||||
|
|
||||||
rs2 := Client.Must(Client.ExecuteCommand(th.BasicChannel.Id, "/msg "+user3.Username+" foobar")).(*model.CommandResponse)
|
rs2 := Client.Must(Client.ExecuteCommand(th.BasicChannel.Id, "/msg "+user3.Username+" foobar")).(*model.CommandResponse)
|
||||||
if !strings.HasSuffix(rs2.GotoLocation, "/"+team.Name+"/channels/"+user1.Id+"__"+user3.Id) && !strings.HasSuffix(rs2.GotoLocation, "/"+team.Name+"/channels/"+user3.Id+"__"+user1.Id) {
|
require.Condition(t, func() bool {
|
||||||
t.Fatal("failed to create second direct channel")
|
return strings.HasSuffix(rs2.GotoLocation, "/"+team.Name+"/channels/"+user1.Id+"__"+user3.Id) ||
|
||||||
}
|
strings.HasSuffix(rs2.GotoLocation, "/"+team.Name+"/channels/"+user3.Id+"__"+user1.Id)
|
||||||
if result := Client.Must(Client.SearchPosts(th.BasicTeam.Id, "foobar", false)).(*model.PostList); len(result.Order) == 0 {
|
}, "failed to create second direct channel")
|
||||||
t.Fatalf("post did not get sent to direct message")
|
|
||||||
}
|
result := Client.Must(Client.SearchPosts(th.BasicTeam.Id, "foobar", false)).(*model.PostList)
|
||||||
|
require.NotEqual(t, 0, len(result.Order), "post did not get sent to direct message")
|
||||||
|
|
||||||
rs3 := Client.Must(Client.ExecuteCommand(th.BasicChannel.Id, "/msg "+user2.Username)).(*model.CommandResponse)
|
rs3 := Client.Must(Client.ExecuteCommand(th.BasicChannel.Id, "/msg "+user2.Username)).(*model.CommandResponse)
|
||||||
if !strings.HasSuffix(rs3.GotoLocation, "/"+team.Name+"/channels/"+user1.Id+"__"+user2.Id) && !strings.HasSuffix(rs3.GotoLocation, "/"+team.Name+"/channels/"+user2.Id+"__"+user1.Id) {
|
require.Condition(t, func() bool {
|
||||||
t.Fatal("failed to go back to existing direct channel")
|
return strings.HasSuffix(rs3.GotoLocation, "/"+team.Name+"/channels/"+user1.Id+"__"+user2.Id) ||
|
||||||
}
|
strings.HasSuffix(rs3.GotoLocation, "/"+team.Name+"/channels/"+user2.Id+"__"+user1.Id)
|
||||||
|
}, "failed to go back to existing direct channel")
|
||||||
|
|
||||||
Client.Must(Client.ExecuteCommand(th.BasicChannel.Id, "/msg "+th.BasicUser.Username+" foobar"))
|
Client.Must(Client.ExecuteCommand(th.BasicChannel.Id, "/msg "+th.BasicUser.Username+" foobar"))
|
||||||
Client.Must(Client.ExecuteCommand(th.BasicChannel.Id, "/msg junk foobar"))
|
Client.Must(Client.ExecuteCommand(th.BasicChannel.Id, "/msg junk foobar"))
|
||||||
@@ -435,21 +386,13 @@ func TestShrugCommand(t *testing.T) {
|
|||||||
testString := "/shrug"
|
testString := "/shrug"
|
||||||
|
|
||||||
r1 := Client.Must(Client.ExecuteCommand(channel.Id, testString)).(*model.CommandResponse)
|
r1 := Client.Must(Client.ExecuteCommand(channel.Id, testString)).(*model.CommandResponse)
|
||||||
if r1 == nil {
|
require.NotNil(t, r1, "Command failed to execute")
|
||||||
t.Fatal("Command failed to execute")
|
|
||||||
}
|
|
||||||
|
|
||||||
time.Sleep(100 * time.Millisecond)
|
time.Sleep(100 * time.Millisecond)
|
||||||
|
|
||||||
p1 := Client.Must(Client.GetPostsForChannel(channel.Id, 0, 2, "")).(*model.PostList)
|
p1 := Client.Must(Client.GetPostsForChannel(channel.Id, 0, 2, "")).(*model.PostList)
|
||||||
if len(p1.Order) != 2 {
|
require.Len(t, p1.Order, 2, "Command failed to send")
|
||||||
t.Fatal("Command failed to send")
|
require.Equal(t, `¯\\\_(ツ)\_/¯`, p1.Posts[p1.Order[0]].Message, "invalid shrug response")
|
||||||
} else {
|
|
||||||
if p1.Posts[p1.Order[0]].Message != `¯\\\_(ツ)\_/¯` {
|
|
||||||
t.Log(p1.Posts[p1.Order[0]].Message)
|
|
||||||
t.Fatal("invalid shrug response")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestStatusCommands(t *testing.T) {
|
func TestStatusCommands(t *testing.T) {
|
||||||
@@ -467,15 +410,10 @@ func commandAndTest(t *testing.T, th *TestHelper, status string) {
|
|||||||
user := th.BasicUser
|
user := th.BasicUser
|
||||||
|
|
||||||
r1 := Client.Must(Client.ExecuteCommand(channel.Id, "/"+status)).(*model.CommandResponse)
|
r1 := Client.Must(Client.ExecuteCommand(channel.Id, "/"+status)).(*model.CommandResponse)
|
||||||
if r1 == nil {
|
require.NotEqual(t, "Command failed to execute", r1)
|
||||||
t.Fatal("Command failed to execute")
|
|
||||||
}
|
|
||||||
|
|
||||||
time.Sleep(1000 * time.Millisecond)
|
time.Sleep(1000 * time.Millisecond)
|
||||||
|
|
||||||
rstatus := Client.Must(Client.GetUserStatus(user.Id, "")).(*model.Status)
|
rstatus := Client.Must(Client.GetUserStatus(user.Id, "")).(*model.Status)
|
||||||
|
require.Equal(t, status, rstatus.Status, "Error setting status")
|
||||||
if rstatus.Status != status {
|
|
||||||
t.Fatal("Error setting status " + status)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user