summaryrefslogtreecommitdiffstats
path: root/app/command_channel_rename_test.go
blob: 9c86b18e00dfad67bb301903d3d5f3e428d74a4f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package app

import (
	"testing"

	"github.com/mattermost/mattermost-server/model"
	"github.com/stretchr/testify/assert"
)

func TestRenameProviderDoCommand(t *testing.T) {
	th := Setup().InitBasic()
	defer th.TearDown()

	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{{TeamId: th.BasicTeam.Id, Roles: model.TEAM_USER_ROLE_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(th.App, args, msg).Text
		assert.Equal(t, expected, actual)
	}
}