update command_remove_test.go (fix errcheck issue) (#29177)
Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
891b2144df
Коммит
11edef7af0
@@ -142,7 +142,6 @@ issues:
|
|||||||
channels/app/slack.go|\
|
channels/app/slack.go|\
|
||||||
channels/app/slashcommands/auto_environment.go|\
|
channels/app/slashcommands/auto_environment.go|\
|
||||||
channels/app/slashcommands/command_loadtest.go|\
|
channels/app/slashcommands/command_loadtest.go|\
|
||||||
channels/app/slashcommands/command_remove_test.go|\
|
|
||||||
channels/app/slashcommands/command_test.go|\
|
channels/app/slashcommands/command_test.go|\
|
||||||
channels/app/slashcommands/helper_test.go|\
|
channels/app/slashcommands/helper_test.go|\
|
||||||
channels/app/status.go|\
|
channels/app/status.go|\
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
"github.com/mattermost/mattermost/server/public/model"
|
"github.com/mattermost/mattermost/server/public/model"
|
||||||
)
|
)
|
||||||
@@ -34,9 +35,12 @@ func TestRemoveProviderDoCommand(t *testing.T) {
|
|||||||
}, false)
|
}, false)
|
||||||
|
|
||||||
targetUser := th.createUser()
|
targetUser := th.createUser()
|
||||||
th.App.AddUserToTeam(th.Context, th.BasicTeam.Id, targetUser.Id, targetUser.Id)
|
_, _, err := th.App.AddUserToTeam(th.Context, th.BasicTeam.Id, targetUser.Id, targetUser.Id)
|
||||||
th.App.AddUserToChannel(th.Context, targetUser, publicChannel, false)
|
require.Nil(t, err)
|
||||||
th.App.AddUserToChannel(th.Context, targetUser, privateChannel, false)
|
_, 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.
|
// Try a public channel *without* permission.
|
||||||
args := &model.CommandArgs{
|
args := &model.CommandArgs{
|
||||||
@@ -49,7 +53,8 @@ func TestRemoveProviderDoCommand(t *testing.T) {
|
|||||||
assert.Equal(t, "api.command_remove.permission.app_error", actual)
|
assert.Equal(t, "api.command_remove.permission.app_error", actual)
|
||||||
|
|
||||||
// Try a public channel *with* permission.
|
// 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{
|
args = &model.CommandArgs{
|
||||||
T: func(s string, args ...any) string { return s },
|
T: func(s string, args ...any) string { return s },
|
||||||
ChannelId: publicChannel.Id,
|
ChannelId: publicChannel.Id,
|
||||||
@@ -70,7 +75,8 @@ func TestRemoveProviderDoCommand(t *testing.T) {
|
|||||||
assert.Equal(t, "api.command_remove.permission.app_error", actual)
|
assert.Equal(t, "api.command_remove.permission.app_error", actual)
|
||||||
|
|
||||||
// Try a private channel *with* permission.
|
// 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{
|
args = &model.CommandArgs{
|
||||||
T: func(s string, args ...any) string { return s },
|
T: func(s string, args ...any) string { return s },
|
||||||
ChannelId: privateChannel.Id,
|
ChannelId: privateChannel.Id,
|
||||||
@@ -109,9 +115,12 @@ func TestRemoveProviderDoCommand(t *testing.T) {
|
|||||||
|
|
||||||
// Try a public channel with a deactivated user.
|
// Try a public channel with a deactivated user.
|
||||||
deactivatedUser := th.createUser()
|
deactivatedUser := th.createUser()
|
||||||
th.App.AddUserToTeam(th.Context, th.BasicTeam.Id, deactivatedUser.Id, deactivatedUser.Id)
|
_, _, err = th.App.AddUserToTeam(th.Context, th.BasicTeam.Id, deactivatedUser.Id, deactivatedUser.Id)
|
||||||
th.App.AddUserToChannel(th.Context, deactivatedUser, publicChannel, false)
|
require.Nil(t, err)
|
||||||
th.App.UpdateActive(th.Context, deactivatedUser, false)
|
_, 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{
|
args = &model.CommandArgs{
|
||||||
T: func(s string, args ...any) string { return s },
|
T: func(s string, args ...any) string { return s },
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user