Fix /msg switching teams (#7753)

* Fix /msg switching teams

* simplify a bit
This commit is contained in:
Chris
2017-11-01 13:15:31 -05:00
committed by Harrison Healey
parent 23e4b4a27d
commit bd3b7aeeea
2 changed files with 32 additions and 3 deletions

31
app/command_msg_test.go Normal file
View File

@@ -0,0 +1,31 @@
// Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
package app
import (
"testing"
"github.com/nicksnyder/go-i18n/i18n"
"github.com/stretchr/testify/assert"
"github.com/mattermost/mattermost-server/model"
)
func TestMsgProvider(t *testing.T) {
th := Setup().InitBasic()
defer th.TearDown()
team := th.CreateTeam()
th.LinkUserToTeam(th.BasicUser, team)
cmd := &msgProvider{}
resp := cmd.DoCommand(th.App, &model.CommandArgs{
T: i18n.IdentityTfunc(),
SiteURL: "http://test.url",
TeamId: team.Id,
UserId: th.BasicUser.Id,
}, "@"+th.BasicUser2.Username+" hello")
channelName := model.GetDMNameFromIds(th.BasicUser.Id, th.BasicUser2.Id)
assert.Equal(t, "", resp.Text)
assert.Equal(t, "http://test.url/"+team.Name+"/channels/"+channelName, resp.GotoLocation)
}