github.com/gigforks/mattermost-server@v4.9.1-0.20180619094218-800d97fa55d0+incompatible/app/command_channel_rename_test.go (about) 1 package app 2 3 import ( 4 "testing" 5 6 "github.com/mattermost/mattermost-server/model" 7 "github.com/stretchr/testify/assert" 8 ) 9 10 func TestRenameProviderDoCommand(t *testing.T) { 11 th := Setup().InitBasic() 12 defer th.TearDown() 13 14 rp := RenameProvider{} 15 args := &model.CommandArgs{ 16 T: func(s string, args ...interface{}) string { return s }, 17 ChannelId: th.BasicChannel.Id, 18 Session: model.Session{UserId: th.BasicUser.Id, TeamMembers: []*model.TeamMember{{TeamId: th.BasicTeam.Id, Roles: model.TEAM_USER_ROLE_ID}}}, 19 } 20 21 // Blank text is a success 22 for msg, expected := range map[string]string{ 23 "": "api.command_channel_rename.message.app_error", 24 "o": "api.command_channel_rename.too_short.app_error", 25 "joram": "", 26 "1234567890123456789012": "", 27 "12345678901234567890123": "api.command_channel_rename.too_long.app_error", 28 } { 29 actual := rp.DoCommand(th.App, args, msg).Text 30 assert.Equal(t, expected, actual) 31 } 32 }