github.com/spline-fu/mattermost-server@v4.10.10+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().InitBasic()
    16  	defer th.TearDown()
    17  
    18  	cmd := InvitePeopleProvider{}
    19  
    20  	// Test without required permissions
    21  	args := &model.CommandArgs{
    22  		T:         func(s string, args ...interface{}) string { return s },
    23  		ChannelId: th.BasicChannel.Id,
    24  		TeamId:    th.BasicTeam.Id,
    25  		UserId:    th.BasicUser.Id,
    26  		Session:   model.Session{UserId: th.BasicUser.Id, TeamMembers: []*model.TeamMember{{TeamId: th.BasicTeam.Id, Roles: ""}}},
    27  	}
    28  
    29  	actual := cmd.DoCommand(th.App, args, model.NewId()+"@simulator.amazonses.com")
    30  	assert.Equal(t, "api.command_invite_people.permission.app_error", actual.Text)
    31  
    32  	// Test with required permissions.
    33  	args.Session.TeamMembers[0].Roles = model.TEAM_USER_ROLE_ID
    34  	actual = cmd.DoCommand(th.App, args, model.NewId()+"@simulator.amazonses.com")
    35  	assert.Equal(t, "api.command.invite_people.sent", actual.Text)
    36  }