MM-16115: Channel name max length in /rename to match UI. (#11114)

Этот коммит содержится в:
George Goldberg
2019-06-18 10:44:29 +01:00
коммит произвёл GitHub
родитель 059eecc696
Коммит 663977d71a
3 изменённых файлов: 9 добавлений и 9 удалений

Просмотреть файл

@@ -67,10 +67,10 @@ func (me *RenameProvider) DoCommand(a *App, args *model.CommandArgs, message str
Text: args.T("api.command_channel_rename.message.app_error"), Text: args.T("api.command_channel_rename.message.app_error"),
ResponseType: model.COMMAND_RESPONSE_TYPE_EPHEMERAL, ResponseType: model.COMMAND_RESPONSE_TYPE_EPHEMERAL,
} }
} else if len(message) > model.CHANNEL_NAME_UI_MAX_LENGTH { } else if len(message) > model.CHANNEL_NAME_MAX_LENGTH {
return &model.CommandResponse{ return &model.CommandResponse{
Text: args.T("api.command_channel_rename.too_long.app_error", map[string]interface{}{ Text: args.T("api.command_channel_rename.too_long.app_error", map[string]interface{}{
"Length": model.CHANNEL_NAME_UI_MAX_LENGTH, "Length": model.CHANNEL_NAME_MAX_LENGTH,
}), }),
ResponseType: model.COMMAND_RESPONSE_TYPE_EPHEMERAL, ResponseType: model.COMMAND_RESPONSE_TYPE_EPHEMERAL,
} }

Просмотреть файл

@@ -4,6 +4,7 @@
package app package app
import ( import (
"strings"
"testing" "testing"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
@@ -24,13 +25,13 @@ func TestRenameProviderDoCommand(t *testing.T) {
Session: model.Session{UserId: th.BasicUser.Id, TeamMembers: []*model.TeamMember{{TeamId: th.BasicTeam.Id, Roles: model.TEAM_USER_ROLE_ID}}}, Session: model.Session{UserId: th.BasicUser.Id, TeamMembers: []*model.TeamMember{{TeamId: th.BasicTeam.Id, Roles: model.TEAM_USER_ROLE_ID}}},
} }
// Blank text is a success // Table Test for basic cases. Blank text in response indicates success
for msg, expected := range map[string]string{ for msg, expected := range map[string]string{
"": "api.command_channel_rename.message.app_error", "": "api.command_channel_rename.message.app_error",
"o": "api.command_channel_rename.too_short.app_error", "o": "api.command_channel_rename.too_short.app_error",
"joram": "", "joram": "",
"1234567890123456789012": "", "More than 22 chars but less than 64": "",
"12345678901234567890123": "api.command_channel_rename.too_long.app_error", strings.Repeat("12345", 13): "api.command_channel_rename.too_long.app_error",
} { } {
actual := rp.DoCommand(th.App, args, msg).Text actual := rp.DoCommand(th.App, args, msg).Text
assert.Equal(t, expected, actual) assert.Equal(t, expected, actual)

Просмотреть файл

@@ -25,7 +25,6 @@ const (
CHANNEL_DISPLAY_NAME_MAX_RUNES = 64 CHANNEL_DISPLAY_NAME_MAX_RUNES = 64
CHANNEL_NAME_MIN_LENGTH = 2 CHANNEL_NAME_MIN_LENGTH = 2
CHANNEL_NAME_MAX_LENGTH = 64 CHANNEL_NAME_MAX_LENGTH = 64
CHANNEL_NAME_UI_MAX_LENGTH = 22
CHANNEL_HEADER_MAX_RUNES = 1024 CHANNEL_HEADER_MAX_RUNES = 1024
CHANNEL_PURPOSE_MAX_RUNES = 250 CHANNEL_PURPOSE_MAX_RUNES = 250
CHANNEL_CACHE_SIZE = 25000 CHANNEL_CACHE_SIZE = 25000