From af615ffc24b774d76deef8c93282831432669dd8 Mon Sep 17 00:00:00 2001 From: George Goldberg Date: Tue, 10 Jul 2018 09:56:04 +0100 Subject: MM-11229: Fix invite people slash command and add test case. (#9074) --- app/command_invite_people_test.go | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 app/command_invite_people_test.go (limited to 'app/command_invite_people_test.go') diff --git a/app/command_invite_people_test.go b/app/command_invite_people_test.go new file mode 100644 index 000000000..6e10235f4 --- /dev/null +++ b/app/command_invite_people_test.go @@ -0,0 +1,36 @@ +// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. +// See License.txt for license information. + +package app + +import ( + "testing" + + "github.com/stretchr/testify/assert" + + "github.com/mattermost/mattermost-server/model" +) + +func TestInvitePeopleProvider(t *testing.T) { + th := Setup().InitBasic() + defer th.TearDown() + + cmd := InvitePeopleProvider{} + + // Test without required permissions + args := &model.CommandArgs{ + T: func(s string, args ...interface{}) string { return s }, + ChannelId: th.BasicChannel.Id, + TeamId: th.BasicTeam.Id, + UserId: th.BasicUser.Id, + Session: model.Session{UserId: th.BasicUser.Id, TeamMembers: []*model.TeamMember{{TeamId: th.BasicTeam.Id, Roles: ""}}}, + } + + actual := cmd.DoCommand(th.App, args, model.NewId()+"@simulator.amazonses.com") + assert.Equal(t, "api.command_invite_people.permission.app_error", actual.Text) + + // Test with required permissions. + args.Session.TeamMembers[0].Roles = model.TEAM_USER_ROLE_ID + actual = cmd.DoCommand(th.App, args, model.NewId()+"@simulator.amazonses.com") + assert.Equal(t, "api.command.invite_people.sent", actual.Text) +} -- cgit v1.2.3-1-g7c22