From 663977d71a6df1e2a51bd5aafbe60be98a056234 Mon Sep 17 00:00:00 2001 From: George Goldberg Date: Tue, 18 Jun 2019 10:44:29 +0100 Subject: [PATCH] MM-16115: Channel name max length in /rename to match UI. (#11114) --- app/command_channel_rename.go | 4 ++-- app/command_channel_rename_test.go | 13 +++++++------ model/channel.go | 1 - 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app/command_channel_rename.go b/app/command_channel_rename.go index a243305f89..581ee1096d 100644 --- a/app/command_channel_rename.go +++ b/app/command_channel_rename.go @@ -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"), 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{ 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, } diff --git a/app/command_channel_rename_test.go b/app/command_channel_rename_test.go index 8fb31340cd..c775b09b7c 100644 --- a/app/command_channel_rename_test.go +++ b/app/command_channel_rename_test.go @@ -4,6 +4,7 @@ package app import ( + "strings" "testing" "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}}}, } - // Blank text is a success + // Table Test for basic cases. Blank text in response indicates 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", + "": "api.command_channel_rename.message.app_error", + "o": "api.command_channel_rename.too_short.app_error", + "joram": "", + "More than 22 chars but less than 64": "", + strings.Repeat("12345", 13): "api.command_channel_rename.too_long.app_error", } { actual := rp.DoCommand(th.App, args, msg).Text assert.Equal(t, expected, actual) diff --git a/model/channel.go b/model/channel.go index 942fa6d778..07f6f6a6f1 100644 --- a/model/channel.go +++ b/model/channel.go @@ -25,7 +25,6 @@ const ( CHANNEL_DISPLAY_NAME_MAX_RUNES = 64 CHANNEL_NAME_MIN_LENGTH = 2 CHANNEL_NAME_MAX_LENGTH = 64 - CHANNEL_NAME_UI_MAX_LENGTH = 22 CHANNEL_HEADER_MAX_RUNES = 1024 CHANNEL_PURPOSE_MAX_RUNES = 250 CHANNEL_CACHE_SIZE = 25000