github.com/vnforks/kid@v5.11.1+incompatible/app/command_invite_people_test.go (about) 1 // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. 2 // See License.txt for license information. 3 4 package app 5 6 import ( 7 "testing" 8 9 "github.com/stretchr/testify/assert" 10 11 "github.com/mattermost/mattermost-server/model" 12 ) 13 14 func TestInvitePeopleProvider(t *testing.T) { 15 th := Setup(t).InitBasic() 16 defer th.TearDown() 17 18 th.App.UpdateConfig(func(cfg *model.Config) { 19 *cfg.EmailSettings.SendEmailNotifications = true 20 *cfg.ServiceSettings.EnableEmailInvitations = true 21 }) 22 23 cmd := InvitePeopleProvider{} 24 25 // Test without required permissions 26 args := &model.CommandArgs{ 27 T: func(s string, args ...interface{}) string { return s }, 28 ChannelId: th.BasicChannel.Id, 29 TeamId: th.BasicTeam.Id, 30 UserId: th.BasicUser.Id, 31 Session: model.Session{UserId: th.BasicUser.Id, TeamMembers: []*model.TeamMember{{TeamId: th.BasicTeam.Id, Roles: ""}}}, 32 } 33 34 actual := cmd.DoCommand(th.App, args, model.NewId()+"@simulator.amazonses.com") 35 assert.Equal(t, "api.command_invite_people.permission.app_error", actual.Text) 36 37 // Test with required permissions. 38 args.Session.TeamMembers[0].Roles = model.TEAM_USER_ROLE_ID 39 actual = cmd.DoCommand(th.App, args, model.NewId()+"@simulator.amazonses.com") 40 assert.Equal(t, "api.command.invite_people.sent", actual.Text) 41 }