Enforce channel display name limits on slash command (#7309)

Этот коммит содержится в:
Joram Wilander
2017-08-29 05:48:38 -04:00
коммит произвёл Saturnino Abril
родитель ce77d836fc
Коммит 82a8bd99cc
4 изменённых файлов: 44 добавлений и 0 удалений

31
app/command_channel_rename_test.go Обычный файл
Просмотреть файл

@@ -0,0 +1,31 @@
package app
import (
"testing"
"github.com/mattermost/platform/model"
"github.com/stretchr/testify/assert"
)
func TestRenameProviderDoCommand(t *testing.T) {
th := Setup().InitBasic()
rp := RenameProvider{}
args := &model.CommandArgs{
T: func(s string, args ...interface{}) string { return s },
ChannelId: th.BasicChannel.Id,
Session: model.Session{UserId: th.BasicUser.Id, TeamMembers: []*model.TeamMember{&model.TeamMember{TeamId: th.BasicTeam.Id, Roles: model.ROLE_TEAM_USER.Id}}},
}
// Blank text is a success
for msg, expected := range map[string]string{
"": "api.command_channel_rename.message.app_error",
"o": "api.command_channel_rename.too_short.app_error",
"joram": "",
"1234567890123456789012": "",
"12345678901234567890123": "api.command_channel_rename.too_long.app_error",
} {
actual := rp.DoCommand(args, msg).Text
assert.Equal(t, expected, actual)
}
}