update command_remove_test.go (fix errcheck issue) (#29177)

Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com>
This commit is contained in:
TheInvincible 2024-11-13 20:21:49 +01:00 committed by GitHub
parent 891b2144df
commit 11edef7af0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 17 additions and 9 deletions

View file

@ -142,7 +142,6 @@ issues:
channels/app/slack.go|\
channels/app/slashcommands/auto_environment.go|\
channels/app/slashcommands/command_loadtest.go|\
channels/app/slashcommands/command_remove_test.go|\
channels/app/slashcommands/command_test.go|\
channels/app/slashcommands/helper_test.go|\
channels/app/status.go|\

View file

@ -7,6 +7,7 @@ import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/mattermost/mattermost/server/public/model"
)
@ -34,9 +35,12 @@ func TestRemoveProviderDoCommand(t *testing.T) {
}, false)
targetUser := th.createUser()
th.App.AddUserToTeam(th.Context, th.BasicTeam.Id, targetUser.Id, targetUser.Id)
th.App.AddUserToChannel(th.Context, targetUser, publicChannel, false)
th.App.AddUserToChannel(th.Context, targetUser, privateChannel, false)
_, _, err := th.App.AddUserToTeam(th.Context, th.BasicTeam.Id, targetUser.Id, targetUser.Id)
require.Nil(t, err)
_, err = th.App.AddUserToChannel(th.Context, targetUser, publicChannel, false)
require.Nil(t, err)
_, err = th.App.AddUserToChannel(th.Context, targetUser, privateChannel, false)
require.Nil(t, err)
// Try a public channel *without* permission.
args := &model.CommandArgs{
@ -49,7 +53,8 @@ func TestRemoveProviderDoCommand(t *testing.T) {
assert.Equal(t, "api.command_remove.permission.app_error", actual)
// Try a public channel *with* permission.
th.App.AddUserToChannel(th.Context, th.BasicUser, publicChannel, false)
_, err = th.App.AddUserToChannel(th.Context, th.BasicUser, publicChannel, false)
require.Nil(t, err)
args = &model.CommandArgs{
T: func(s string, args ...any) string { return s },
ChannelId: publicChannel.Id,
@ -70,7 +75,8 @@ func TestRemoveProviderDoCommand(t *testing.T) {
assert.Equal(t, "api.command_remove.permission.app_error", actual)
// Try a private channel *with* permission.
th.App.AddUserToChannel(th.Context, th.BasicUser, privateChannel, false)
_, err = th.App.AddUserToChannel(th.Context, th.BasicUser, privateChannel, false)
require.Nil(t, err)
args = &model.CommandArgs{
T: func(s string, args ...any) string { return s },
ChannelId: privateChannel.Id,
@ -109,9 +115,12 @@ func TestRemoveProviderDoCommand(t *testing.T) {
// Try a public channel with a deactivated user.
deactivatedUser := th.createUser()
th.App.AddUserToTeam(th.Context, th.BasicTeam.Id, deactivatedUser.Id, deactivatedUser.Id)
th.App.AddUserToChannel(th.Context, deactivatedUser, publicChannel, false)
th.App.UpdateActive(th.Context, deactivatedUser, false)
_, _, err = th.App.AddUserToTeam(th.Context, th.BasicTeam.Id, deactivatedUser.Id, deactivatedUser.Id)
require.Nil(t, err)
_, err = th.App.AddUserToChannel(th.Context, deactivatedUser, publicChannel, false)
require.Nil(t, err)
_, err = th.App.UpdateActive(th.Context, deactivatedUser, false)
require.Nil(t, err)
args = &model.CommandArgs{
T: func(s string, args ...any) string { return s },