From 5e851f708b0118b49cecbaa77eb91328e24f6a22 Mon Sep 17 00:00:00 2001 From: Agniva De Sarker Date: Thu, 21 Mar 2024 09:12:35 +0530 Subject: [PATCH] MM-57245: Bump up Go version to 1.21 (#26512) * MM-57245: Bump up Go version to 1.21 https://mattermost.atlassian.net/browse/MM-57245 ```release-note NONE ``` --- .github/workflows/codeql-analysis.yml | 2 +- .github/workflows/migration.yml | 2 +- .github/workflows/mmctl-test-template.yml | 2 +- server/.go-version | 2 +- server/build/Dockerfile.buildenv | 2 +- server/cmd/mmctl/commands/bot_test.go | 128 ++--- server/cmd/mmctl/commands/channel_test.go | 436 +++++++++--------- .../cmd/mmctl/commands/channel_users_test.go | 80 ++-- server/cmd/mmctl/commands/channelargs_test.go | 14 +- server/cmd/mmctl/commands/command_test.go | 124 ++--- server/cmd/mmctl/commands/config_test.go | 86 ++-- server/cmd/mmctl/commands/export_test.go | 10 +- server/cmd/mmctl/commands/group_test.go | 230 ++++----- server/cmd/mmctl/commands/import_test.go | 18 +- server/cmd/mmctl/commands/integrity_test.go | 6 +- server/cmd/mmctl/commands/ldap_test.go | 12 +- server/cmd/mmctl/commands/license_test.go | 10 +- server/cmd/mmctl/commands/logs_test.go | 6 +- .../mmctl/commands/permission_role_test.go | 72 +-- .../mmctl/commands/permissions_e2e_test.go | 8 +- server/cmd/mmctl/commands/permissions_test.go | 32 +- .../mmctl/commands/plugin_marketplace_test.go | 16 +- server/cmd/mmctl/commands/plugin_test.go | 56 +-- server/cmd/mmctl/commands/post_test.go | 30 +- server/cmd/mmctl/commands/roles_test.go | 32 +- server/cmd/mmctl/commands/saml_test.go | 6 +- server/cmd/mmctl/commands/system_test.go | 20 +- server/cmd/mmctl/commands/team_test.go | 96 ++-- server/cmd/mmctl/commands/team_users_test.go | 74 +-- server/cmd/mmctl/commands/teamargs_test.go | 14 +- server/cmd/mmctl/commands/token_test.go | 48 +- server/cmd/mmctl/commands/user_e2e_test.go | 64 +-- server/cmd/mmctl/commands/user_test.go | 436 +++++++++--------- server/cmd/mmctl/commands/userargs_test.go | 18 +- server/cmd/mmctl/commands/webhook_test.go | 88 ++-- server/go.mod | 4 +- server/public/go.mod | 4 +- server/public/go.sum | 5 + 38 files changed, 1151 insertions(+), 1142 deletions(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index a82094a8e3..ebcb207fb7 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -42,7 +42,7 @@ jobs: - name: Setup go uses: actions/setup-go@v2 with: - go-version: '1.20' + go-version: '1.21' if: ${{ matrix.language == 'go' }} diff --git a/.github/workflows/migration.yml b/.github/workflows/migration.yml index a02d1f6cce..10ff9112a9 100644 --- a/.github/workflows/migration.yml +++ b/.github/workflows/migration.yml @@ -7,7 +7,7 @@ jobs: runs-on: ubuntu-22.04 env: COMPOSE_PROJECT_NAME: ghactions - BUILD_IMAGE: mattermost/mattermost-build-server:20230904_golang-1.20.7 + BUILD_IMAGE: mattermost/mattermost-build-server:1.21.8 TEST_IMAGE: migration-test-image defaults: run: diff --git a/.github/workflows/mmctl-test-template.yml b/.github/workflows/mmctl-test-template.yml index 8bbc49c112..7408a9d656 100644 --- a/.github/workflows/mmctl-test-template.yml +++ b/.github/workflows/mmctl-test-template.yml @@ -21,7 +21,7 @@ jobs: runs-on: ubuntu-22.04 env: COMPOSE_PROJECT_NAME: ghactions - BUILD_IMAGE: mattermost/mattermost-build-server:20230904_golang-1.20.7 + BUILD_IMAGE: mattermost/mattermost-build-server:1.21.8 steps: - name: Checkout mattermost project uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 diff --git a/server/.go-version b/server/.go-version index 6597009a06..428abfd24f 100644 --- a/server/.go-version +++ b/server/.go-version @@ -1 +1 @@ -1.20.7 \ No newline at end of file +1.21.8 diff --git a/server/build/Dockerfile.buildenv b/server/build/Dockerfile.buildenv index 720b18dbee..c0fe80255a 100644 --- a/server/build/Dockerfile.buildenv +++ b/server/build/Dockerfile.buildenv @@ -1,3 +1,3 @@ -FROM golang:1.20.7-bullseye@sha256:c95c52c458a2678251e0769ea13c710b0c52814771c53a495f53b9e87f9c0e99 +FROM golang:1.21.8-bullseye@sha256:81d98548f08e22a59c5c0be814acc0997f3dfd3313487adcf4e1d3d962af3a43 RUN apt-get update && apt-get install -y make git apt-transport-https ca-certificates curl software-properties-common build-essential zip xmlsec1 jq diff --git a/server/cmd/mmctl/commands/bot_test.go b/server/cmd/mmctl/commands/bot_test.go index f45c6fa252..fd8716b50e 100644 --- a/server/cmd/mmctl/commands/bot_test.go +++ b/server/cmd/mmctl/commands/bot_test.go @@ -28,7 +28,7 @@ func (s *MmctlUnitTestSuite) TestBotCreateCmd() { s.client. EXPECT(). - CreateBot(context.Background(), &mockBot). + CreateBot(context.TODO(), &mockBot). Return(&mockBot, &model.Response{}, nil). Times(1) @@ -52,25 +52,25 @@ func (s *MmctlUnitTestSuite) TestBotCreateCmd() { s.client. EXPECT(). - CreateBot(context.Background(), &mockBot). + CreateBot(context.TODO(), &mockBot). Return(&mockBot, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetUserByEmail(context.Background(), botArg, ""). + GetUserByEmail(context.TODO(), botArg, ""). Return(nil, &model.Response{}, errors.New("no user found with the given email")). Times(1) s.client. EXPECT(). - GetUserByUsername(context.Background(), botArg, ""). + GetUserByUsername(context.TODO(), botArg, ""). Return(model.UserFromBot(&mockBot), &model.Response{}, nil). Times(1) s.client. EXPECT(). - CreateUserAccessToken(context.Background(), mockBot.UserId, "autogenerated"). + CreateUserAccessToken(context.TODO(), mockBot.UserId, "autogenerated"). Return(&mockToken, &model.Response{}, nil). Times(1) @@ -89,7 +89,7 @@ func (s *MmctlUnitTestSuite) TestBotCreateCmd() { s.client. EXPECT(). - CreateBot(context.Background(), &mockBot). + CreateBot(context.TODO(), &mockBot). Return(nil, &model.Response{}, errors.New("some-error")). Times(1) @@ -118,19 +118,19 @@ func (s *MmctlUnitTestSuite) TestBotUpdateCmd() { s.client. EXPECT(). - GetUserByEmail(context.Background(), botArg, ""). + GetUserByEmail(context.TODO(), botArg, ""). Return(nil, &model.Response{}, errors.New("mock error")). Times(1) s.client. EXPECT(). - GetUserByUsername(context.Background(), botArg, ""). + GetUserByUsername(context.TODO(), botArg, ""). Return(&mockUser, &model.Response{}, nil). Times(1) s.client. EXPECT(). - PatchBot(context.Background(), mockUser.Id, gomock.Any()). + PatchBot(context.TODO(), mockUser.Id, gomock.Any()). Return(&mockBot, &model.Response{}, nil). Times(1) @@ -150,19 +150,19 @@ func (s *MmctlUnitTestSuite) TestBotUpdateCmd() { s.client. EXPECT(). - GetUserByEmail(context.Background(), botArg, ""). + GetUserByEmail(context.TODO(), botArg, ""). Return(nil, &model.Response{}, errors.New("mock error")). Times(1) s.client. EXPECT(). - GetUserByUsername(context.Background(), botArg, ""). + GetUserByUsername(context.TODO(), botArg, ""). Return(nil, &model.Response{}, errors.New("mock error")). Times(1) s.client. EXPECT(). - GetUser(context.Background(), botArg, ""). + GetUser(context.TODO(), botArg, ""). Return(nil, &model.Response{}, errors.New("mock error")). Times(1) @@ -185,19 +185,19 @@ func (s *MmctlUnitTestSuite) TestBotUpdateCmd() { s.client. EXPECT(). - GetUserByEmail(context.Background(), botArg, ""). + GetUserByEmail(context.TODO(), botArg, ""). Return(nil, &model.Response{}, errors.New("mock error")). Times(1) s.client. EXPECT(). - GetUserByUsername(context.Background(), botArg, ""). + GetUserByUsername(context.TODO(), botArg, ""). Return(&mockUser, &model.Response{}, nil). Times(1) s.client. EXPECT(). - PatchBot(context.Background(), mockUser.Id, gomock.Any()). + PatchBot(context.TODO(), mockUser.Id, gomock.Any()). Return(nil, &model.Response{}, errors.New("mock error")). Times(1) @@ -221,13 +221,13 @@ func (s *MmctlUnitTestSuite) TestBotListCmd() { s.client. EXPECT(). - GetBotsIncludeDeleted(context.Background(), 0, 200, ""). + GetBotsIncludeDeleted(context.TODO(), 0, 200, ""). Return([]*model.Bot{&mockBot}, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetUsersByIds(context.Background(), []string{mockBot.OwnerId}). + GetUsersByIds(context.TODO(), []string{mockBot.OwnerId}). Return([]*model.User{&mockUser}, &model.Response{}, nil). Times(1) @@ -247,7 +247,7 @@ func (s *MmctlUnitTestSuite) TestBotListCmd() { s.client. EXPECT(). - GetBotsIncludeDeleted(context.Background(), 0, 200, ""). + GetBotsIncludeDeleted(context.TODO(), 0, 200, ""). Return(nil, &model.Response{}, errors.New("mock error")). Times(1) @@ -269,13 +269,13 @@ func (s *MmctlUnitTestSuite) TestBotListCmd() { s.client. EXPECT(). - GetBotsOrphaned(context.Background(), 0, 200, ""). + GetBotsOrphaned(context.TODO(), 0, 200, ""). Return([]*model.Bot{&mockBot}, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetUsersByIds(context.Background(), []string{mockBot.OwnerId}). + GetUsersByIds(context.TODO(), []string{mockBot.OwnerId}). Return([]*model.User{&mockUser}, &model.Response{}, nil). Times(1) @@ -295,7 +295,7 @@ func (s *MmctlUnitTestSuite) TestBotListCmd() { s.client. EXPECT(). - GetBotsOrphaned(context.Background(), 0, 200, ""). + GetBotsOrphaned(context.TODO(), 0, 200, ""). Return(nil, &model.Response{}, errors.New("mock error")). Times(1) @@ -317,13 +317,13 @@ func (s *MmctlUnitTestSuite) TestBotListCmd() { s.client. EXPECT(). - GetBots(context.Background(), 0, 200, ""). + GetBots(context.TODO(), 0, 200, ""). Return([]*model.Bot{&mockBot}, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetUsersByIds(context.Background(), []string{mockBot.OwnerId}). + GetUsersByIds(context.TODO(), []string{mockBot.OwnerId}). Return([]*model.User{&mockUser}, &model.Response{}, nil). Times(1) @@ -344,13 +344,13 @@ func (s *MmctlUnitTestSuite) TestBotListCmd() { s.client. EXPECT(). - GetBots(context.Background(), 0, 200, ""). + GetBots(context.TODO(), 0, 200, ""). Return([]*model.Bot{&mockBot}, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetUsersByIds(context.Background(), []string{mockBot.OwnerId}). + GetUsersByIds(context.TODO(), []string{mockBot.OwnerId}). Return([]*model.User{}, &model.Response{}, nil). Times(1) @@ -370,7 +370,7 @@ func (s *MmctlUnitTestSuite) TestBotListCmd() { s.client. EXPECT(). - GetBots(context.Background(), 0, 200, ""). + GetBots(context.TODO(), 0, 200, ""). Return(nil, &model.Response{}, errors.New("mock error")). Times(1) @@ -391,13 +391,13 @@ func (s *MmctlUnitTestSuite) TestBotListCmd() { s.client. EXPECT(). - GetBots(context.Background(), 0, 200, ""). + GetBots(context.TODO(), 0, 200, ""). Return([]*model.Bot{&mockBot}, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetUsersByIds(context.Background(), []string{mockBot.OwnerId}). + GetUsersByIds(context.TODO(), []string{mockBot.OwnerId}). Return(nil, &model.Response{}, errors.New("mock error")). Times(1) @@ -419,19 +419,19 @@ func (s *MmctlUnitTestSuite) TestBotDisableCmd() { s.client. EXPECT(). - GetUserByEmail(context.Background(), botArg, ""). + GetUserByEmail(context.TODO(), botArg, ""). Return(nil, &model.Response{}, errors.New("mock error")). Times(1) s.client. EXPECT(). - GetUserByUsername(context.Background(), botArg, ""). + GetUserByUsername(context.TODO(), botArg, ""). Return(&mockUser, &model.Response{}, nil). Times(1) s.client. EXPECT(). - DisableBot(context.Background(), mockUser.Id). + DisableBot(context.TODO(), mockUser.Id). Return(&mockBot, &model.Response{}, nil). Times(1) @@ -448,19 +448,19 @@ func (s *MmctlUnitTestSuite) TestBotDisableCmd() { s.client. EXPECT(). - GetUserByEmail(context.Background(), botArg, ""). + GetUserByEmail(context.TODO(), botArg, ""). Return(nil, &model.Response{}, errors.New("mock error")). Times(1) s.client. EXPECT(). - GetUserByUsername(context.Background(), botArg, ""). + GetUserByUsername(context.TODO(), botArg, ""). Return(nil, &model.Response{}, errors.New("mock error")). Times(1) s.client. EXPECT(). - GetUser(context.Background(), botArg, ""). + GetUser(context.TODO(), botArg, ""). Return(nil, &model.Response{}, errors.New("mock error")). Times(1) @@ -483,19 +483,19 @@ func (s *MmctlUnitTestSuite) TestBotDisableCmd() { s.client. EXPECT(). - GetUserByEmail(context.Background(), botArg, ""). + GetUserByEmail(context.TODO(), botArg, ""). Return(nil, &model.Response{}, errors.New("mock error")). Times(1) s.client. EXPECT(). - GetUserByUsername(context.Background(), botArg, ""). + GetUserByUsername(context.TODO(), botArg, ""). Return(&mockUser, &model.Response{}, nil). Times(1) s.client. EXPECT(). - DisableBot(context.Background(), mockUser.Id). + DisableBot(context.TODO(), mockUser.Id). Return(nil, &model.Response{}, errors.New("mock error")). Times(1) @@ -517,19 +517,19 @@ func (s *MmctlUnitTestSuite) TestBotEnableCmd() { s.client. EXPECT(). - GetUserByEmail(context.Background(), botArg, ""). + GetUserByEmail(context.TODO(), botArg, ""). Return(nil, &model.Response{}, errors.New("mock error")). Times(1) s.client. EXPECT(). - GetUserByUsername(context.Background(), botArg, ""). + GetUserByUsername(context.TODO(), botArg, ""). Return(&mockUser, &model.Response{}, nil). Times(1) s.client. EXPECT(). - EnableBot(context.Background(), mockUser.Id). + EnableBot(context.TODO(), mockUser.Id). Return(&mockBot, &model.Response{}, nil). Times(1) @@ -546,19 +546,19 @@ func (s *MmctlUnitTestSuite) TestBotEnableCmd() { s.client. EXPECT(). - GetUserByEmail(context.Background(), botArg, ""). + GetUserByEmail(context.TODO(), botArg, ""). Return(nil, &model.Response{}, errors.New("mock error")). Times(1) s.client. EXPECT(). - GetUserByUsername(context.Background(), botArg, ""). + GetUserByUsername(context.TODO(), botArg, ""). Return(nil, &model.Response{}, errors.New("mock error")). Times(1) s.client. EXPECT(). - GetUser(context.Background(), botArg, ""). + GetUser(context.TODO(), botArg, ""). Return(nil, &model.Response{}, errors.New("mock error")). Times(1) @@ -581,19 +581,19 @@ func (s *MmctlUnitTestSuite) TestBotEnableCmd() { s.client. EXPECT(). - GetUserByEmail(context.Background(), botArg, ""). + GetUserByEmail(context.TODO(), botArg, ""). Return(nil, &model.Response{}, errors.New("mock error")). Times(1) s.client. EXPECT(). - GetUserByUsername(context.Background(), botArg, ""). + GetUserByUsername(context.TODO(), botArg, ""). Return(&mockUser, &model.Response{}, nil). Times(1) s.client. EXPECT(). - EnableBot(context.Background(), mockUser.Id). + EnableBot(context.TODO(), mockUser.Id). Return(nil, &model.Response{}, errors.New("mock error")). Times(1) @@ -617,31 +617,31 @@ func (s *MmctlUnitTestSuite) TestBotAssignCmd() { s.client. EXPECT(). - GetUserByEmail(context.Background(), botArg, ""). + GetUserByEmail(context.TODO(), botArg, ""). Return(nil, &model.Response{}, errors.New("mock error")). Times(1) s.client. EXPECT(). - GetUserByUsername(context.Background(), botArg, ""). + GetUserByUsername(context.TODO(), botArg, ""). Return(&mockBotUser, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetUserByEmail(context.Background(), userArg, ""). + GetUserByEmail(context.TODO(), userArg, ""). Return(nil, &model.Response{}, errors.New("mock error")). Times(1) s.client. EXPECT(). - GetUserByUsername(context.Background(), userArg, ""). + GetUserByUsername(context.TODO(), userArg, ""). Return(&mockNewOwner, &model.Response{}, nil). Times(1) s.client. EXPECT(). - AssignBot(context.Background(), mockBotUser.Id, mockNewOwner.Id). + AssignBot(context.TODO(), mockBotUser.Id, mockNewOwner.Id). Return(&mockBot, &model.Response{}, nil). Times(1) @@ -659,19 +659,19 @@ func (s *MmctlUnitTestSuite) TestBotAssignCmd() { s.client. EXPECT(). - GetUserByUsername(context.Background(), botArg, ""). + GetUserByUsername(context.TODO(), botArg, ""). Return(nil, &model.Response{}, errors.New("mock error")). Times(1) s.client. EXPECT(). - GetUser(context.Background(), botArg, ""). + GetUser(context.TODO(), botArg, ""). Return(nil, &model.Response{}, errors.New("mock error")). Times(1) s.client. EXPECT(). - GetUserByEmail(context.Background(), botArg, ""). + GetUserByEmail(context.TODO(), botArg, ""). Return(nil, &model.Response{}, errors.New("mock error")). Times(1) @@ -691,31 +691,31 @@ func (s *MmctlUnitTestSuite) TestBotAssignCmd() { s.client. EXPECT(). - GetUserByEmail(context.Background(), botArg, ""). + GetUserByEmail(context.TODO(), botArg, ""). Return(nil, &model.Response{}, errors.New("mock error")). Times(1) s.client. EXPECT(). - GetUserByUsername(context.Background(), botArg, ""). + GetUserByUsername(context.TODO(), botArg, ""). Return(&mockBotUser, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetUserByUsername(context.Background(), userArg, ""). + GetUserByUsername(context.TODO(), userArg, ""). Return(nil, &model.Response{}, errors.New("mock error")). Times(1) s.client. EXPECT(). - GetUser(context.Background(), userArg, ""). + GetUser(context.TODO(), userArg, ""). Return(nil, &model.Response{}, errors.New("mock error")). Times(1) s.client. EXPECT(). - GetUserByEmail(context.Background(), userArg, ""). + GetUserByEmail(context.TODO(), userArg, ""). Return(nil, &model.Response{}, errors.New("mock error")). Times(1) @@ -736,31 +736,31 @@ func (s *MmctlUnitTestSuite) TestBotAssignCmd() { s.client. EXPECT(). - GetUserByEmail(context.Background(), botArg, ""). + GetUserByEmail(context.TODO(), botArg, ""). Return(nil, &model.Response{}, errors.New("mock error")). Times(1) s.client. EXPECT(). - GetUserByUsername(context.Background(), botArg, ""). + GetUserByUsername(context.TODO(), botArg, ""). Return(&mockBotUser, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetUserByEmail(context.Background(), userArg, ""). + GetUserByEmail(context.TODO(), userArg, ""). Return(nil, &model.Response{}, errors.New("mock error")). Times(1) s.client. EXPECT(). - GetUserByUsername(context.Background(), userArg, ""). + GetUserByUsername(context.TODO(), userArg, ""). Return(&mockNewOwner, &model.Response{}, nil). Times(1) s.client. EXPECT(). - AssignBot(context.Background(), mockBotUser.Id, mockNewOwner.Id). + AssignBot(context.TODO(), mockBotUser.Id, mockNewOwner.Id). Return(nil, &model.Response{}, errors.New("mock error")). Times(1) diff --git a/server/cmd/mmctl/commands/channel_test.go b/server/cmd/mmctl/commands/channel_test.go index a6d70ea409..2a97ef77ca 100644 --- a/server/cmd/mmctl/commands/channel_test.go +++ b/server/cmd/mmctl/commands/channel_test.go @@ -41,13 +41,13 @@ func (s *MmctlUnitTestSuite) TestSearchChannelCmdF() { s.client. EXPECT(). - GetTeam(context.Background(), teamID, ""). + GetTeam(context.TODO(), teamID, ""). Return(&mockTeam, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetChannelByName(context.Background(), channelName, teamID, ""). + GetChannelByName(context.TODO(), channelName, teamID, ""). Return(&mockChannel, &model.Response{}, nil). Times(1) @@ -69,21 +69,21 @@ func (s *MmctlUnitTestSuite) TestSearchChannelCmdF() { s.client. EXPECT(). - GetAllTeams(context.Background(), "", 0, 9999). + GetAllTeams(context.TODO(), "", 0, 9999). Return(mockTeams, &model.Response{}, nil). Times(1) // first call is for the other team, that doesn't have the channel s.client. EXPECT(). - GetChannelByName(context.Background(), channelName, otherTeamID, ""). + GetChannelByName(context.TODO(), channelName, otherTeamID, ""). Return(nil, &model.Response{}, nil). Times(1) // second call is for the team that contains the channel s.client. EXPECT(). - GetChannelByName(context.Background(), channelName, teamID, ""). + GetChannelByName(context.TODO(), channelName, teamID, ""). Return(&mockChannel, &model.Response{}, nil). Times(1) @@ -103,13 +103,13 @@ func (s *MmctlUnitTestSuite) TestSearchChannelCmdF() { s.client. EXPECT(). - GetTeam(context.Background(), teamID, ""). + GetTeam(context.TODO(), teamID, ""). Return(&mockTeam, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetChannelByName(context.Background(), channelName, teamID, ""). + GetChannelByName(context.TODO(), channelName, teamID, ""). Return(nil, &model.Response{}, nil). Times(1) @@ -128,13 +128,13 @@ func (s *MmctlUnitTestSuite) TestSearchChannelCmdF() { s.client. EXPECT(). - GetTeam(context.Background(), teamID, ""). + GetTeam(context.TODO(), teamID, ""). Return(nil, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetTeamByName(context.Background(), teamID, ""). + GetTeamByName(context.TODO(), teamID, ""). Return(nil, &model.Response{}, nil). Times(1) @@ -186,7 +186,7 @@ func (s *MmctlUnitTestSuite) TestModifyChannelCmdF() { s.client. EXPECT(). - GetChannel(context.Background(), args[0], ""). + GetChannel(context.TODO(), args[0], ""). Return(nil, &model.Response{}, errors.New("")). Times(1) @@ -209,13 +209,13 @@ func (s *MmctlUnitTestSuite) TestModifyChannelCmdF() { s.client. EXPECT(). - GetTeam(context.Background(), team, ""). + GetTeam(context.TODO(), team, ""). Return(nil, &model.Response{}, errors.New("")). Times(1) s.client. EXPECT(). - GetTeamByName(context.Background(), team, ""). + GetTeamByName(context.TODO(), team, ""). Return(nil, &model.Response{}, errors.New("")). Times(1) @@ -240,7 +240,7 @@ func (s *MmctlUnitTestSuite) TestModifyChannelCmdF() { s.client. EXPECT(). - GetChannel(context.Background(), args[0], ""). + GetChannel(context.TODO(), args[0], ""). Return(channel, &model.Response{}, nil). Times(1) @@ -265,7 +265,7 @@ func (s *MmctlUnitTestSuite) TestModifyChannelCmdF() { s.client. EXPECT(). - GetChannel(context.Background(), args[0], ""). + GetChannel(context.TODO(), args[0], ""). Return(channel, &model.Response{}, nil). Times(1) @@ -292,13 +292,13 @@ func (s *MmctlUnitTestSuite) TestModifyChannelCmdF() { s.client. EXPECT(). - GetChannel(context.Background(), args[0], ""). + GetChannel(context.TODO(), args[0], ""). Return(channel, &model.Response{}, nil). Times(1) s.client. EXPECT(). - UpdateChannelPrivacy(context.Background(), channel.Id, model.ChannelTypeOpen). + UpdateChannelPrivacy(context.TODO(), channel.Id, model.ChannelTypeOpen). Return(nil, &model.Response{}, mockError). Times(1) @@ -327,13 +327,13 @@ func (s *MmctlUnitTestSuite) TestModifyChannelCmdF() { s.client. EXPECT(). - GetChannel(context.Background(), args[0], ""). + GetChannel(context.TODO(), args[0], ""). Return(channel, &model.Response{}, nil). Times(1) s.client. EXPECT(). - UpdateChannelPrivacy(context.Background(), channel.Id, model.ChannelTypeOpen). + UpdateChannelPrivacy(context.TODO(), channel.Id, model.ChannelTypeOpen). Return(returnedChannel, &model.Response{}, nil). Times(1) @@ -362,13 +362,13 @@ func (s *MmctlUnitTestSuite) TestModifyChannelCmdF() { s.client. EXPECT(). - GetChannel(context.Background(), args[0], ""). + GetChannel(context.TODO(), args[0], ""). Return(channel, &model.Response{}, nil). Times(1) s.client. EXPECT(). - UpdateChannelPrivacy(context.Background(), channel.Id, model.ChannelTypePrivate). + UpdateChannelPrivacy(context.TODO(), channel.Id, model.ChannelTypePrivate). Return(returnedChannel, &model.Response{}, nil). Times(1) @@ -405,19 +405,19 @@ func (s *MmctlUnitTestSuite) TestArchiveChannelCmdF() { s.client. EXPECT(). - GetTeam(context.Background(), teamID, ""). + GetTeam(context.TODO(), teamID, ""). Return(&mockTeam, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetChannelByNameIncludeDeleted(context.Background(), channelName, teamID, ""). + GetChannelByNameIncludeDeleted(context.TODO(), channelName, teamID, ""). Return(&mockChannel, &model.Response{}, nil). Times(1) s.client. EXPECT(). - DeleteChannel(context.Background(), channelID). + DeleteChannel(context.TODO(), channelID). Return(&model.Response{StatusCode: http.StatusOK}, nil). Times(1) @@ -437,13 +437,13 @@ func (s *MmctlUnitTestSuite) TestArchiveChannelCmdF() { s.client. EXPECT(). - GetChannel(context.Background(), channelName, ""). + GetChannel(context.TODO(), channelName, ""). Return(&mockChannel, &model.Response{}, nil). Times(1) s.client. EXPECT(). - DeleteChannel(context.Background(), channelID). + DeleteChannel(context.TODO(), channelID). Return(&model.Response{StatusCode: http.StatusOK}, nil). Times(1) @@ -469,25 +469,25 @@ func (s *MmctlUnitTestSuite) TestArchiveChannelCmdF() { s.client. EXPECT(). - GetChannel(context.Background(), channelArg1, ""). + GetChannel(context.TODO(), channelArg1, ""). Return(&mockChannel1, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetChannel(context.Background(), channelArg2, ""). + GetChannel(context.TODO(), channelArg2, ""). Return(&mockChannel2, &model.Response{}, nil). Times(1) s.client. EXPECT(). - DeleteChannel(context.Background(), channelID1). + DeleteChannel(context.TODO(), channelID1). Return(&model.Response{StatusCode: http.StatusOK}, nil). Times(1) s.client. EXPECT(). - DeleteChannel(context.Background(), channelID2). + DeleteChannel(context.TODO(), channelID2). Return(&model.Response{StatusCode: http.StatusOK}, nil). Times(1) @@ -508,13 +508,13 @@ func (s *MmctlUnitTestSuite) TestArchiveChannelCmdF() { s.client. EXPECT(). - GetTeam(context.Background(), teamArg, ""). + GetTeam(context.TODO(), teamArg, ""). Return(nil, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetTeamByName(context.Background(), teamArg, ""). + GetTeamByName(context.TODO(), teamArg, ""). Return(nil, &model.Response{}, nil). Times(1) @@ -540,19 +540,19 @@ func (s *MmctlUnitTestSuite) TestArchiveChannelCmdF() { s.client. EXPECT(). - GetTeam(context.Background(), teamArg, ""). + GetTeam(context.TODO(), teamArg, ""). Return(&mockTeam, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetChannelByNameIncludeDeleted(context.Background(), channelArg, teamArg, ""). + GetChannelByNameIncludeDeleted(context.TODO(), channelArg, teamArg, ""). Return(nil, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetChannel(context.Background(), channelArg, ""). + GetChannel(context.TODO(), channelArg, ""). Return(nil, &model.Response{}, nil). Times(1) @@ -575,7 +575,7 @@ func (s *MmctlUnitTestSuite) TestArchiveChannelCmdF() { s.client. EXPECT(). - GetChannel(context.Background(), channelArg, ""). + GetChannel(context.TODO(), channelArg, ""). Return(nil, &model.Response{}, nil). Times(1) @@ -601,14 +601,14 @@ func (s *MmctlUnitTestSuite) TestArchiveChannelCmdF() { s.client. EXPECT(). - GetChannel(context.Background(), channelArg, ""). + GetChannel(context.TODO(), channelArg, ""). Return(&mockChannel, &model.Response{}, nil). Times(1) mockErr := errors.New("mock error") s.client. EXPECT(). - DeleteChannel(context.Background(), channelID). + DeleteChannel(context.TODO(), channelID). Return(&model.Response{StatusCode: http.StatusBadRequest}, mockErr). Times(1) @@ -658,13 +658,13 @@ func (s *MmctlUnitTestSuite) TestListChannelsCmd() { s.client. EXPECT(). - GetTeam(context.Background(), teamID, ""). + GetTeam(context.TODO(), teamID, ""). Return(nil, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetTeamByName(context.Background(), teamID, ""). + GetTeamByName(context.TODO(), teamID, ""). Return(nil, &model.Response{}, nil). Times(1) @@ -694,30 +694,30 @@ func (s *MmctlUnitTestSuite) TestListChannelsCmd() { s.client. EXPECT(). - GetTeam(context.Background(), teamID, ""). + GetTeam(context.TODO(), teamID, ""). Return(team, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetPublicChannelsForTeam(context.Background(), teamID, 0, web.PerPageMaximum, ""). + GetPublicChannelsForTeam(context.TODO(), teamID, 0, web.PerPageMaximum, ""). Return(publicChannels, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetDeletedChannelsForTeam(context.Background(), teamID, 0, web.PerPageMaximum, ""). + GetDeletedChannelsForTeam(context.TODO(), teamID, 0, web.PerPageMaximum, ""). Return(archivedChannels, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetPrivateChannelsForTeam(context.Background(), teamID, 0, web.PerPageMaximum, ""). + GetPrivateChannelsForTeam(context.TODO(), teamID, 0, web.PerPageMaximum, ""). Return(privateChannels, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetChannelsForTeamForUser(context.Background(), teamID, "me", false, ""). + GetChannelsForTeamForUser(context.TODO(), teamID, "me", false, ""). Return(userChannels, &model.Response{}, nil). Times(0) @@ -751,37 +751,37 @@ func (s *MmctlUnitTestSuite) TestListChannelsCmd() { s.client. EXPECT(). - GetTeam(context.Background(), teamID, ""). + GetTeam(context.TODO(), teamID, ""). Return(team, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetPublicChannelsForTeam(context.Background(), teamID, 0, web.PerPageMaximum, ""). + GetPublicChannelsForTeam(context.TODO(), teamID, 0, web.PerPageMaximum, ""). Return(publicChannels, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetPublicChannelsForTeam(context.Background(), teamID, 1, web.PerPageMaximum, ""). + GetPublicChannelsForTeam(context.TODO(), teamID, 1, web.PerPageMaximum, ""). Return(emptyChannels, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetDeletedChannelsForTeam(context.Background(), teamID, 0, web.PerPageMaximum, ""). + GetDeletedChannelsForTeam(context.TODO(), teamID, 0, web.PerPageMaximum, ""). Return(archivedChannels, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetPrivateChannelsForTeam(context.Background(), teamID, 0, web.PerPageMaximum, ""). + GetPrivateChannelsForTeam(context.TODO(), teamID, 0, web.PerPageMaximum, ""). Return(privateChannels, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetChannelsForTeamForUser(context.Background(), teamID, "me", false, ""). + GetChannelsForTeamForUser(context.TODO(), teamID, "me", false, ""). Return(userChannels, &model.Response{}, nil). Times(0) @@ -817,37 +817,37 @@ func (s *MmctlUnitTestSuite) TestListChannelsCmd() { s.client. EXPECT(). - GetTeam(context.Background(), teamID, ""). + GetTeam(context.TODO(), teamID, ""). Return(team, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetPublicChannelsForTeam(context.Background(), teamID, 0, web.PerPageMaximum, ""). + GetPublicChannelsForTeam(context.TODO(), teamID, 0, web.PerPageMaximum, ""). Return(publicChannels, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetDeletedChannelsForTeam(context.Background(), teamID, 0, web.PerPageMaximum, ""). + GetDeletedChannelsForTeam(context.TODO(), teamID, 0, web.PerPageMaximum, ""). Return(archivedChannels, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetDeletedChannelsForTeam(context.Background(), teamID, 1, web.PerPageMaximum, ""). + GetDeletedChannelsForTeam(context.TODO(), teamID, 1, web.PerPageMaximum, ""). Return(emptyChannels, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetPrivateChannelsForTeam(context.Background(), teamID, 0, web.PerPageMaximum, ""). + GetPrivateChannelsForTeam(context.TODO(), teamID, 0, web.PerPageMaximum, ""). Return(privateChannels, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetChannelsForTeamForUser(context.Background(), teamID, "me", false, ""). + GetChannelsForTeamForUser(context.TODO(), teamID, "me", false, ""). Return(userChannels, &model.Response{}, nil). Times(0) @@ -885,49 +885,49 @@ func (s *MmctlUnitTestSuite) TestListChannelsCmd() { s.client. EXPECT(). - GetTeam(context.Background(), teamID, ""). + GetTeam(context.TODO(), teamID, ""). Return(team, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetPublicChannelsForTeam(context.Background(), teamID, 0, web.PerPageMaximum, ""). + GetPublicChannelsForTeam(context.TODO(), teamID, 0, web.PerPageMaximum, ""). Return(publicChannels, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetPublicChannelsForTeam(context.Background(), teamID, 1, web.PerPageMaximum, ""). + GetPublicChannelsForTeam(context.TODO(), teamID, 1, web.PerPageMaximum, ""). Return(emptyChannels, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetDeletedChannelsForTeam(context.Background(), teamID, 0, web.PerPageMaximum, ""). + GetDeletedChannelsForTeam(context.TODO(), teamID, 0, web.PerPageMaximum, ""). Return(archivedChannels, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetDeletedChannelsForTeam(context.Background(), teamID, 1, web.PerPageMaximum, ""). + GetDeletedChannelsForTeam(context.TODO(), teamID, 1, web.PerPageMaximum, ""). Return(emptyChannels, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetPrivateChannelsForTeam(context.Background(), teamID, 0, web.PerPageMaximum, ""). + GetPrivateChannelsForTeam(context.TODO(), teamID, 0, web.PerPageMaximum, ""). Return(privateChannels, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetPrivateChannelsForTeam(context.Background(), teamID, 1, web.PerPageMaximum, ""). + GetPrivateChannelsForTeam(context.TODO(), teamID, 1, web.PerPageMaximum, ""). Return(emptyChannels, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetChannelsForTeamForUser(context.Background(), teamID, "me", false, ""). + GetChannelsForTeamForUser(context.TODO(), teamID, "me", false, ""). Return(userChannels, &model.Response{}, nil). Times(0) @@ -966,30 +966,30 @@ func (s *MmctlUnitTestSuite) TestListChannelsCmd() { s.client. EXPECT(). - GetTeam(context.Background(), teamID, ""). + GetTeam(context.TODO(), teamID, ""). Return(team, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetPublicChannelsForTeam(context.Background(), teamID, 0, web.PerPageMaximum, ""). + GetPublicChannelsForTeam(context.TODO(), teamID, 0, web.PerPageMaximum, ""). Return(emptyChannels, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetDeletedChannelsForTeam(context.Background(), teamID, 0, web.PerPageMaximum, ""). + GetDeletedChannelsForTeam(context.TODO(), teamID, 0, web.PerPageMaximum, ""). Return(emptyChannels, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetPrivateChannelsForTeam(context.Background(), teamID, 0, web.PerPageMaximum, ""). + GetPrivateChannelsForTeam(context.TODO(), teamID, 0, web.PerPageMaximum, ""). Return(nil, &model.Response{}, mockError). Times(1) s.client. EXPECT(). - GetChannelsForTeamForUser(context.Background(), teamID, "me", false, ""). + GetChannelsForTeamForUser(context.TODO(), teamID, "me", false, ""). Return(userChannels, &model.Response{}, nil). Times(1) @@ -1016,31 +1016,31 @@ func (s *MmctlUnitTestSuite) TestListChannelsCmd() { s.client. EXPECT(). - GetTeam(context.Background(), teamID, ""). + GetTeam(context.TODO(), teamID, ""). Return(team, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetPublicChannelsForTeam(context.Background(), teamID, 0, web.PerPageMaximum, ""). + GetPublicChannelsForTeam(context.TODO(), teamID, 0, web.PerPageMaximum, ""). Return(nil, &model.Response{}, mockError). Times(1) s.client. EXPECT(). - GetDeletedChannelsForTeam(context.Background(), teamID, 0, web.PerPageMaximum, ""). + GetDeletedChannelsForTeam(context.TODO(), teamID, 0, web.PerPageMaximum, ""). Return(emptyChannels, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetPrivateChannelsForTeam(context.Background(), teamID, 0, web.PerPageMaximum, ""). + GetPrivateChannelsForTeam(context.TODO(), teamID, 0, web.PerPageMaximum, ""). Return(emptyChannels, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetChannelsForTeamForUser(context.Background(), teamID, "me", false, ""). + GetChannelsForTeamForUser(context.TODO(), teamID, "me", false, ""). Return(emptyChannels, &model.Response{}, nil). Times(0) @@ -1065,30 +1065,30 @@ func (s *MmctlUnitTestSuite) TestListChannelsCmd() { s.client. EXPECT(). - GetTeam(context.Background(), teamID, ""). + GetTeam(context.TODO(), teamID, ""). Return(team, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetPublicChannelsForTeam(context.Background(), teamID, 0, web.PerPageMaximum, ""). + GetPublicChannelsForTeam(context.TODO(), teamID, 0, web.PerPageMaximum, ""). Return(emptyChannels, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetDeletedChannelsForTeam(context.Background(), teamID, 0, web.PerPageMaximum, ""). + GetDeletedChannelsForTeam(context.TODO(), teamID, 0, web.PerPageMaximum, ""). Return(nil, &model.Response{}, mockError). Times(1) s.client. EXPECT(). - GetPrivateChannelsForTeam(context.Background(), teamID, 0, web.PerPageMaximum, ""). + GetPrivateChannelsForTeam(context.TODO(), teamID, 0, web.PerPageMaximum, ""). Return(emptyChannels, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetChannelsForTeamForUser(context.Background(), teamID, "me", false, ""). + GetChannelsForTeamForUser(context.TODO(), teamID, "me", false, ""). Return(emptyChannels, &model.Response{}, nil). Times(0) @@ -1113,31 +1113,31 @@ func (s *MmctlUnitTestSuite) TestListChannelsCmd() { s.client. EXPECT(). - GetTeam(context.Background(), teamID, ""). + GetTeam(context.TODO(), teamID, ""). Return(team, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetPublicChannelsForTeam(context.Background(), teamID, 0, web.PerPageMaximum, ""). + GetPublicChannelsForTeam(context.TODO(), teamID, 0, web.PerPageMaximum, ""). Return(emptyChannels, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetDeletedChannelsForTeam(context.Background(), teamID, 0, web.PerPageMaximum, ""). + GetDeletedChannelsForTeam(context.TODO(), teamID, 0, web.PerPageMaximum, ""). Return(nil, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetPrivateChannelsForTeam(context.Background(), teamID, 0, web.PerPageMaximum, ""). + GetPrivateChannelsForTeam(context.TODO(), teamID, 0, web.PerPageMaximum, ""). Return(emptyChannels, &model.Response{}, mockError). Times(1) s.client. EXPECT(). - GetChannelsForTeamForUser(context.Background(), teamID, "me", false, ""). + GetChannelsForTeamForUser(context.TODO(), teamID, "me", false, ""). Return(emptyChannels, &model.Response{}, mockError). Times(1) // falls through to GetChannelsForTeamForUser in non-local mode @@ -1164,31 +1164,31 @@ func (s *MmctlUnitTestSuite) TestListChannelsCmd() { s.client. EXPECT(). - GetTeam(context.Background(), teamID, ""). + GetTeam(context.TODO(), teamID, ""). Return(team, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetPublicChannelsForTeam(context.Background(), teamID, 0, web.PerPageMaximum, ""). + GetPublicChannelsForTeam(context.TODO(), teamID, 0, web.PerPageMaximum, ""). Return(emptyChannels, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetDeletedChannelsForTeam(context.Background(), teamID, 0, web.PerPageMaximum, ""). + GetDeletedChannelsForTeam(context.TODO(), teamID, 0, web.PerPageMaximum, ""). Return(nil, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetPrivateChannelsForTeam(context.Background(), teamID, 0, web.PerPageMaximum, ""). + GetPrivateChannelsForTeam(context.TODO(), teamID, 0, web.PerPageMaximum, ""). Return(emptyChannels, &model.Response{}, mockError). Times(1) s.client. EXPECT(). - GetChannelsForTeamForUser(context.Background(), teamID, "me", false, ""). + GetChannelsForTeamForUser(context.TODO(), teamID, "me", false, ""). Return(emptyChannels, &model.Response{}, mockError). Times(0) // does not fall through to GetChannelsForTeamForUser in local mode @@ -1216,31 +1216,31 @@ func (s *MmctlUnitTestSuite) TestListChannelsCmd() { s.client. EXPECT(). - GetTeam(context.Background(), teamID, ""). + GetTeam(context.TODO(), teamID, ""). Return(team, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetPublicChannelsForTeam(context.Background(), teamID, 0, web.PerPageMaximum, ""). + GetPublicChannelsForTeam(context.TODO(), teamID, 0, web.PerPageMaximum, ""). Return(nil, &model.Response{}, mockError). Times(1) s.client. EXPECT(). - GetDeletedChannelsForTeam(context.Background(), teamID, 0, web.PerPageMaximum, ""). + GetDeletedChannelsForTeam(context.TODO(), teamID, 0, web.PerPageMaximum, ""). Return(nil, &model.Response{}, mockError). Times(1) s.client. EXPECT(). - GetPrivateChannelsForTeam(context.Background(), teamID, 0, web.PerPageMaximum, ""). + GetPrivateChannelsForTeam(context.TODO(), teamID, 0, web.PerPageMaximum, ""). Return(nil, &model.Response{}, mockError). Times(1) s.client. EXPECT(). - GetChannelsForTeamForUser(context.Background(), teamID, "me", false, ""). + GetChannelsForTeamForUser(context.TODO(), teamID, "me", false, ""). Return(nil, &model.Response{}, mockError). Times(1) @@ -1276,60 +1276,60 @@ func (s *MmctlUnitTestSuite) TestListChannelsCmd() { s.client. EXPECT(). - GetTeam(context.Background(), teamID1, ""). + GetTeam(context.TODO(), teamID1, ""). Return(team1, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetTeam(context.Background(), teamID2, ""). + GetTeam(context.TODO(), teamID2, ""). Return(nil, &model.Response{}, nil). // Team 2 not found Times(1) s.client. EXPECT(). - GetTeamByName(context.Background(), teamID2, ""). + GetTeamByName(context.TODO(), teamID2, ""). Return(nil, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetPublicChannelsForTeam(context.Background(), teamID1, 0, web.PerPageMaximum, ""). + GetPublicChannelsForTeam(context.TODO(), teamID1, 0, web.PerPageMaximum, ""). Return(publicChannels, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetPublicChannelsForTeam(context.Background(), teamID1, 1, web.PerPageMaximum, ""). + GetPublicChannelsForTeam(context.TODO(), teamID1, 1, web.PerPageMaximum, ""). Return(emptyChannels, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetDeletedChannelsForTeam(context.Background(), teamID1, 0, web.PerPageMaximum, ""). + GetDeletedChannelsForTeam(context.TODO(), teamID1, 0, web.PerPageMaximum, ""). Return(archivedChannels, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetDeletedChannelsForTeam(context.Background(), teamID1, 1, web.PerPageMaximum, ""). + GetDeletedChannelsForTeam(context.TODO(), teamID1, 1, web.PerPageMaximum, ""). Return(emptyChannels, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetPrivateChannelsForTeam(context.Background(), teamID1, 0, web.PerPageMaximum, ""). + GetPrivateChannelsForTeam(context.TODO(), teamID1, 0, web.PerPageMaximum, ""). Return(privateChannels, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetPrivateChannelsForTeam(context.Background(), teamID1, 1, web.PerPageMaximum, ""). + GetPrivateChannelsForTeam(context.TODO(), teamID1, 1, web.PerPageMaximum, ""). Return(emptyChannels, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetChannelsForTeamForUser(context.Background(), teamID1, "me", false, ""). + GetChannelsForTeamForUser(context.TODO(), teamID1, "me", false, ""). Return(privateChannels, &model.Response{}, nil). Times(0) @@ -1368,49 +1368,49 @@ func (s *MmctlUnitTestSuite) TestListChannelsCmd() { s.client. EXPECT(). - GetTeam(context.Background(), teamID1, ""). + GetTeam(context.TODO(), teamID1, ""). Return(team1, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetPublicChannelsForTeam(context.Background(), teamID1, 0, web.PerPageMaximum, ""). + GetPublicChannelsForTeam(context.TODO(), teamID1, 0, web.PerPageMaximum, ""). Return(publicChannels, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetPublicChannelsForTeam(context.Background(), teamID1, 1, web.PerPageMaximum, ""). + GetPublicChannelsForTeam(context.TODO(), teamID1, 1, web.PerPageMaximum, ""). Return(emptyChannels, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetDeletedChannelsForTeam(context.Background(), teamID1, 0, web.PerPageMaximum, ""). + GetDeletedChannelsForTeam(context.TODO(), teamID1, 0, web.PerPageMaximum, ""). Return(archivedChannels, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetDeletedChannelsForTeam(context.Background(), teamID1, 1, web.PerPageMaximum, ""). + GetDeletedChannelsForTeam(context.TODO(), teamID1, 1, web.PerPageMaximum, ""). Return(emptyChannels, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetPrivateChannelsForTeam(context.Background(), teamID1, 0, web.PerPageMaximum, ""). + GetPrivateChannelsForTeam(context.TODO(), teamID1, 0, web.PerPageMaximum, ""). Return(privateChannels, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetPrivateChannelsForTeam(context.Background(), teamID1, 1, web.PerPageMaximum, ""). + GetPrivateChannelsForTeam(context.TODO(), teamID1, 1, web.PerPageMaximum, ""). Return(emptyChannels, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetChannelsForTeamForUser(context.Background(), teamID1, "me", false, ""). + GetChannelsForTeamForUser(context.TODO(), teamID1, "me", false, ""). Return(privateChannels, &model.Response{}, nil). Times(0) @@ -1418,30 +1418,30 @@ func (s *MmctlUnitTestSuite) TestListChannelsCmd() { s.client. EXPECT(). - GetTeam(context.Background(), teamID2, ""). + GetTeam(context.TODO(), teamID2, ""). Return(team2, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetPublicChannelsForTeam(context.Background(), teamID2, 0, web.PerPageMaximum, ""). + GetPublicChannelsForTeam(context.TODO(), teamID2, 0, web.PerPageMaximum, ""). Return(nil, &model.Response{}, mockError). Times(1) s.client. EXPECT(). - GetDeletedChannelsForTeam(context.Background(), teamID2, 0, web.PerPageMaximum, ""). + GetDeletedChannelsForTeam(context.TODO(), teamID2, 0, web.PerPageMaximum, ""). Return(nil, &model.Response{}, mockError). Times(1) s.client. EXPECT(). - GetPrivateChannelsForTeam(context.Background(), teamID2, 0, web.PerPageMaximum, ""). + GetPrivateChannelsForTeam(context.TODO(), teamID2, 0, web.PerPageMaximum, ""). Return(privateChannels, &model.Response{}, mockError). Times(1) s.client. EXPECT(). - GetChannelsForTeamForUser(context.Background(), teamID2, "me", false, ""). + GetChannelsForTeamForUser(context.TODO(), teamID2, "me", false, ""). Return(privateChannels, &model.Response{}, mockError). Times(1) @@ -1466,23 +1466,23 @@ func (s *MmctlUnitTestSuite) TestListChannelsCmd() { s.client. EXPECT(). - GetTeam(context.Background(), team1ID, ""). + GetTeam(context.TODO(), team1ID, ""). Return(nil, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetTeam(context.Background(), team2ID, ""). + GetTeam(context.TODO(), team2ID, ""). Return(nil, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetTeamByName(context.Background(), team1ID, ""). + GetTeamByName(context.TODO(), team1ID, ""). Return(nil, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetTeamByName(context.Background(), team2ID, ""). + GetTeamByName(context.TODO(), team2ID, ""). Return(nil, &model.Response{}, nil). Times(1) @@ -1520,97 +1520,97 @@ func (s *MmctlUnitTestSuite) TestListChannelsCmd() { s.client. EXPECT(). - GetTeam(context.Background(), teamID1, ""). + GetTeam(context.TODO(), teamID1, ""). Return(team1, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetPublicChannelsForTeam(context.Background(), teamID1, 0, web.PerPageMaximum, ""). + GetPublicChannelsForTeam(context.TODO(), teamID1, 0, web.PerPageMaximum, ""). Return(publicChannels, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetPublicChannelsForTeam(context.Background(), teamID1, 1, web.PerPageMaximum, ""). + GetPublicChannelsForTeam(context.TODO(), teamID1, 1, web.PerPageMaximum, ""). Return(emptyChannels, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetDeletedChannelsForTeam(context.Background(), teamID1, 0, web.PerPageMaximum, ""). + GetDeletedChannelsForTeam(context.TODO(), teamID1, 0, web.PerPageMaximum, ""). Return(archivedChannels, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetDeletedChannelsForTeam(context.Background(), teamID1, 1, web.PerPageMaximum, ""). + GetDeletedChannelsForTeam(context.TODO(), teamID1, 1, web.PerPageMaximum, ""). Return(emptyChannels, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetPrivateChannelsForTeam(context.Background(), teamID1, 0, web.PerPageMaximum, ""). + GetPrivateChannelsForTeam(context.TODO(), teamID1, 0, web.PerPageMaximum, ""). Return(privateChannels, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetPrivateChannelsForTeam(context.Background(), teamID1, 1, web.PerPageMaximum, ""). + GetPrivateChannelsForTeam(context.TODO(), teamID1, 1, web.PerPageMaximum, ""). Return(emptyChannels, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetChannelsForTeamForUser(context.Background(), teamID1, "me", false, ""). + GetChannelsForTeamForUser(context.TODO(), teamID1, "me", false, ""). Return(privateChannels, &model.Response{}, nil). Times(0) s.client. EXPECT(). - GetTeam(context.Background(), teamID2, ""). + GetTeam(context.TODO(), teamID2, ""). Return(team2, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetPublicChannelsForTeam(context.Background(), teamID2, 0, web.PerPageMaximum, ""). + GetPublicChannelsForTeam(context.TODO(), teamID2, 0, web.PerPageMaximum, ""). Return(publicChannels, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetPublicChannelsForTeam(context.Background(), teamID2, 1, web.PerPageMaximum, ""). + GetPublicChannelsForTeam(context.TODO(), teamID2, 1, web.PerPageMaximum, ""). Return(emptyChannels, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetDeletedChannelsForTeam(context.Background(), teamID2, 0, web.PerPageMaximum, ""). + GetDeletedChannelsForTeam(context.TODO(), teamID2, 0, web.PerPageMaximum, ""). Return(archivedChannels, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetDeletedChannelsForTeam(context.Background(), teamID2, 1, web.PerPageMaximum, ""). + GetDeletedChannelsForTeam(context.TODO(), teamID2, 1, web.PerPageMaximum, ""). Return(emptyChannels, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetPrivateChannelsForTeam(context.Background(), teamID2, 0, web.PerPageMaximum, ""). + GetPrivateChannelsForTeam(context.TODO(), teamID2, 0, web.PerPageMaximum, ""). Return(privateChannels, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetPrivateChannelsForTeam(context.Background(), teamID2, 1, web.PerPageMaximum, ""). + GetPrivateChannelsForTeam(context.TODO(), teamID2, 1, web.PerPageMaximum, ""). Return(emptyChannels, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetChannelsForTeamForUser(context.Background(), teamID2, "me", false, ""). + GetChannelsForTeamForUser(context.TODO(), teamID2, "me", false, ""). Return(privateChannels, &model.Response{}, nil). Times(0) @@ -1664,19 +1664,19 @@ func (s *MmctlUnitTestSuite) TestUnarchiveChannelCmdF() { s.client. EXPECT(). - GetTeam(context.Background(), teamID, ""). + GetTeam(context.TODO(), teamID, ""). Return(&mockTeam, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetChannelByNameIncludeDeleted(context.Background(), channelName, teamID, ""). + GetChannelByNameIncludeDeleted(context.TODO(), channelName, teamID, ""). Return(&mockChannel, &model.Response{}, nil). Times(1) s.client. EXPECT(). - RestoreChannel(context.Background(), channelID). + RestoreChannel(context.TODO(), channelID). Return(&mockChannel, &model.Response{}, nil). Times(1) @@ -1696,13 +1696,13 @@ func (s *MmctlUnitTestSuite) TestUnarchiveChannelCmdF() { s.client. EXPECT(). - GetChannel(context.Background(), channelName, ""). + GetChannel(context.TODO(), channelName, ""). Return(&mockChannel, &model.Response{}, nil). Times(1) s.client. EXPECT(). - RestoreChannel(context.Background(), channelID). + RestoreChannel(context.TODO(), channelID). Return(&mockChannel, &model.Response{}, nil). Times(1) @@ -1728,25 +1728,25 @@ func (s *MmctlUnitTestSuite) TestUnarchiveChannelCmdF() { s.client. EXPECT(). - GetChannel(context.Background(), channelArg1, ""). + GetChannel(context.TODO(), channelArg1, ""). Return(&mockChannel1, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetChannel(context.Background(), channelArg2, ""). + GetChannel(context.TODO(), channelArg2, ""). Return(&mockChannel2, &model.Response{}, nil). Times(1) s.client. EXPECT(). - RestoreChannel(context.Background(), channelID1). + RestoreChannel(context.TODO(), channelID1). Return(&mockChannel1, &model.Response{}, nil). Times(1) s.client. EXPECT(). - RestoreChannel(context.Background(), channelID2). + RestoreChannel(context.TODO(), channelID2). Return(&mockChannel2, &model.Response{}, nil). Times(1) @@ -1766,13 +1766,13 @@ func (s *MmctlUnitTestSuite) TestUnarchiveChannelCmdF() { s.client. EXPECT(). - GetTeam(context.Background(), teamArg, ""). + GetTeam(context.TODO(), teamArg, ""). Return(nil, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetTeamByName(context.Background(), teamArg, ""). + GetTeamByName(context.TODO(), teamArg, ""). Return(nil, &model.Response{}, nil). Times(1) @@ -1798,19 +1798,19 @@ func (s *MmctlUnitTestSuite) TestUnarchiveChannelCmdF() { s.client. EXPECT(). - GetTeam(context.Background(), teamArg, ""). + GetTeam(context.TODO(), teamArg, ""). Return(&mockTeam, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetChannelByNameIncludeDeleted(context.Background(), channelArg, teamArg, ""). + GetChannelByNameIncludeDeleted(context.TODO(), channelArg, teamArg, ""). Return(nil, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetChannel(context.Background(), channelArg, ""). + GetChannel(context.TODO(), channelArg, ""). Return(nil, &model.Response{}, nil). Times(1) @@ -1833,7 +1833,7 @@ func (s *MmctlUnitTestSuite) TestUnarchiveChannelCmdF() { s.client. EXPECT(). - GetChannel(context.Background(), channelArg, ""). + GetChannel(context.TODO(), channelArg, ""). Return(nil, &model.Response{}, nil). Times(1) @@ -1857,14 +1857,14 @@ func (s *MmctlUnitTestSuite) TestUnarchiveChannelCmdF() { s.client. EXPECT(). - GetChannel(context.Background(), channelName, ""). + GetChannel(context.TODO(), channelName, ""). Return(&mockChannel, &model.Response{}, nil). Times(1) mockErr := errors.New("mock error") s.client. EXPECT(). - RestoreChannel(context.Background(), channelID). + RestoreChannel(context.TODO(), channelID). Return(nil, &model.Response{}, mockErr). Times(1) @@ -1952,25 +1952,25 @@ func (s *MmctlUnitTestSuite) TestRenameChannelCmd() { } s.client. EXPECT(). - GetTeam(context.Background(), teamName, ""). + GetTeam(context.TODO(), teamName, ""). Return(nil, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetTeamByName(context.Background(), teamName, ""). + GetTeamByName(context.TODO(), teamName, ""). Return(foundTeam, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetChannelByNameIncludeDeleted(context.Background(), channelName, foundTeam.Id, ""). + GetChannelByNameIncludeDeleted(context.TODO(), channelName, foundTeam.Id, ""). Return(nil, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetChannel(context.Background(), channelName, ""). + GetChannel(context.TODO(), channelName, ""). Return(nil, &model.Response{}, nil). Times(1) @@ -1995,7 +1995,7 @@ func (s *MmctlUnitTestSuite) TestRenameChannelCmd() { s.client. EXPECT(). - GetChannel(context.Background(), channelName, ""). + GetChannel(context.TODO(), channelName, ""). Return(nil, &model.Response{}, nil). Times(1) @@ -2019,13 +2019,13 @@ func (s *MmctlUnitTestSuite) TestRenameChannelCmd() { s.client. EXPECT(). - GetTeam(context.Background(), teamName, ""). + GetTeam(context.TODO(), teamName, ""). Return(nil, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetTeamByName(context.Background(), teamName, ""). + GetTeamByName(context.TODO(), teamName, ""). Return(nil, &model.Response{}, nil). Times(1) @@ -2049,7 +2049,7 @@ func (s *MmctlUnitTestSuite) TestRenameChannelCmd() { s.client. EXPECT(). - GetTeam(context.Background(), teamName, ""). + GetTeam(context.TODO(), teamName, ""). Return(nil, &model.Response{}, nil). Times(1) @@ -2061,19 +2061,19 @@ func (s *MmctlUnitTestSuite) TestRenameChannelCmd() { s.client. EXPECT(). - GetTeamByName(context.Background(), teamName, ""). + GetTeamByName(context.TODO(), teamName, ""). Return(foundTeam, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetChannelByNameIncludeDeleted(context.Background(), channelName, foundTeam.Id, ""). + GetChannelByNameIncludeDeleted(context.TODO(), channelName, foundTeam.Id, ""). Return(nil, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetChannel(context.Background(), channelName, ""). + GetChannel(context.TODO(), channelName, ""). Return(nil, &model.Response{}, nil). Times(1) @@ -2113,26 +2113,26 @@ func (s *MmctlUnitTestSuite) TestRenameChannelCmd() { s.client. EXPECT(). - GetTeam(context.Background(), teamName, ""). + GetTeam(context.TODO(), teamName, ""). Return(nil, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetTeamByName(context.Background(), teamName, ""). + GetTeamByName(context.TODO(), teamName, ""). Return(foundTeam, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetChannelByNameIncludeDeleted(context.Background(), channelName, foundTeam.Id, ""). + GetChannelByNameIncludeDeleted(context.TODO(), channelName, foundTeam.Id, ""). Return(foundChannel, &model.Response{}, nil). Times(1) mockError := model.NewAppError("at-random-location.go", "mock error", nil, "mocking a random error", 0) s.client. EXPECT(). - PatchChannel(context.Background(), foundChannel.Id, channelPatch). + PatchChannel(context.TODO(), foundChannel.Id, channelPatch). Return(nil, &model.Response{}, mockError). Times(1) @@ -2178,25 +2178,25 @@ func (s *MmctlUnitTestSuite) TestRenameChannelCmd() { s.client. EXPECT(). - GetTeam(context.Background(), teamName, ""). + GetTeam(context.TODO(), teamName, ""). Return(nil, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetTeamByName(context.Background(), teamName, ""). + GetTeamByName(context.TODO(), teamName, ""). Return(foundTeam, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetChannelByNameIncludeDeleted(context.Background(), channelName, foundTeam.Id, ""). + GetChannelByNameIncludeDeleted(context.TODO(), channelName, foundTeam.Id, ""). Return(foundChannel, &model.Response{}, nil). Times(1) s.client. EXPECT(). - PatchChannel(context.Background(), foundChannel.Id, channelPatch). + PatchChannel(context.TODO(), foundChannel.Id, channelPatch). Return(updatedChannel, &model.Response{}, nil). Times(1) @@ -2240,13 +2240,13 @@ func (s *MmctlUnitTestSuite) TestRenameChannelCmd() { s.client. EXPECT(). - GetChannel(context.Background(), channelName, ""). + GetChannel(context.TODO(), channelName, ""). Return(foundChannel, &model.Response{}, nil). Times(1) s.client. EXPECT(). - PatchChannel(context.Background(), foundChannel.Id, channelPatch). + PatchChannel(context.TODO(), foundChannel.Id, channelPatch). Return(updatedChannel, &model.Response{}, nil). Times(1) @@ -2295,25 +2295,25 @@ func (s *MmctlUnitTestSuite) TestRenameChannelCmd() { s.client. EXPECT(). - GetTeam(context.Background(), teamName, ""). + GetTeam(context.TODO(), teamName, ""). Return(nil, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetTeamByName(context.Background(), teamName, ""). + GetTeamByName(context.TODO(), teamName, ""). Return(foundTeam, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetChannelByNameIncludeDeleted(context.Background(), channelName, foundTeam.Id, ""). + GetChannelByNameIncludeDeleted(context.TODO(), channelName, foundTeam.Id, ""). Return(foundChannel, &model.Response{}, nil). Times(1) s.client. EXPECT(). - PatchChannel(context.Background(), foundChannel.Id, channelPatch). + PatchChannel(context.TODO(), foundChannel.Id, channelPatch). Return(updatedChannel, &model.Response{}, nil). Times(1) @@ -2361,25 +2361,25 @@ func (s *MmctlUnitTestSuite) TestRenameChannelCmd() { s.client. EXPECT(). - GetTeam(context.Background(), teamName, ""). + GetTeam(context.TODO(), teamName, ""). Return(nil, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetTeamByName(context.Background(), teamName, ""). + GetTeamByName(context.TODO(), teamName, ""). Return(foundTeam, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetChannelByNameIncludeDeleted(context.Background(), channelName, foundTeam.Id, ""). + GetChannelByNameIncludeDeleted(context.TODO(), channelName, foundTeam.Id, ""). Return(foundChannel, &model.Response{}, nil). Times(1) s.client. EXPECT(). - PatchChannel(context.Background(), foundChannel.Id, channelPatch). + PatchChannel(context.TODO(), foundChannel.Id, channelPatch). Return(updatedChannel, &model.Response{}, nil). Times(1) @@ -2421,37 +2421,37 @@ func (s *MmctlUnitTestSuite) TestMoveChannelCmdF() { s.client. EXPECT(). - GetTeam(context.Background(), dstTeamName, ""). + GetTeam(context.TODO(), dstTeamName, ""). Return(nil, &model.Response{}, errors.New("")). Times(1) s.client. EXPECT(). - GetTeamByName(context.Background(), dstTeamName, ""). + GetTeamByName(context.TODO(), dstTeamName, ""). Return(&mockTeam1, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetTeam(context.Background(), srcTeamName, ""). + GetTeam(context.TODO(), srcTeamName, ""). Return(nil, &model.Response{}, errors.New("")). Times(1) s.client. EXPECT(). - GetTeamByName(context.Background(), srcTeamName, ""). + GetTeamByName(context.TODO(), srcTeamName, ""). Return(&mockTeam2, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetChannelByNameIncludeDeleted(context.Background(), channelName, mockTeam2.Id, ""). + GetChannelByNameIncludeDeleted(context.TODO(), channelName, mockTeam2.Id, ""). Return(&mockChannel, &model.Response{}, nil). Times(1) s.client. EXPECT(). - MoveChannel(context.Background(), mockChannel.Id, mockTeam1.Id, false). + MoveChannel(context.TODO(), mockChannel.Id, mockTeam1.Id, false). Return(&mockChannel, &model.Response{}, nil). Times(1) @@ -2471,13 +2471,13 @@ func (s *MmctlUnitTestSuite) TestMoveChannelCmdF() { s.client. EXPECT(). - GetTeam(context.Background(), dstTeamName, ""). + GetTeam(context.TODO(), dstTeamName, ""). Return(nil, &model.Response{}, errors.New("")). Times(1) s.client. EXPECT(). - GetTeamByName(context.Background(), dstTeamName, ""). + GetTeamByName(context.TODO(), dstTeamName, ""). Return(nil, &model.Response{}, errors.New("")). Times(1) @@ -2502,13 +2502,13 @@ func (s *MmctlUnitTestSuite) TestMoveChannelCmdF() { s.client. EXPECT(). - GetTeam(context.Background(), dstTeamID, ""). + GetTeam(context.TODO(), dstTeamID, ""). Return(&mockTeam1, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetChannel(context.Background(), channelID, ""). + GetChannel(context.TODO(), channelID, ""). Return(nil, &model.Response{}, errors.New("")). Times(1) @@ -2533,19 +2533,19 @@ func (s *MmctlUnitTestSuite) TestMoveChannelCmdF() { s.client. EXPECT(). - GetTeam(context.Background(), dstTeamID, ""). + GetTeam(context.TODO(), dstTeamID, ""). Return(&mockTeam1, &model.Response{}, errors.New("")). Times(1) s.client. EXPECT(). - GetChannel(context.Background(), channelID, ""). + GetChannel(context.TODO(), channelID, ""). Return(&model.Channel{Id: channelID, Name: "some-name"}, &model.Response{}, nil). Times(1) s.client. EXPECT(). - MoveChannel(context.Background(), channelID, mockTeam1.Id, false). + MoveChannel(context.TODO(), channelID, mockTeam1.Id, false). Return(nil, &model.Response{}, errors.New("some-error")). Times(1) @@ -2627,13 +2627,13 @@ func (s *MmctlUnitTestSuite) TestCreateChannelCmd() { s.client. EXPECT(). - GetTeam(context.Background(), teamName, ""). + GetTeam(context.TODO(), teamName, ""). Return(nil, &model.Response{}, mockError). Times(1) s.client. EXPECT(). - GetTeamByName(context.Background(), teamName, ""). + GetTeamByName(context.TODO(), teamName, ""). Return(nil, &model.Response{}, mockError). Times(1) @@ -2671,19 +2671,19 @@ func (s *MmctlUnitTestSuite) TestCreateChannelCmd() { s.client. EXPECT(). - GetTeam(context.Background(), teamName, ""). + GetTeam(context.TODO(), teamName, ""). Return(nil, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetTeamByName(context.Background(), teamName, ""). + GetTeamByName(context.TODO(), teamName, ""). Return(foundTeam, &model.Response{}, nil). Times(1) s.client. EXPECT(). - CreateChannel(context.Background(), foundChannel). + CreateChannel(context.TODO(), foundChannel). Return(foundChannel, &model.Response{}, nil). Times(1) @@ -2724,13 +2724,13 @@ func (s *MmctlUnitTestSuite) TestCreateChannelCmd() { s.client. EXPECT(). - GetTeam(context.Background(), teamName, ""). + GetTeam(context.TODO(), teamName, ""). Return(foundTeam, &model.Response{}, nil). Times(1) s.client. EXPECT(). - CreateChannel(context.Background(), foundChannel). + CreateChannel(context.TODO(), foundChannel). Return(foundChannel, &model.Response{}, nil). Times(1) @@ -2777,13 +2777,13 @@ func (s *MmctlUnitTestSuite) TestCreateChannelCmd() { s.client. EXPECT(). - GetTeam(context.Background(), teamName, ""). + GetTeam(context.TODO(), teamName, ""). Return(foundTeam, &model.Response{}, nil). Times(1) s.client. EXPECT(). - CreateChannel(context.Background(), foundChannel). + CreateChannel(context.TODO(), foundChannel). Return(foundChannel, &model.Response{}, nil). Times(1) @@ -2822,19 +2822,19 @@ func (s *MmctlUnitTestSuite) TestDeleteChannelsCmd() { s.client. EXPECT(). - GetTeam(context.Background(), teamID, ""). + GetTeam(context.TODO(), teamID, ""). Return(&mockTeam, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetChannelByNameIncludeDeleted(context.Background(), channelName, teamID, ""). + GetChannelByNameIncludeDeleted(context.TODO(), channelName, teamID, ""). Return(nil, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetChannel(context.Background(), channelName, ""). + GetChannel(context.TODO(), channelName, ""). Return(nil, &model.Response{}, nil). Times(1) @@ -2853,13 +2853,13 @@ func (s *MmctlUnitTestSuite) TestDeleteChannelsCmd() { s.client. EXPECT(). - GetTeam(context.Background(), teamName, ""). + GetTeam(context.TODO(), teamName, ""). Return(nil, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetTeamByName(context.Background(), teamName, ""). + GetTeamByName(context.TODO(), teamName, ""). Return(nil, &model.Response{}, nil). Times(1) @@ -2878,19 +2878,19 @@ func (s *MmctlUnitTestSuite) TestDeleteChannelsCmd() { printer.Clean() s.client. EXPECT(). - GetTeam(context.Background(), teamID, ""). + GetTeam(context.TODO(), teamID, ""). Return(&mockTeam, nil, nil). Times(1) s.client. EXPECT(). - GetChannelByNameIncludeDeleted(context.Background(), channelName, teamID, ""). + GetChannelByNameIncludeDeleted(context.TODO(), channelName, teamID, ""). Return(&mockChannel, nil, nil). Times(1) s.client. EXPECT(). - PermanentDeleteChannel(context.Background(), channelID). + PermanentDeleteChannel(context.TODO(), channelID). Return(&model.Response{StatusCode: http.StatusOK}, nil). Times(1) @@ -2908,7 +2908,7 @@ func (s *MmctlUnitTestSuite) TestDeleteChannelsCmd() { s.client. EXPECT(). - GetTeam(context.Background(), teamID, ""). + GetTeam(context.TODO(), teamID, ""). Return(&mockTeam, nil, nil). Times(2) @@ -2917,25 +2917,25 @@ func (s *MmctlUnitTestSuite) TestDeleteChannelsCmd() { s.client. EXPECT(). - GetChannelByNameIncludeDeleted(context.Background(), channelNameDoesNotExist, teamID, ""). + GetChannelByNameIncludeDeleted(context.TODO(), channelNameDoesNotExist, teamID, ""). Return(nil, &model.Response{}, mockError). Times(1) s.client. EXPECT(). - GetChannel(context.Background(), channelNameDoesNotExist, ""). + GetChannel(context.TODO(), channelNameDoesNotExist, ""). Return(nil, &model.Response{}, mockError). Times(1) s.client. EXPECT(). - GetChannelByNameIncludeDeleted(context.Background(), channelName, teamID, ""). + GetChannelByNameIncludeDeleted(context.TODO(), channelName, teamID, ""). Return(&mockChannel, nil, nil). Times(1) s.client. EXPECT(). - PermanentDeleteChannel(context.Background(), channelID). + PermanentDeleteChannel(context.TODO(), channelID). Return(&model.Response{StatusCode: http.StatusOK}, nil). Times(1) diff --git a/server/cmd/mmctl/commands/channel_users_test.go b/server/cmd/mmctl/commands/channel_users_test.go index 332689f08e..1853b59f00 100644 --- a/server/cmd/mmctl/commands/channel_users_test.go +++ b/server/cmd/mmctl/commands/channel_users_test.go @@ -44,24 +44,24 @@ func (s *MmctlUnitTestSuite) TestChannelUsersAddCmdF() { s.client. EXPECT(). - GetTeam(context.Background(), teamID, ""). + GetTeam(context.TODO(), teamID, ""). Return(&mockTeam, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetChannelByNameIncludeDeleted(context.Background(), channelName, teamID, ""). + GetChannelByNameIncludeDeleted(context.TODO(), channelName, teamID, ""). Return(&mockChannel, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetUserByEmail(context.Background(), userEmail, ""). + GetUserByEmail(context.TODO(), userEmail, ""). Return(&mockUser, &model.Response{}, nil). Times(1) s.client. EXPECT(). - AddChannelMember(context.Background(), channelID, userID). + AddChannelMember(context.TODO(), channelID, userID). Return(&model.ChannelMember{}, &model.Response{}, nil). Times(1) err := channelUsersAddCmdF(s.client, cmd, []string{channelArg, userEmail}) @@ -75,19 +75,19 @@ func (s *MmctlUnitTestSuite) TestChannelUsersAddCmdF() { s.client. EXPECT(). - GetTeam(context.Background(), teamID, ""). + GetTeam(context.TODO(), teamID, ""). Return(&mockTeam, &model.Response{}, nil). Times(1) // No channel is returned by client. s.client. EXPECT(). - GetChannelByNameIncludeDeleted(context.Background(), channelName, teamID, ""). + GetChannelByNameIncludeDeleted(context.TODO(), channelName, teamID, ""). Return(nil, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetChannel(context.Background(), channelName, ""). + GetChannel(context.TODO(), channelName, ""). Return(nil, &model.Response{}, nil). Times(1) @@ -103,12 +103,12 @@ func (s *MmctlUnitTestSuite) TestChannelUsersAddCmdF() { // No team is returned by client. s.client. EXPECT(). - GetTeam(context.Background(), teamID, ""). + GetTeam(context.TODO(), teamID, ""). Return(nil, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetTeamByName(context.Background(), teamID, ""). + GetTeamByName(context.TODO(), teamID, ""). Return(nil, &model.Response{}, nil). Times(1) @@ -124,38 +124,38 @@ func (s *MmctlUnitTestSuite) TestChannelUsersAddCmdF() { s.client. EXPECT(). - GetTeam(context.Background(), teamID, ""). + GetTeam(context.TODO(), teamID, ""). Return(&mockTeam, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetChannelByNameIncludeDeleted(context.Background(), channelName, teamID, ""). + GetChannelByNameIncludeDeleted(context.TODO(), channelName, teamID, ""). Return(&mockChannel, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetUserByEmail(context.Background(), nilUserArg, ""). + GetUserByEmail(context.TODO(), nilUserArg, ""). Return(nil, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetUserByUsername(context.Background(), nilUserArg, ""). + GetUserByUsername(context.TODO(), nilUserArg, ""). Return(nil, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetUser(context.Background(), nilUserArg, ""). + GetUser(context.TODO(), nilUserArg, ""). Return(nil, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetUserByEmail(context.Background(), userEmail, ""). + GetUserByEmail(context.TODO(), userEmail, ""). Return(&mockUser, &model.Response{}, nil). Times(1) s.client. EXPECT(). - AddChannelMember(context.Background(), channelID, userID). + AddChannelMember(context.TODO(), channelID, userID). Return(&model.ChannelMember{}, &model.Response{}, nil). Times(1) err := channelUsersAddCmdF(s.client, cmd, []string{channelArg, nilUserArg, userEmail}) @@ -170,24 +170,24 @@ func (s *MmctlUnitTestSuite) TestChannelUsersAddCmdF() { s.client. EXPECT(). - GetTeam(context.Background(), teamID, ""). + GetTeam(context.TODO(), teamID, ""). Return(&mockTeam, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetChannelByNameIncludeDeleted(context.Background(), channelName, teamID, ""). + GetChannelByNameIncludeDeleted(context.TODO(), channelName, teamID, ""). Return(&mockChannel, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetUserByEmail(context.Background(), userEmail, ""). + GetUserByEmail(context.TODO(), userEmail, ""). Return(&mockUser, &model.Response{}, nil). Times(1) s.client. EXPECT(). - AddChannelMember(context.Background(), channelID, userID). + AddChannelMember(context.TODO(), channelID, userID). Return(nil, &model.Response{}, errors.New("mock error")). Times(1) err := channelUsersAddCmdF(s.client, cmd, []string{channelArg, userEmail}) @@ -225,25 +225,25 @@ func (s *MmctlUnitTestSuite) TestChannelUsersRemoveCmd() { s.client. EXPECT(). - GetTeam(context.Background(), teamName, ""). + GetTeam(context.TODO(), teamName, ""). Return(foundTeam, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetChannelByNameIncludeDeleted(context.Background(), channelName, foundTeam.Id, ""). + GetChannelByNameIncludeDeleted(context.TODO(), channelName, foundTeam.Id, ""). Return(foundChannel, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetUserByEmail(context.Background(), userEmail, ""). + GetUserByEmail(context.TODO(), userEmail, ""). Return(&mockUser, &model.Response{}, nil). Times(1) s.client. EXPECT(). - RemoveUserFromChannel(context.Background(), foundChannel.Id, mockUser.Id). + RemoveUserFromChannel(context.TODO(), foundChannel.Id, mockUser.Id). Return(&model.Response{StatusCode: http.StatusOK}, nil). Times(1) @@ -289,37 +289,37 @@ func (s *MmctlUnitTestSuite) TestChannelUsersRemoveCmd() { s.client. EXPECT(). - GetTeam(context.Background(), teamName, ""). + GetTeam(context.TODO(), teamName, ""). Return(foundTeam, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetChannelByNameIncludeDeleted(context.Background(), channelName, foundTeam.Id, ""). + GetChannelByNameIncludeDeleted(context.TODO(), channelName, foundTeam.Id, ""). Return(foundChannel, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetChannelMembers(context.Background(), foundChannel.Id, 0, 10000, ""). + GetChannelMembers(context.TODO(), foundChannel.Id, 0, 10000, ""). Return(mockChannelMembers, &model.Response{}, nil). Times(1) s.client. EXPECT(). - RemoveUserFromChannel(context.Background(), foundChannel.Id, mockUser.Id). + RemoveUserFromChannel(context.TODO(), foundChannel.Id, mockUser.Id). Return(&model.Response{StatusCode: http.StatusOK}, nil). Times(1) s.client. EXPECT(). - RemoveUserFromChannel(context.Background(), foundChannel.Id, mockUser2.Id). + RemoveUserFromChannel(context.TODO(), foundChannel.Id, mockUser2.Id). Return(&model.Response{StatusCode: http.StatusOK}, nil). Times(1) s.client. EXPECT(). - RemoveUserFromChannel(context.Background(), foundChannel.Id, mockUser3.Id). + RemoveUserFromChannel(context.TODO(), foundChannel.Id, mockUser3.Id). Return(&model.Response{StatusCode: http.StatusOK}, nil). Times(1) @@ -349,37 +349,37 @@ func (s *MmctlUnitTestSuite) TestChannelUsersRemoveCmd() { s.client. EXPECT(). - GetTeam(context.Background(), teamName, ""). + GetTeam(context.TODO(), teamName, ""). Return(foundTeam, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetChannelByNameIncludeDeleted(context.Background(), channelName, foundTeam.Id, ""). + GetChannelByNameIncludeDeleted(context.TODO(), channelName, foundTeam.Id, ""). Return(foundChannel, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetUserByEmail(context.Background(), userEmail, ""). + GetUserByEmail(context.TODO(), userEmail, ""). Return(&mockUser, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetUserByEmail(context.Background(), mockUser2.Email, ""). + GetUserByEmail(context.TODO(), mockUser2.Email, ""). Return(&mockUser2, &model.Response{}, nil). Times(1) s.client. EXPECT(). - RemoveUserFromChannel(context.Background(), foundChannel.Id, mockUser.Id). + RemoveUserFromChannel(context.TODO(), foundChannel.Id, mockUser.Id). Return(&model.Response{StatusCode: http.StatusOK}, nil). Times(1) s.client. EXPECT(). - RemoveUserFromChannel(context.Background(), foundChannel.Id, mockUser2.Id). + RemoveUserFromChannel(context.TODO(), foundChannel.Id, mockUser2.Id). Return(&model.Response{StatusCode: http.StatusOK}, nil). Times(1) @@ -412,25 +412,25 @@ func (s *MmctlUnitTestSuite) TestChannelUsersRemoveCmd() { s.client. EXPECT(). - GetTeam(context.Background(), teamName, ""). + GetTeam(context.TODO(), teamName, ""). Return(foundTeam, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetChannelByNameIncludeDeleted(context.Background(), channelName, foundTeam.Id, ""). + GetChannelByNameIncludeDeleted(context.TODO(), channelName, foundTeam.Id, ""). Return(foundChannel, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetChannelMembers(context.Background(), foundChannel.Id, 0, 10000, ""). + GetChannelMembers(context.TODO(), foundChannel.Id, 0, 10000, ""). Return(mockChannelMembers, &model.Response{}, nil). Times(1) s.client. EXPECT(). - RemoveUserFromChannel(context.Background(), foundChannel.Id, mockUser.Id). + RemoveUserFromChannel(context.TODO(), foundChannel.Id, mockUser.Id). Return(&model.Response{StatusCode: http.StatusNotFound}, errors.New("mock error")). Times(1) diff --git a/server/cmd/mmctl/commands/channelargs_test.go b/server/cmd/mmctl/commands/channelargs_test.go index 6e9f00dff5..1e03185865 100644 --- a/server/cmd/mmctl/commands/channelargs_test.go +++ b/server/cmd/mmctl/commands/channelargs_test.go @@ -19,7 +19,7 @@ func (s *MmctlUnitTestSuite) TestGetChannelArgs() { s.client. EXPECT(). - GetChannel(context.Background(), notFoundChannel, ""). + GetChannel(context.TODO(), notFoundChannel, ""). Return(nil, &model.Response{StatusCode: http.StatusNotFound}, notFoundErr). Times(1) @@ -34,7 +34,7 @@ func (s *MmctlUnitTestSuite) TestGetChannelArgs() { s.client. EXPECT(). - GetChannel(context.Background(), badRequestChannel, ""). + GetChannel(context.TODO(), badRequestChannel, ""). Return(nil, &model.Response{StatusCode: http.StatusBadRequest}, badRequestErr). Times(1) @@ -49,7 +49,7 @@ func (s *MmctlUnitTestSuite) TestGetChannelArgs() { s.client. EXPECT(). - GetChannel(context.Background(), forbidden, ""). + GetChannel(context.TODO(), forbidden, ""). Return(nil, &model.Response{StatusCode: http.StatusForbidden}, forbiddenErr). Times(1) @@ -64,7 +64,7 @@ func (s *MmctlUnitTestSuite) TestGetChannelArgs() { s.client. EXPECT(). - GetChannel(context.Background(), errChannel, ""). + GetChannel(context.TODO(), errChannel, ""). Return(nil, &model.Response{StatusCode: http.StatusInternalServerError}, internalServerErrorErr). Times(1) @@ -79,7 +79,7 @@ func (s *MmctlUnitTestSuite) TestGetChannelArgs() { s.client. EXPECT(). - GetChannel(context.Background(), successID, ""). + GetChannel(context.TODO(), successID, ""). Return(successChannel, nil, nil). Times(1) @@ -97,12 +97,12 @@ func (s *MmctlUnitTestSuite) TestGetChannelArgs() { s.client. EXPECT(). - GetTeam(context.Background(), teamID, ""). + GetTeam(context.TODO(), teamID, ""). Return(successTeam, nil, nil). Times(1) s.client. EXPECT(). - GetChannelByNameIncludeDeleted(context.Background(), channelID, teamID, ""). + GetChannelByNameIncludeDeleted(context.TODO(), channelID, teamID, ""). Return(successChannel, nil, nil). Times(1) diff --git a/server/cmd/mmctl/commands/command_test.go b/server/cmd/mmctl/commands/command_test.go index ac5fa27ffe..8a8c8ed4f4 100644 --- a/server/cmd/mmctl/commands/command_test.go +++ b/server/cmd/mmctl/commands/command_test.go @@ -69,17 +69,17 @@ func (s *MmctlUnitTestSuite) TestCommandCreateCmd() { // createCommandCmdF will call getTeamFromTeamArg, getUserFromUserArg which then calls GetUserByEmail s.client. EXPECT(). - GetTeam(context.Background(), teamArg, ""). + GetTeam(context.TODO(), teamArg, ""). Return(&mockTeam, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetUserByEmail(context.Background(), creatorIDArg, ""). + GetUserByEmail(context.TODO(), creatorIDArg, ""). Return(&mockUser, &model.Response{}, nil). Times(1) s.client. EXPECT(). - CreateCommand(context.Background(), &mockCommand). + CreateCommand(context.TODO(), &mockCommand). Return(&mockCommand, &model.Response{}, nil). Times(1) @@ -117,17 +117,17 @@ func (s *MmctlUnitTestSuite) TestCommandCreateCmd() { s.client. EXPECT(). - GetTeam(context.Background(), teamArg, ""). + GetTeam(context.TODO(), teamArg, ""). Return(&mockTeam, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetUserByEmail(context.Background(), creatorIDArg, ""). + GetUserByEmail(context.TODO(), creatorIDArg, ""). Return(&mockUser, &model.Response{}, nil). Times(1) s.client. EXPECT(). - CreateCommand(context.Background(), &mockCommand). + CreateCommand(context.TODO(), &mockCommand). Return(&mockCommand, &model.Response{}, nil). Times(1) @@ -146,12 +146,12 @@ func (s *MmctlUnitTestSuite) TestCommandCreateCmd() { s.client. EXPECT(). - GetTeam(context.Background(), teamArg, ""). + GetTeam(context.TODO(), teamArg, ""). Return(nil, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetTeamByName(context.Background(), teamArg, ""). + GetTeamByName(context.TODO(), teamArg, ""). Return(nil, &model.Response{}, nil). Times(1) @@ -197,12 +197,12 @@ func (s *MmctlUnitTestSuite) TestCommandCreateCmd() { s.client. EXPECT(). - GetTeam(context.Background(), teamArg, ""). + GetTeam(context.TODO(), teamArg, ""). Return(&mockTeam, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetUserByEmail(context.Background(), creatorIDArg, ""). + GetUserByEmail(context.TODO(), creatorIDArg, ""). Return(&mockUser, &model.Response{}, nil). Times(1) @@ -248,12 +248,12 @@ func (s *MmctlUnitTestSuite) TestCommandCreateCmd() { s.client. EXPECT(). - GetTeam(context.Background(), teamArg, ""). + GetTeam(context.TODO(), teamArg, ""). Return(&mockTeam, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetUserByEmail(context.Background(), creatorIDArg, ""). + GetUserByEmail(context.TODO(), creatorIDArg, ""). Return(&mockUser, &model.Response{}, nil). Times(1) @@ -313,18 +313,18 @@ func (s *MmctlUnitTestSuite) TestCommandCreateCmd() { s.client. EXPECT(). - GetTeam(context.Background(), teamArg, ""). + GetTeam(context.TODO(), teamArg, ""). Return(&mockTeam, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetUserByEmail(context.Background(), creatorIDArg, ""). + GetUserByEmail(context.TODO(), creatorIDArg, ""). Return(&mockUser, &model.Response{}, nil). Times(1) mockError := errors.New("mock error, simulated error for CreateCommand") s.client. EXPECT(). - CreateCommand(context.Background(), &mockCommand). + CreateCommand(context.TODO(), &mockCommand). Return(nil, &model.Response{}, mockError). Times(1) @@ -344,7 +344,7 @@ func (s *MmctlUnitTestSuite) TestArchiveCommandCmd() { s.client. EXPECT(). - DeleteCommand(context.Background(), arg). + DeleteCommand(context.TODO(), arg). Return(&model.Response{StatusCode: http.StatusOK}, nil). Times(1) @@ -362,7 +362,7 @@ func (s *MmctlUnitTestSuite) TestArchiveCommandCmd() { s.client. EXPECT(). - DeleteCommand(context.Background(), arg). + DeleteCommand(context.TODO(), arg). Return(&model.Response{StatusCode: http.StatusBadRequest}, nil). Times(1) @@ -380,7 +380,7 @@ func (s *MmctlUnitTestSuite) TestArchiveCommandCmd() { s.client. EXPECT(). - DeleteCommand(context.Background(), arg). + DeleteCommand(context.TODO(), arg). Return(&model.Response{StatusCode: http.StatusBadRequest}, mockError). Times(1) @@ -417,9 +417,9 @@ func (s *MmctlUnitTestSuite) TestCommandListCmdF() { } cmd := &cobra.Command{} - s.client.EXPECT().GetAllTeams(context.Background(), "", 0, 10000).Return(teams, &model.Response{}, nil).Times(1) - s.client.EXPECT().ListCommands(context.Background(), team1ID, true).Return(team1Commands, &model.Response{}, nil).Times(1) - s.client.EXPECT().ListCommands(context.Background(), team2Id, true).Return(team2Commands, &model.Response{}, nil).Times(1) + s.client.EXPECT().GetAllTeams(context.TODO(), "", 0, 10000).Return(teams, &model.Response{}, nil).Times(1) + s.client.EXPECT().ListCommands(context.TODO(), team1ID, true).Return(team1Commands, &model.Response{}, nil).Times(1) + s.client.EXPECT().ListCommands(context.TODO(), team2Id, true).Return(team2Commands, &model.Response{}, nil).Times(1) err := listCommandCmdF(s.client, cmd, []string{}) s.Require().Nil(err) s.Len(printer.GetLines(), 2) @@ -440,8 +440,8 @@ func (s *MmctlUnitTestSuite) TestCommandListCmdF() { } cmd := &cobra.Command{} - s.client.EXPECT().GetTeam(context.Background(), teamID, "").Return(team, &model.Response{}, nil).Times(1) - s.client.EXPECT().ListCommands(context.Background(), teamID, true).Return(teamCommand, &model.Response{}, nil).Times(1) + s.client.EXPECT().GetTeam(context.TODO(), teamID, "").Return(team, &model.Response{}, nil).Times(1) + s.client.EXPECT().ListCommands(context.TODO(), teamID, true).Return(teamCommand, &model.Response{}, nil).Times(1) err := listCommandCmdF(s.client, cmd, []string{teamID}) s.Require().Nil(err) s.Len(printer.GetLines(), 1) @@ -454,9 +454,9 @@ func (s *MmctlUnitTestSuite) TestCommandListCmdF() { printer.Clean() cmd := &cobra.Command{} // first try to get team by id - s.client.EXPECT().GetTeam(context.Background(), teamID, "").Return(nil, &model.Response{}, nil).Times(1) + s.client.EXPECT().GetTeam(context.TODO(), teamID, "").Return(nil, &model.Response{}, nil).Times(1) // second try to search the team by name - s.client.EXPECT().GetTeamByName(context.Background(), teamID, "").Return(nil, &model.Response{}, nil).Times(1) + s.client.EXPECT().GetTeamByName(context.TODO(), teamID, "").Return(nil, &model.Response{}, nil).Times(1) err := listCommandCmdF(s.client, cmd, []string{teamID}) s.Require().Error(err) s.Len(printer.GetLines(), 0) @@ -469,8 +469,8 @@ func (s *MmctlUnitTestSuite) TestCommandListCmdF() { printer.Clean() cmd := &cobra.Command{} team := &model.Team{Id: teamID} - s.client.EXPECT().GetTeam(context.Background(), teamID, "").Return(team, &model.Response{}, nil).Times(1) - s.client.EXPECT().ListCommands(context.Background(), teamID, true).Return(nil, &model.Response{}, errors.New("")).Times(1) + s.client.EXPECT().GetTeam(context.TODO(), teamID, "").Return(team, &model.Response{}, nil).Times(1) + s.client.EXPECT().ListCommands(context.TODO(), teamID, true).Return(nil, &model.Response{}, errors.New("")).Times(1) err := listCommandCmdF(s.client, cmd, []string{teamID}) s.Require().Error(err) s.Len(printer.GetLines(), 0) @@ -542,17 +542,17 @@ func (s *MmctlUnitTestSuite) TestCommandModifyCmd() { // modifyCommandCmdF will call getCommandById, GetUserByEmail and UpdateCommand s.client. EXPECT(). - GetCommandById(context.Background(), arg). + GetCommandById(context.TODO(), arg). Return(&mockCommand, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetUserByEmail(context.Background(), mockCommandModified.CreatorId, ""). + GetUserByEmail(context.TODO(), mockCommandModified.CreatorId, ""). Return(&model.User{Id: mockCommandModified.CreatorId}, &model.Response{}, nil). Times(1) s.client. EXPECT(). - UpdateCommand(context.Background(), &mockCommand). + UpdateCommand(context.TODO(), &mockCommand). Return(mockCommandModified, &model.Response{}, nil). Times(1) @@ -583,7 +583,7 @@ func (s *MmctlUnitTestSuite) TestCommandModifyCmd() { // modifyCommandCmdF will call getCommandById s.client. EXPECT(). - GetCommandById(context.Background(), arg). + GetCommandById(context.TODO(), arg). Return(nil, &model.Response{}, nil). Times(1) @@ -616,22 +616,22 @@ func (s *MmctlUnitTestSuite) TestCommandModifyCmd() { // via email, username, and id. s.client. EXPECT(). - GetCommandById(context.Background(), arg). + GetCommandById(context.TODO(), arg). Return(&mockCommand, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetUserByEmail(context.Background(), bogusUsername, ""). + GetUserByEmail(context.TODO(), bogusUsername, ""). Return(nil, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetUserByUsername(context.Background(), bogusUsername, ""). + GetUserByUsername(context.TODO(), bogusUsername, ""). Return(nil, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetUser(context.Background(), bogusUsername, ""). + GetUser(context.TODO(), bogusUsername, ""). Return(nil, &model.Response{}, nil). Times(1) @@ -662,7 +662,7 @@ func (s *MmctlUnitTestSuite) TestCommandModifyCmd() { // modifyCommandCmdF will call getCommandById s.client. EXPECT(). - GetCommandById(context.Background(), arg). + GetCommandById(context.TODO(), arg). Return(&mockCommand, &model.Response{}, nil). Times(1) @@ -693,7 +693,7 @@ func (s *MmctlUnitTestSuite) TestCommandModifyCmd() { // modifyCommandCmdF will call getCommandById s.client. EXPECT(). - GetCommandById(context.Background(), arg). + GetCommandById(context.TODO(), arg). Return(&mockCommand, &model.Response{}, nil). Times(1) @@ -724,13 +724,13 @@ func (s *MmctlUnitTestSuite) TestCommandModifyCmd() { // modifyCommandCmdF will call getCommandById then UpdateCommand s.client. EXPECT(). - GetCommandById(context.Background(), arg). + GetCommandById(context.TODO(), arg). Return(&mockCommand, &model.Response{}, nil). Times(1) mockError := errors.New("mock error, simulated error for CreateCommand") s.client. EXPECT(). - UpdateCommand(context.Background(), &mockCommand). + UpdateCommand(context.TODO(), &mockCommand). Return(nil, &model.Response{}, mockError). Times(1) @@ -793,22 +793,22 @@ func (s *MmctlUnitTestSuite) TestCommandMoveCmd() { s.client. EXPECT(). - GetTeam(context.Background(), teamArg, ""). + GetTeam(context.TODO(), teamArg, ""). Return(nil, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetTeamByName(context.Background(), teamArg, ""). + GetTeamByName(context.TODO(), teamArg, ""). Return(&mockTeamDest, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetCommandById(context.Background(), commandArg). + GetCommandById(context.TODO(), commandArg). Return(&mockCommand, &model.Response{}, nil). Times(1) s.client. EXPECT(). - MoveCommand(context.Background(), teamArg, mockCommand.Id). + MoveCommand(context.TODO(), teamArg, mockCommand.Id). Return(&model.Response{StatusCode: http.StatusOK}, nil). Times(1) @@ -823,12 +823,12 @@ func (s *MmctlUnitTestSuite) TestCommandMoveCmd() { printer.Clean() s.client. EXPECT(). - GetTeam(context.Background(), teamArgBogus, ""). + GetTeam(context.TODO(), teamArgBogus, ""). Return(nil, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetTeamByName(context.Background(), teamArgBogus, ""). + GetTeamByName(context.TODO(), teamArgBogus, ""). Return(nil, &model.Response{}, nil). Times(1) @@ -843,12 +843,12 @@ func (s *MmctlUnitTestSuite) TestCommandMoveCmd() { printer.Clean() s.client. EXPECT(). - GetTeam(context.Background(), teamArg, ""). + GetTeam(context.TODO(), teamArg, ""). Return(&mockTeamDest, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetCommandById(context.Background(), commandArgBogus). + GetCommandById(context.TODO(), commandArgBogus). Return(nil, &model.Response{}, nil). Times(1) @@ -863,17 +863,17 @@ func (s *MmctlUnitTestSuite) TestCommandMoveCmd() { printer.Clean() s.client. EXPECT(). - GetTeam(context.Background(), teamArg, ""). + GetTeam(context.TODO(), teamArg, ""). Return(&mockTeamDest, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetCommandById(context.Background(), commandArg). + GetCommandById(context.TODO(), commandArg). Return(&mockCommand, &model.Response{}, nil). Times(1) s.client. EXPECT(). - MoveCommand(context.Background(), teamArg, commandArg). + MoveCommand(context.TODO(), teamArg, commandArg). Return(&model.Response{StatusCode: http.StatusBadRequest}, nil). Times(1) @@ -888,17 +888,17 @@ func (s *MmctlUnitTestSuite) TestCommandMoveCmd() { printer.Clean() s.client. EXPECT(). - GetTeam(context.Background(), teamArg, ""). + GetTeam(context.TODO(), teamArg, ""). Return(&mockTeamDest, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetCommandById(context.Background(), commandArg). + GetCommandById(context.TODO(), commandArg). Return(&mockCommand, &model.Response{}, nil). Times(1) s.client. EXPECT(). - MoveCommand(context.Background(), teamArg, commandArg). + MoveCommand(context.TODO(), teamArg, commandArg). Return(&model.Response{StatusCode: http.StatusBadRequest}, mockError). Times(1) @@ -937,7 +937,7 @@ func (s *MmctlUnitTestSuite) TestCommandShowCmd() { // showCommandCmdF will look up command by id s.client. EXPECT(). - GetCommandById(context.Background(), commandArg). + GetCommandById(context.TODO(), commandArg). Return(&mockCommand, &model.Response{}, nil). Times(1) @@ -953,7 +953,7 @@ func (s *MmctlUnitTestSuite) TestCommandShowCmd() { // showCommandCmdF will look up command by id s.client. EXPECT(). - GetCommandById(context.Background(), commandArgBogus). + GetCommandById(context.TODO(), commandArgBogus). Return(nil, &model.Response{}, nil). Times(1) @@ -973,13 +973,13 @@ func (s *MmctlUnitTestSuite) TestCommandShowCmd() { s.client. EXPECT(). - GetTeamByName(context.Background(), mockTeam.Name, ""). + GetTeamByName(context.TODO(), mockTeam.Name, ""). Return(&mockTeam, &model.Response{}, nil). Times(1) s.client. EXPECT(). - ListCommands(context.Background(), mockTeam.Id, false). + ListCommands(context.TODO(), mockTeam.Id, false). Return(list, &model.Response{}, nil). Times(1) @@ -1002,13 +1002,13 @@ func (s *MmctlUnitTestSuite) TestCommandShowCmd() { s.client. EXPECT(). - GetTeamByName(context.Background(), teamName, ""). + GetTeamByName(context.TODO(), teamName, ""). Return(nil, &model.Response{}, errors.New("team not found")). Times(1) s.client. EXPECT(). - GetCommandById(context.Background(), teamTrigger). + GetCommandById(context.TODO(), teamTrigger). Return(nil, &model.Response{}, errors.New("command not found")). Times(1) @@ -1030,19 +1030,19 @@ func (s *MmctlUnitTestSuite) TestCommandShowCmd() { s.client. EXPECT(). - GetTeamByName(context.Background(), mockTeam.Name, ""). + GetTeamByName(context.TODO(), mockTeam.Name, ""). Return(&mockTeam, &model.Response{}, nil). Times(1) s.client. EXPECT(). - ListCommands(context.Background(), mockTeam.Id, false). + ListCommands(context.TODO(), mockTeam.Id, false). Return(list, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetCommandById(context.Background(), teamTrigger). + GetCommandById(context.TODO(), teamTrigger). Return(nil, &model.Response{}, errors.New("bogus")). Times(1) diff --git a/server/cmd/mmctl/commands/config_test.go b/server/cmd/mmctl/commands/config_test.go index d2ab07bbee..62603df385 100644 --- a/server/cmd/mmctl/commands/config_test.go +++ b/server/cmd/mmctl/commands/config_test.go @@ -32,7 +32,7 @@ func (s *MmctlUnitTestSuite) TestConfigGetCmd() { s.client. EXPECT(). - GetConfig(context.Background()). + GetConfig(context.TODO()). Return(outputConfig, &model.Response{}, nil). Times(1) @@ -51,7 +51,7 @@ func (s *MmctlUnitTestSuite) TestConfigGetCmd() { s.client. EXPECT(). - GetConfig(context.Background()). + GetConfig(context.TODO()). Return(outputConfig, &model.Response{}, nil). Times(1) @@ -70,7 +70,7 @@ func (s *MmctlUnitTestSuite) TestConfigGetCmd() { s.client. EXPECT(). - GetConfig(context.Background()). + GetConfig(context.TODO()). Return(outputConfig, &model.Response{}, nil). Times(1) @@ -89,7 +89,7 @@ func (s *MmctlUnitTestSuite) TestConfigGetCmd() { s.client. EXPECT(). - GetConfig(context.Background()). + GetConfig(context.TODO()). Return(outputConfig, &model.Response{}, nil). Times(1) @@ -108,7 +108,7 @@ func (s *MmctlUnitTestSuite) TestConfigGetCmd() { s.client. EXPECT(). - GetConfig(context.Background()). + GetConfig(context.TODO()). Return(outputConfig, &model.Response{}, nil). Times(1) @@ -129,7 +129,7 @@ func (s *MmctlUnitTestSuite) TestConfigGetCmd() { s.client. EXPECT(). - GetConfig(context.Background()). + GetConfig(context.TODO()). Return(outputConfig, &model.Response{}, nil). Times(1) @@ -150,7 +150,7 @@ func (s *MmctlUnitTestSuite) TestConfigGetCmd() { s.client. EXPECT(). - GetConfig(context.Background()). + GetConfig(context.TODO()). Return(outputConfig, &model.Response{}, nil). Times(1) @@ -170,7 +170,7 @@ func (s *MmctlUnitTestSuite) TestConfigGetCmd() { s.client. EXPECT(). - GetConfig(context.Background()). + GetConfig(context.TODO()). Return(outputConfig, &model.Response{StatusCode: 500}, errors.New("")). Times(1) @@ -197,7 +197,7 @@ func (s *MmctlUnitTestSuite) TestConfigGetCmd() { s.client. EXPECT(). - GetConfig(context.Background()). + GetConfig(context.TODO()). Return(outputConfig, &model.Response{}, nil). Times(7) @@ -255,7 +255,7 @@ func (s *MmctlUnitTestSuite) TestConfigGetCmd() { s.client. EXPECT(). - GetConfig(context.Background()). + GetConfig(context.TODO()). Return(outputConfig, &model.Response{}, nil). Times(0) @@ -272,7 +272,7 @@ func (s *MmctlUnitTestSuite) TestConfigGetCmd() { s.client. EXPECT(). - GetConfig(context.Background()). + GetConfig(context.TODO()). Return(outputConfig, &model.Response{}, nil). Times(1) @@ -296,12 +296,12 @@ func (s *MmctlUnitTestSuite) TestConfigSetCmd() { s.client. EXPECT(). - GetConfig(context.Background()). + GetConfig(context.TODO()). Return(defaultConfig, &model.Response{}, nil). Times(1) s.client. EXPECT(). - PatchConfig(context.Background(), inputConfig). + PatchConfig(context.TODO(), inputConfig). Return(inputConfig, &model.Response{}, nil). Times(1) @@ -324,12 +324,12 @@ func (s *MmctlUnitTestSuite) TestConfigSetCmd() { s.client. EXPECT(). - GetConfig(context.Background()). + GetConfig(context.TODO()). Return(defaultConfig, &model.Response{}, nil). Times(1) s.client. EXPECT(). - PatchConfig(context.Background(), inputConfig). + PatchConfig(context.TODO(), inputConfig). Return(inputConfig, &model.Response{}, nil). Times(1) @@ -352,12 +352,12 @@ func (s *MmctlUnitTestSuite) TestConfigSetCmd() { s.client. EXPECT(). - GetConfig(context.Background()). + GetConfig(context.TODO()). Return(defaultConfig, &model.Response{}, nil). Times(1) s.client. EXPECT(). - PatchConfig(context.Background(), inputConfig). + PatchConfig(context.TODO(), inputConfig). Return(inputConfig, &model.Response{}, nil). Times(1) @@ -380,12 +380,12 @@ func (s *MmctlUnitTestSuite) TestConfigSetCmd() { s.client. EXPECT(). - GetConfig(context.Background()). + GetConfig(context.TODO()). Return(defaultConfig, &model.Response{}, nil). Times(1) s.client. EXPECT(). - PatchConfig(context.Background(), inputConfig). + PatchConfig(context.TODO(), inputConfig). Return(inputConfig, &model.Response{}, nil). Times(1) @@ -407,12 +407,12 @@ func (s *MmctlUnitTestSuite) TestConfigSetCmd() { s.client. EXPECT(). - GetConfig(context.Background()). + GetConfig(context.TODO()). Return(defaultConfig, &model.Response{}, nil). Times(1) s.client. EXPECT(). - PatchConfig(context.Background(), inputConfig). + PatchConfig(context.TODO(), inputConfig). Return(inputConfig, &model.Response{}, nil). Times(1) @@ -434,7 +434,7 @@ func (s *MmctlUnitTestSuite) TestConfigSetCmd() { s.client. EXPECT(). - GetConfig(context.Background()). + GetConfig(context.TODO()). Return(defaultConfig, &model.Response{}, nil). Times(1) @@ -453,7 +453,7 @@ func (s *MmctlUnitTestSuite) TestConfigSetCmd() { s.client. EXPECT(). - GetConfig(context.Background()). + GetConfig(context.TODO()). Return(defaultConfig, &model.Response{}, nil). Times(1) @@ -475,12 +475,12 @@ func (s *MmctlUnitTestSuite) TestConfigSetCmd() { s.client. EXPECT(). - GetConfig(context.Background()). + GetConfig(context.TODO()). Return(defaultConfig, &model.Response{}, nil). Times(1) s.client. EXPECT(). - PatchConfig(context.Background(), inputConfig). + PatchConfig(context.TODO(), inputConfig). Return(inputConfig, &model.Response{StatusCode: 500}, errors.New("")). Times(1) @@ -515,13 +515,13 @@ func (s *MmctlUnitTestSuite) TestConfigSetCmd() { } s.client. EXPECT(). - GetConfig(context.Background()). + GetConfig(context.TODO()). Return(defaultConfig, &model.Response{}, nil). Times(3) s.client. EXPECT(). - PatchConfig(context.Background(), inputConfig). + PatchConfig(context.TODO(), inputConfig). Return(inputConfig, &model.Response{}, nil). Times(3) @@ -555,7 +555,7 @@ func (s *MmctlUnitTestSuite) TestConfigSetCmd() { s.client. EXPECT(). - GetConfig(context.Background()). + GetConfig(context.TODO()). Return(defaultConfig, &model.Response{}, nil). Times(1) @@ -576,7 +576,7 @@ func (s *MmctlUnitTestSuite) TestConfigSetCmd() { s.client. EXPECT(). - GetConfig(context.Background()). + GetConfig(context.TODO()). Return(defaultConfig, &model.Response{}, nil). Times(1) @@ -617,12 +617,12 @@ func (s *MmctlUnitTestSuite) TestConfigPatchCmd() { s.client. EXPECT(). - GetConfig(context.Background()). + GetConfig(context.TODO()). Return(defaultConfig, &model.Response{}, nil). Times(1) s.client. EXPECT(). - PatchConfig(context.Background(), inputConfig). + PatchConfig(context.TODO(), inputConfig). Return(inputConfig, &model.Response{}, nil). Times(1) @@ -640,7 +640,7 @@ func (s *MmctlUnitTestSuite) TestConfigPatchCmd() { s.client. EXPECT(). - GetConfig(context.Background()). + GetConfig(context.TODO()). Return(defaultConfig, &model.Response{}, nil). Times(1) @@ -668,12 +668,12 @@ func (s *MmctlUnitTestSuite) TestConfigResetCmd() { s.client. EXPECT(). - GetConfig(context.Background()). + GetConfig(context.TODO()). Return(defaultConfig, &model.Response{}, nil). Times(1) s.client. EXPECT(). - UpdateConfig(context.Background(), defaultConfig). + UpdateConfig(context.TODO(), defaultConfig). Return(defaultConfig, &model.Response{}, nil). Times(1) @@ -694,12 +694,12 @@ func (s *MmctlUnitTestSuite) TestConfigResetCmd() { s.client. EXPECT(). - GetConfig(context.Background()). + GetConfig(context.TODO()). Return(defaultConfig, &model.Response{}, nil). Times(1) s.client. EXPECT(). - UpdateConfig(context.Background(), defaultConfig). + UpdateConfig(context.TODO(), defaultConfig). Return(defaultConfig, &model.Response{}, nil). Times(1) @@ -721,7 +721,7 @@ func (s *MmctlUnitTestSuite) TestConfigResetCmd() { s.client. EXPECT(). - GetConfig(context.Background()). + GetConfig(context.TODO()). Return(defaultConfig, &model.Response{}, nil). Times(1) @@ -742,7 +742,7 @@ func (s *MmctlUnitTestSuite) TestConfigShowCmd() { s.client. EXPECT(). - GetConfig(context.Background()). + GetConfig(context.TODO()). Return(mockConfig, &model.Response{}, nil). Times(1) @@ -759,7 +759,7 @@ func (s *MmctlUnitTestSuite) TestConfigShowCmd() { s.client. EXPECT(). - GetConfig(context.Background()). + GetConfig(context.TODO()). Return(nil, &model.Response{}, configError). Times(1) @@ -775,7 +775,7 @@ func (s *MmctlUnitTestSuite) TestConfigReloadCmd() { s.client. EXPECT(). - ReloadConfig(context.Background()). + ReloadConfig(context.TODO()). Return(&model.Response{StatusCode: http.StatusOK}, nil). Times(1) @@ -789,7 +789,7 @@ func (s *MmctlUnitTestSuite) TestConfigReloadCmd() { s.client. EXPECT(). - ReloadConfig(context.Background()). + ReloadConfig(context.TODO()). Return(&model.Response{StatusCode: http.StatusBadRequest}, errors.New("some-error")). Times(1) @@ -813,7 +813,7 @@ func (s *MmctlUnitTestSuite) TestConfigMigrateCmd() { s.client. EXPECT(). - MigrateConfig(context.Background(), args[0], args[1]). + MigrateConfig(context.TODO(), args[0], args[1]). Return(&model.Response{StatusCode: http.StatusOK}, nil). Times(1) @@ -831,7 +831,7 @@ func (s *MmctlUnitTestSuite) TestConfigMigrateCmd() { s.client. EXPECT(). - MigrateConfig(context.Background(), args[0], args[1]). + MigrateConfig(context.TODO(), args[0], args[1]). Return(&model.Response{StatusCode: http.StatusBadRequest}, errors.New("some-error")). Times(1) diff --git a/server/cmd/mmctl/commands/export_test.go b/server/cmd/mmctl/commands/export_test.go index abe50ccd56..09014b96db 100644 --- a/server/cmd/mmctl/commands/export_test.go +++ b/server/cmd/mmctl/commands/export_test.go @@ -24,7 +24,7 @@ func (s *MmctlUnitTestSuite) TestExportCreateCmdF() { s.client. EXPECT(). - CreateJob(context.Background(), mockJob). + CreateJob(context.TODO(), mockJob). Return(mockJob, &model.Response{}, nil). Times(1) @@ -44,7 +44,7 @@ func (s *MmctlUnitTestSuite) TestExportCreateCmdF() { s.client. EXPECT(). - CreateJob(context.Background(), mockJob). + CreateJob(context.TODO(), mockJob). Return(mockJob, &model.Response{}, nil). Times(1) @@ -66,7 +66,7 @@ func (s *MmctlUnitTestSuite) TestExportDeleteCmdF() { s.client. EXPECT(). - DeleteExport(context.Background(), exportName). + DeleteExport(context.TODO(), exportName). Return(&model.Response{StatusCode: http.StatusOK}, nil). Times(1) @@ -84,7 +84,7 @@ func (s *MmctlUnitTestSuite) TestExportListCmdF() { s.client. EXPECT(). - ListExports(context.Background()). + ListExports(context.TODO()). Return(mockExports, &model.Response{}, nil). Times(1) @@ -105,7 +105,7 @@ func (s *MmctlUnitTestSuite) TestExportListCmdF() { s.client. EXPECT(). - ListExports(context.Background()). + ListExports(context.TODO()). Return(mockExports, &model.Response{}, nil). Times(1) diff --git a/server/cmd/mmctl/commands/group_test.go b/server/cmd/mmctl/commands/group_test.go index ff1259b5f1..68ebc9a3df 100644 --- a/server/cmd/mmctl/commands/group_test.go +++ b/server/cmd/mmctl/commands/group_test.go @@ -23,7 +23,7 @@ func (s *MmctlUnitTestSuite) TestListLdapGroupsCmd() { s.client. EXPECT(). - GetLdapGroups(context.Background()). + GetLdapGroups(context.TODO()). Return(nil, &model.Response{}, mockError). Times(1) @@ -43,7 +43,7 @@ func (s *MmctlUnitTestSuite) TestListLdapGroupsCmd() { s.client. EXPECT(). - GetLdapGroups(context.Background()). + GetLdapGroups(context.TODO()). Return(mockList, &model.Response{}, nil). Times(1) @@ -65,13 +65,13 @@ func (s *MmctlUnitTestSuite) TestTeamGroupEnableCmd() { s.client. EXPECT(). - GetTeam(context.Background(), arg, ""). + GetTeam(context.TODO(), arg, ""). Return(nil, &model.Response{}, errors.New("")). Times(1) s.client. EXPECT(). - GetTeamByName(context.Background(), arg, ""). + GetTeamByName(context.TODO(), arg, ""). Return(nil, &model.Response{}, errors.New("")). Times(1) @@ -96,13 +96,13 @@ func (s *MmctlUnitTestSuite) TestTeamGroupEnableCmd() { s.client. EXPECT(). - GetTeam(context.Background(), arg, ""). + GetTeam(context.TODO(), arg, ""). Return(&mockTeam, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetGroupsByTeam(context.Background(), mockTeam.Id, groupOpts). + GetGroupsByTeam(context.TODO(), mockTeam.Id, groupOpts). Return(nil, 0, &model.Response{}, mockError). Times(1) @@ -126,13 +126,13 @@ func (s *MmctlUnitTestSuite) TestTeamGroupEnableCmd() { s.client. EXPECT(). - GetTeam(context.Background(), arg, ""). + GetTeam(context.TODO(), arg, ""). Return(&mockTeam, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetGroupsByTeam(context.Background(), mockTeam.Id, groupOpts). + GetGroupsByTeam(context.TODO(), mockTeam.Id, groupOpts). Return([]*model.GroupWithSchemeAdmin{}, 0, &model.Response{}, nil). Times(1) @@ -158,19 +158,19 @@ func (s *MmctlUnitTestSuite) TestTeamGroupEnableCmd() { s.client. EXPECT(). - GetTeam(context.Background(), arg, ""). + GetTeam(context.TODO(), arg, ""). Return(&mockTeam, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetGroupsByTeam(context.Background(), mockTeam.Id, groupOpts). + GetGroupsByTeam(context.TODO(), mockTeam.Id, groupOpts). Return([]*model.GroupWithSchemeAdmin{{}}, 1, &model.Response{}, nil). Times(1) s.client. EXPECT(). - PatchTeam(context.Background(), mockTeam.Id, &teamPatch). + PatchTeam(context.TODO(), mockTeam.Id, &teamPatch). Return(nil, &model.Response{}, mockError). Times(1) @@ -195,19 +195,19 @@ func (s *MmctlUnitTestSuite) TestTeamGroupEnableCmd() { s.client. EXPECT(). - GetTeam(context.Background(), arg, ""). + GetTeam(context.TODO(), arg, ""). Return(&mockTeam, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetGroupsByTeam(context.Background(), mockTeam.Id, groupOpts). + GetGroupsByTeam(context.TODO(), mockTeam.Id, groupOpts). Return([]*model.GroupWithSchemeAdmin{{}}, 1, &model.Response{}, nil). Times(1) s.client. EXPECT(). - PatchTeam(context.Background(), mockTeam.Id, &teamPatch). + PatchTeam(context.TODO(), mockTeam.Id, &teamPatch). Return(&mockTeam, &model.Response{}, nil). Times(1) @@ -227,13 +227,13 @@ func (s *MmctlUnitTestSuite) TestTeamGroupDisableCmd() { s.client. EXPECT(). - GetTeam(context.Background(), teamArg, ""). + GetTeam(context.TODO(), teamArg, ""). Return(&mockTeam, &model.Response{}, nil). Times(1) s.client. EXPECT(). - PatchTeam(context.Background(), teamArg, &teamPatch). + PatchTeam(context.TODO(), teamArg, &teamPatch). Return(nil, &model.Response{}, nil). Times(1) @@ -248,13 +248,13 @@ func (s *MmctlUnitTestSuite) TestTeamGroupDisableCmd() { s.client. EXPECT(). - GetTeam(context.Background(), teamArg, ""). + GetTeam(context.TODO(), teamArg, ""). Return(nil, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetTeamByName(context.Background(), teamArg, ""). + GetTeamByName(context.TODO(), teamArg, ""). Return(nil, &model.Response{}, nil). Times(1) @@ -274,13 +274,13 @@ func (s *MmctlUnitTestSuite) TestTeamGroupDisableCmd() { s.client. EXPECT(). - GetTeam(context.Background(), teamArg, ""). + GetTeam(context.TODO(), teamArg, ""). Return(&mockTeam, &model.Response{}, nil). Times(1) s.client. EXPECT(). - PatchTeam(context.Background(), teamArg, &teamPatch). + PatchTeam(context.TODO(), teamArg, &teamPatch). Return(nil, &model.Response{}, mockError). Times(1) @@ -316,19 +316,19 @@ func (s *MmctlUnitTestSuite) TestChannelGroupListCmd() { s.client. EXPECT(). - GetTeam(context.Background(), teamID, ""). + GetTeam(context.TODO(), teamID, ""). Return(&mockTeam, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetChannelByNameIncludeDeleted(context.Background(), channelID, teamID, ""). + GetChannelByNameIncludeDeleted(context.TODO(), channelID, teamID, ""). Return(&mockChannel, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetGroupsByChannel(context.Background(), channelID, *groupOpts). + GetGroupsByChannel(context.TODO(), channelID, *groupOpts). Return(mockGroups, 0, &model.Response{}, nil). Times(1) @@ -363,19 +363,19 @@ func (s *MmctlUnitTestSuite) TestChannelGroupListCmd() { s.client. EXPECT(). - GetTeam(context.Background(), teamID, ""). + GetTeam(context.TODO(), teamID, ""). Return(&mockTeam, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetChannelByNameIncludeDeleted(context.Background(), channelID, teamID, ""). + GetChannelByNameIncludeDeleted(context.TODO(), channelID, teamID, ""). Return(&mockChannel, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetGroupsByChannel(context.Background(), channelID, *groupOpts). + GetGroupsByChannel(context.TODO(), channelID, *groupOpts). Return(mockGroups, 0, &model.Response{}, nil). Times(1) @@ -408,19 +408,19 @@ func (s *MmctlUnitTestSuite) TestChannelGroupListCmd() { s.client. EXPECT(). - GetTeam(context.Background(), teamID, ""). + GetTeam(context.TODO(), teamID, ""). Return(&mockTeam, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetChannelByNameIncludeDeleted(context.Background(), channelID, teamID, ""). + GetChannelByNameIncludeDeleted(context.TODO(), channelID, teamID, ""). Return(&mockChannel, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetGroupsByChannel(context.Background(), channelID, *groupOpts). + GetGroupsByChannel(context.TODO(), channelID, *groupOpts). Return(mockGroups, 0, &model.Response{}, nil). Times(1) @@ -442,19 +442,19 @@ func (s *MmctlUnitTestSuite) TestChannelGroupListCmd() { s.client. EXPECT(). - GetTeam(context.Background(), teamID, ""). + GetTeam(context.TODO(), teamID, ""). Return(&mockTeam, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetChannelByNameIncludeDeleted(context.Background(), channelID, teamID, ""). + GetChannelByNameIncludeDeleted(context.TODO(), channelID, teamID, ""). Return(nil, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetChannel(context.Background(), channelID, ""). + GetChannel(context.TODO(), channelID, ""). Return(nil, &model.Response{}, nil). Times(1) @@ -475,13 +475,13 @@ func (s *MmctlUnitTestSuite) TestChannelGroupListCmd() { s.client. EXPECT(). - GetTeam(context.Background(), teamID, ""). + GetTeam(context.TODO(), teamID, ""). Return(nil, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetTeamByName(context.Background(), teamID, ""). + GetTeamByName(context.TODO(), teamID, ""). Return(nil, &model.Response{}, nil). Times(1) @@ -513,19 +513,19 @@ func (s *MmctlUnitTestSuite) TestChannelGroupListCmd() { s.client. EXPECT(). - GetTeam(context.Background(), teamID, ""). + GetTeam(context.TODO(), teamID, ""). Return(&mockTeam, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetChannelByNameIncludeDeleted(context.Background(), channelID, teamID, ""). + GetChannelByNameIncludeDeleted(context.TODO(), channelID, teamID, ""). Return(&mockChannel, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetGroupsByChannel(context.Background(), channelID, *groupOpts). + GetGroupsByChannel(context.TODO(), channelID, *groupOpts). Return(nil, 0, &model.Response{}, mockError). Times(1) @@ -548,19 +548,19 @@ func (s *MmctlUnitTestSuite) TestChannelGroupListCmd() { s.client. EXPECT(). - GetTeam(context.Background(), teamID, ""). + GetTeam(context.TODO(), teamID, ""). Return(&mockTeam, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetChannelByNameIncludeDeleted(context.Background(), channelID, teamID, ""). + GetChannelByNameIncludeDeleted(context.TODO(), channelID, teamID, ""). Return(nil, &model.Response{}, mockError). Times(1) s.client. EXPECT(). - GetChannel(context.Background(), channelID, ""). + GetChannel(context.TODO(), channelID, ""). Return(nil, &model.Response{}, mockError). Times(1) @@ -582,13 +582,13 @@ func (s *MmctlUnitTestSuite) TestChannelGroupListCmd() { s.client. EXPECT(). - GetTeam(context.Background(), teamID, ""). + GetTeam(context.TODO(), teamID, ""). Return(nil, &model.Response{}, mockError). Times(1) s.client. EXPECT(). - GetTeamByName(context.Background(), teamID, ""). + GetTeamByName(context.TODO(), teamID, ""). Return(nil, &model.Response{}, mockError). Times(1) @@ -605,13 +605,13 @@ func (s *MmctlUnitTestSuite) TestTeamGroupListCmd() { s.client. EXPECT(). - GetTeam(context.Background(), "team1", ""). + GetTeam(context.TODO(), "team1", ""). Return(nil, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetTeamByName(context.Background(), "team1", ""). + GetTeamByName(context.TODO(), "team1", ""). Return(nil, &model.Response{}, nil). Times(1) @@ -646,13 +646,13 @@ func (s *MmctlUnitTestSuite) TestTeamGroupListCmd() { s.client. EXPECT(). - GetTeam(context.Background(), "team1", ""). + GetTeam(context.TODO(), "team1", ""). Return(&mockTeam, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetGroupsByTeam(context.Background(), "team1", groupOpts). + GetGroupsByTeam(context.TODO(), "team1", groupOpts). Return(groups, 2, &model.Response{}, mockError). Times(1) @@ -685,13 +685,13 @@ func (s *MmctlUnitTestSuite) TestTeamGroupListCmd() { s.client. EXPECT(). - GetTeam(context.Background(), "team1", ""). + GetTeam(context.TODO(), "team1", ""). Return(&mockTeam, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetGroupsByTeam(context.Background(), "team1", groupOpts). + GetGroupsByTeam(context.TODO(), "team1", groupOpts). Return(groups, 2, &model.Response{}, nil). Times(1) @@ -716,13 +716,13 @@ func (s *MmctlUnitTestSuite) TestTeamGroupStatusCmd() { s.client. EXPECT(). - GetTeam(context.Background(), teamID, ""). + GetTeam(context.TODO(), teamID, ""). Return(nil, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetTeamByName(context.Background(), teamID, ""). + GetTeamByName(context.TODO(), teamID, ""). Return(nil, &model.Response{}, nil). Times(1) @@ -742,7 +742,7 @@ func (s *MmctlUnitTestSuite) TestTeamGroupStatusCmd() { s.client. EXPECT(). - GetTeam(context.Background(), teamID, ""). + GetTeam(context.TODO(), teamID, ""). Return(team, &model.Response{}, nil). Times(1) @@ -765,7 +765,7 @@ func (s *MmctlUnitTestSuite) TestTeamGroupStatusCmd() { s.client. EXPECT(). - GetTeam(context.Background(), teamID, ""). + GetTeam(context.TODO(), teamID, ""). Return(team, &model.Response{}, nil). Times(1) @@ -788,7 +788,7 @@ func (s *MmctlUnitTestSuite) TestTeamGroupStatusCmd() { s.client. EXPECT(). - GetTeam(context.Background(), teamID, ""). + GetTeam(context.TODO(), teamID, ""). Return(team, &model.Response{}, nil). Times(1) @@ -813,13 +813,13 @@ func (s *MmctlUnitTestSuite) TestChannelGroupStatusCmd() { s.client. EXPECT(). - GetTeam(context.Background(), teamID, ""). + GetTeam(context.TODO(), teamID, ""). Return(nil, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetTeamByName(context.Background(), teamID, ""). + GetTeamByName(context.TODO(), teamID, ""). Return(nil, &model.Response{}, nil). Times(1) @@ -841,19 +841,19 @@ func (s *MmctlUnitTestSuite) TestChannelGroupStatusCmd() { s.client. EXPECT(). - GetTeam(context.Background(), teamID, ""). + GetTeam(context.TODO(), teamID, ""). Return(team, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetChannelByNameIncludeDeleted(context.Background(), channelID, teamID, ""). + GetChannelByNameIncludeDeleted(context.TODO(), channelID, teamID, ""). Return(nil, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetChannel(context.Background(), channelID, ""). + GetChannel(context.TODO(), channelID, ""). Return(nil, &model.Response{}, nil). Times(1) @@ -876,13 +876,13 @@ func (s *MmctlUnitTestSuite) TestChannelGroupStatusCmd() { s.client. EXPECT(). - GetTeam(context.Background(), teamID, ""). + GetTeam(context.TODO(), teamID, ""). Return(team, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetChannelByNameIncludeDeleted(context.Background(), channelID, teamID, ""). + GetChannelByNameIncludeDeleted(context.TODO(), channelID, teamID, ""). Return(channel, &model.Response{}, nil). Times(1) @@ -908,13 +908,13 @@ func (s *MmctlUnitTestSuite) TestChannelGroupStatusCmd() { s.client. EXPECT(). - GetTeam(context.Background(), teamID, ""). + GetTeam(context.TODO(), teamID, ""). Return(team, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetChannelByNameIncludeDeleted(context.Background(), channelID, teamID, ""). + GetChannelByNameIncludeDeleted(context.TODO(), channelID, teamID, ""). Return(channel, &model.Response{}, nil). Times(1) @@ -940,13 +940,13 @@ func (s *MmctlUnitTestSuite) TestChannelGroupStatusCmd() { s.client. EXPECT(). - GetTeam(context.Background(), teamID, ""). + GetTeam(context.TODO(), teamID, ""). Return(team, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetChannelByNameIncludeDeleted(context.Background(), channelID, teamID, ""). + GetChannelByNameIncludeDeleted(context.TODO(), channelID, teamID, ""). Return(channel, &model.Response{}, nil). Times(1) @@ -979,25 +979,25 @@ func (s *MmctlUnitTestSuite) TestChannelGroupEnableCmdF() { s.client. EXPECT(). - GetTeam(context.Background(), teamArg, ""). + GetTeam(context.TODO(), teamArg, ""). Return(&mockTeam, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetChannelByNameIncludeDeleted(context.Background(), channelPart, teamArg, ""). + GetChannelByNameIncludeDeleted(context.TODO(), channelPart, teamArg, ""). Return(&mockChannel, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetGroupsByChannel(context.Background(), channelPart, *groupOpts). + GetGroupsByChannel(context.TODO(), channelPart, *groupOpts). Return(mockGroups, 0, &model.Response{}, nil). Times(1) s.client. EXPECT(). - PatchChannel(context.Background(), channelPart, &model.ChannelPatch{GroupConstrained: model.NewBool(true)}). + PatchChannel(context.TODO(), channelPart, &model.ChannelPatch{GroupConstrained: model.NewBool(true)}). Return(&mockChannel, &model.Response{}, nil). Times(1) @@ -1017,13 +1017,13 @@ func (s *MmctlUnitTestSuite) TestChannelGroupEnableCmdF() { s.client. EXPECT(). - GetTeam(context.Background(), teamArg, ""). + GetTeam(context.TODO(), teamArg, ""). Return(nil, &model.Response{}, mockError). Times(1) s.client. EXPECT(). - GetTeamByName(context.Background(), teamArg, ""). + GetTeamByName(context.TODO(), teamArg, ""). Return(nil, &model.Response{}, mockError). Times(1) @@ -1045,19 +1045,19 @@ func (s *MmctlUnitTestSuite) TestChannelGroupEnableCmdF() { s.client. EXPECT(). - GetTeam(context.Background(), teamArg, ""). + GetTeam(context.TODO(), teamArg, ""). Return(&mockTeam, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetChannelByNameIncludeDeleted(context.Background(), channelPart, teamArg, ""). + GetChannelByNameIncludeDeleted(context.TODO(), channelPart, teamArg, ""). Return(nil, &model.Response{}, mockError). Times(1) s.client. EXPECT(). - GetChannel(context.Background(), channelPart, ""). + GetChannel(context.TODO(), channelPart, ""). Return(nil, &model.Response{}, mockError). Times(1) @@ -1086,19 +1086,19 @@ func (s *MmctlUnitTestSuite) TestChannelGroupEnableCmdF() { s.client. EXPECT(). - GetTeam(context.Background(), teamArg, ""). + GetTeam(context.TODO(), teamArg, ""). Return(&mockTeam, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetChannelByNameIncludeDeleted(context.Background(), channelPart, teamArg, ""). + GetChannelByNameIncludeDeleted(context.TODO(), channelPart, teamArg, ""). Return(&mockChannel, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetGroupsByChannel(context.Background(), channelPart, *groupOpts). + GetGroupsByChannel(context.TODO(), channelPart, *groupOpts). Return(nil, 0, &model.Response{}, mockError). Times(1) @@ -1129,25 +1129,25 @@ func (s *MmctlUnitTestSuite) TestChannelGroupEnableCmdF() { s.client. EXPECT(). - GetTeam(context.Background(), teamArg, ""). + GetTeam(context.TODO(), teamArg, ""). Return(&mockTeam, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetChannelByNameIncludeDeleted(context.Background(), channelPart, teamArg, ""). + GetChannelByNameIncludeDeleted(context.TODO(), channelPart, teamArg, ""). Return(&mockChannel, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetGroupsByChannel(context.Background(), channelPart, *groupOpts). + GetGroupsByChannel(context.TODO(), channelPart, *groupOpts). Return(mockGroups, 0, &model.Response{}, nil). Times(1) s.client. EXPECT(). - PatchChannel(context.Background(), channelPart, &model.ChannelPatch{GroupConstrained: model.NewBool(true)}). + PatchChannel(context.TODO(), channelPart, &model.ChannelPatch{GroupConstrained: model.NewBool(true)}). Return(nil, &model.Response{}, mockError). Times(1) @@ -1176,19 +1176,19 @@ func (s *MmctlUnitTestSuite) TestChannelGroupEnableCmdF() { s.client. EXPECT(). - GetTeam(context.Background(), teamArg, ""). + GetTeam(context.TODO(), teamArg, ""). Return(&mockTeam, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetChannelByNameIncludeDeleted(context.Background(), channelPart, teamArg, ""). + GetChannelByNameIncludeDeleted(context.TODO(), channelPart, teamArg, ""). Return(&mockChannel, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetGroupsByChannel(context.Background(), channelPart, *groupOpts). + GetGroupsByChannel(context.TODO(), channelPart, *groupOpts). Return(mockGroups, 0, &model.Response{}, nil). Times(1) @@ -1208,13 +1208,13 @@ func (s *MmctlUnitTestSuite) TestChannelGroupEnableCmdF() { s.client. EXPECT(). - GetTeam(context.Background(), teamArg, ""). + GetTeam(context.TODO(), teamArg, ""). Return(nil, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetTeamByName(context.Background(), teamArg, ""). + GetTeamByName(context.TODO(), teamArg, ""). Return(nil, &model.Response{}, nil). Times(1) @@ -1235,19 +1235,19 @@ func (s *MmctlUnitTestSuite) TestChannelGroupEnableCmdF() { s.client. EXPECT(). - GetTeam(context.Background(), teamArg, ""). + GetTeam(context.TODO(), teamArg, ""). Return(&mockTeam, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetChannelByNameIncludeDeleted(context.Background(), channelPart, teamArg, ""). + GetChannelByNameIncludeDeleted(context.TODO(), channelPart, teamArg, ""). Return(nil, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetChannel(context.Background(), channelPart, ""). + GetChannel(context.TODO(), channelPart, ""). Return(nil, &model.Response{}, nil). Times(1) @@ -1278,31 +1278,31 @@ func (s *MmctlUnitTestSuite) TestChannelGroupEnableCmdF() { s.client. EXPECT(). - GetTeam(context.Background(), teamArg, ""). + GetTeam(context.TODO(), teamArg, ""). Return(&mockTeam, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetChannelByNameIncludeDeleted(context.Background(), channelPart, teamArg, ""). + GetChannelByNameIncludeDeleted(context.TODO(), channelPart, teamArg, ""). Return(nil, &model.Response{}, mockError). Times(1) s.client. EXPECT(). - GetChannel(context.Background(), channelPart, ""). + GetChannel(context.TODO(), channelPart, ""). Return(&mockChannel, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetGroupsByChannel(context.Background(), channelPart, *groupOpts). + GetGroupsByChannel(context.TODO(), channelPart, *groupOpts). Return(mockGroups, 0, &model.Response{}, nil). Times(1) s.client. EXPECT(). - PatchChannel(context.Background(), channelPart, &model.ChannelPatch{GroupConstrained: model.NewBool(true)}). + PatchChannel(context.TODO(), channelPart, &model.ChannelPatch{GroupConstrained: model.NewBool(true)}). Return(&mockChannel, &model.Response{}, nil). Times(1) @@ -1325,19 +1325,19 @@ func (s *MmctlUnitTestSuite) TestChannelGroupDisableCmdF() { s.client. EXPECT(). - GetTeam(context.Background(), teamArg, ""). + GetTeam(context.TODO(), teamArg, ""). Return(&mockTeam, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetChannelByNameIncludeDeleted(context.Background(), channelPart, teamArg, ""). + GetChannelByNameIncludeDeleted(context.TODO(), channelPart, teamArg, ""). Return(&mockChannel, &model.Response{}, nil). Times(1) s.client. EXPECT(). - PatchChannel(context.Background(), channelPart, &model.ChannelPatch{GroupConstrained: model.NewBool(false)}). + PatchChannel(context.TODO(), channelPart, &model.ChannelPatch{GroupConstrained: model.NewBool(false)}). Return(&mockChannel, &model.Response{}, nil). Times(1) @@ -1356,13 +1356,13 @@ func (s *MmctlUnitTestSuite) TestChannelGroupDisableCmdF() { s.client. EXPECT(). - GetTeam(context.Background(), teamArg, ""). + GetTeam(context.TODO(), teamArg, ""). Return(nil, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetTeamByName(context.Background(), teamArg, ""). + GetTeamByName(context.TODO(), teamArg, ""). Return(nil, &model.Response{}, nil). Times(1) @@ -1383,19 +1383,19 @@ func (s *MmctlUnitTestSuite) TestChannelGroupDisableCmdF() { s.client. EXPECT(). - GetTeam(context.Background(), teamArg, ""). + GetTeam(context.TODO(), teamArg, ""). Return(&mockTeam, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetChannelByNameIncludeDeleted(context.Background(), channelPart, teamArg, ""). + GetChannelByNameIncludeDeleted(context.TODO(), channelPart, teamArg, ""). Return(nil, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetChannel(context.Background(), channelPart, ""). + GetChannel(context.TODO(), channelPart, ""). Return(nil, &model.Response{}, nil). Times(1) @@ -1418,25 +1418,25 @@ func (s *MmctlUnitTestSuite) TestChannelGroupDisableCmdF() { s.client. EXPECT(). - GetTeam(context.Background(), teamArg, ""). + GetTeam(context.TODO(), teamArg, ""). Return(nil, &model.Response{}, mockError). Times(1) s.client. EXPECT(). - GetTeamByName(context.Background(), teamArg, ""). + GetTeamByName(context.TODO(), teamArg, ""). Return(&mockTeam, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetChannelByNameIncludeDeleted(context.Background(), channelPart, teamArg, ""). + GetChannelByNameIncludeDeleted(context.TODO(), channelPart, teamArg, ""). Return(&mockChannel, &model.Response{}, nil). Times(1) s.client. EXPECT(). - PatchChannel(context.Background(), channelPart, &model.ChannelPatch{GroupConstrained: model.NewBool(false)}). + PatchChannel(context.TODO(), channelPart, &model.ChannelPatch{GroupConstrained: model.NewBool(false)}). Return(&mockChannel, &model.Response{}, nil). Times(1) @@ -1456,13 +1456,13 @@ func (s *MmctlUnitTestSuite) TestChannelGroupDisableCmdF() { s.client. EXPECT(). - GetTeam(context.Background(), teamArg, ""). + GetTeam(context.TODO(), teamArg, ""). Return(nil, &model.Response{}, mockError). Times(1) s.client. EXPECT(). - GetTeamByName(context.Background(), teamArg, ""). + GetTeamByName(context.TODO(), teamArg, ""). Return(nil, &model.Response{}, mockError). Times(1) @@ -1484,19 +1484,19 @@ func (s *MmctlUnitTestSuite) TestChannelGroupDisableCmdF() { s.client. EXPECT(). - GetTeam(context.Background(), teamArg, ""). + GetTeam(context.TODO(), teamArg, ""). Return(&mockTeam, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetChannelByNameIncludeDeleted(context.Background(), channelPart, teamArg, ""). + GetChannelByNameIncludeDeleted(context.TODO(), channelPart, teamArg, ""). Return(nil, &model.Response{}, mockError). Times(1) s.client. EXPECT(). - GetChannel(context.Background(), channelPart, ""). + GetChannel(context.TODO(), channelPart, ""). Return(nil, &model.Response{}, mockError). Times(1) @@ -1519,19 +1519,19 @@ func (s *MmctlUnitTestSuite) TestChannelGroupDisableCmdF() { s.client. EXPECT(). - GetTeam(context.Background(), teamArg, ""). + GetTeam(context.TODO(), teamArg, ""). Return(&mockTeam, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetChannelByNameIncludeDeleted(context.Background(), channelPart, teamArg, ""). + GetChannelByNameIncludeDeleted(context.TODO(), channelPart, teamArg, ""). Return(&mockChannel, &model.Response{}, nil). Times(1) s.client. EXPECT(). - PatchChannel(context.Background(), channelPart, &model.ChannelPatch{GroupConstrained: model.NewBool(false)}). + PatchChannel(context.TODO(), channelPart, &model.ChannelPatch{GroupConstrained: model.NewBool(false)}). Return(nil, &model.Response{}, mockError). Times(1) @@ -1549,7 +1549,7 @@ func (s *MmctlUnitTestSuite) TestUserGroupRestoreCmd() { s.client. EXPECT(). - RestoreGroup(context.Background(), "groupId", ""). + RestoreGroup(context.TODO(), "groupId", ""). Return(nil, &model.Response{StatusCode: http.StatusOK}, nil). Times(1) @@ -1566,7 +1566,7 @@ func (s *MmctlUnitTestSuite) TestUserGroupRestoreCmd() { mockError := errors.New("no group found") s.client. EXPECT(). - RestoreGroup(context.Background(), "groupId", ""). + RestoreGroup(context.TODO(), "groupId", ""). Return(nil, &model.Response{StatusCode: http.StatusNotFound}, mockError). Times(1) diff --git a/server/cmd/mmctl/commands/import_test.go b/server/cmd/mmctl/commands/import_test.go index 1549befa73..247f6f4c5e 100644 --- a/server/cmd/mmctl/commands/import_test.go +++ b/server/cmd/mmctl/commands/import_test.go @@ -22,7 +22,7 @@ func (s *MmctlUnitTestSuite) TestImportListAvailableCmdF() { s.client. EXPECT(). - ListImports(context.Background()). + ListImports(context.TODO()). Return(mockImports, &model.Response{}, nil). Times(1) @@ -43,7 +43,7 @@ func (s *MmctlUnitTestSuite) TestImportListAvailableCmdF() { s.client. EXPECT(). - ListImports(context.Background()). + ListImports(context.TODO()). Return(mockImports, &model.Response{}, nil). Times(1) @@ -64,7 +64,7 @@ func (s *MmctlUnitTestSuite) TestImportListIncompleteCmdF() { s.client. EXPECT(). - GetUploadsForUser(context.Background(), "me"). + GetUploadsForUser(context.TODO(), "me"). Return(mockUploads, &model.Response{}, nil). Times(1) @@ -94,7 +94,7 @@ func (s *MmctlUnitTestSuite) TestImportListIncompleteCmdF() { s.client. EXPECT(). - GetUploadsForUser(context.Background(), "me"). + GetUploadsForUser(context.TODO(), "me"). Return(mockUploads, &model.Response{}, nil). Times(1) @@ -115,7 +115,7 @@ func (s *MmctlUnitTestSuite) TestImportJobShowCmdF() { s.client. EXPECT(). - GetJob(context.Background(), jobID). + GetJob(context.TODO(), jobID). Return(nil, &model.Response{StatusCode: http.StatusNotFound}, errors.New("not found")). Times(1) @@ -133,7 +133,7 @@ func (s *MmctlUnitTestSuite) TestImportJobShowCmdF() { s.client. EXPECT(). - GetJob(context.Background(), mockJob.Id). + GetJob(context.TODO(), mockJob.Id). Return(mockJob, &model.Response{}, nil). Times(1) @@ -158,7 +158,7 @@ func (s *MmctlUnitTestSuite) TestImportJobListCmdF() { s.client. EXPECT(). - GetJobsByType(context.Background(), model.JobTypeImportProcess, 0, perPage). + GetJobsByType(context.TODO(), model.JobTypeImportProcess, 0, perPage). Return(mockJobs, &model.Response{}, nil). Times(1) @@ -191,7 +191,7 @@ func (s *MmctlUnitTestSuite) TestImportJobListCmdF() { s.client. EXPECT(). - GetJobsByType(context.Background(), model.JobTypeImportProcess, 0, perPage). + GetJobsByType(context.TODO(), model.JobTypeImportProcess, 0, perPage). Return(mockJobs, &model.Response{}, nil). Times(1) @@ -215,7 +215,7 @@ func (s *MmctlUnitTestSuite) TestImportProcessCmdF() { s.client. EXPECT(). - CreateJob(context.Background(), mockJob). + CreateJob(context.TODO(), mockJob). Return(mockJob, &model.Response{}, nil). Times(1) diff --git a/server/cmd/mmctl/commands/integrity_test.go b/server/cmd/mmctl/commands/integrity_test.go index 630249b9a1..16eb339bfd 100644 --- a/server/cmd/mmctl/commands/integrity_test.go +++ b/server/cmd/mmctl/commands/integrity_test.go @@ -41,7 +41,7 @@ func (s *MmctlUnitTestSuite) TestIntegrityCmd() { } s.client. EXPECT(). - CheckIntegrity(context.Background()). + CheckIntegrity(context.TODO()). Return(mockResults, &model.Response{}, nil). Times(1) @@ -59,7 +59,7 @@ func (s *MmctlUnitTestSuite) TestIntegrityCmd() { s.client. EXPECT(). - CheckIntegrity(context.Background()). + CheckIntegrity(context.TODO()). Return(nil, &model.Response{}, errors.New("mock error")). Times(1) @@ -99,7 +99,7 @@ func (s *MmctlUnitTestSuite) TestIntegrityCmd() { } s.client. EXPECT(). - CheckIntegrity(context.Background()). + CheckIntegrity(context.TODO()). Return(mockResults, &model.Response{}, nil). Times(1) var expected error diff --git a/server/cmd/mmctl/commands/ldap_test.go b/server/cmd/mmctl/commands/ldap_test.go index ae2e673702..dc8dbea13a 100644 --- a/server/cmd/mmctl/commands/ldap_test.go +++ b/server/cmd/mmctl/commands/ldap_test.go @@ -22,7 +22,7 @@ func (s *MmctlUnitTestSuite) TestLdapSyncCmd() { s.client. EXPECT(). - SyncLdap(context.Background(), false). + SyncLdap(context.TODO(), false). Return(&model.Response{StatusCode: http.StatusOK}, nil). Times(1) @@ -39,7 +39,7 @@ func (s *MmctlUnitTestSuite) TestLdapSyncCmd() { s.client. EXPECT(). - SyncLdap(context.Background(), false). + SyncLdap(context.TODO(), false). Return(&model.Response{StatusCode: http.StatusBadRequest}, nil). Times(1) @@ -56,7 +56,7 @@ func (s *MmctlUnitTestSuite) TestLdapSyncCmd() { s.client. EXPECT(). - SyncLdap(context.Background(), false). + SyncLdap(context.TODO(), false). Return(&model.Response{StatusCode: http.StatusBadRequest}, mockError). Times(1) @@ -74,7 +74,7 @@ func (s *MmctlUnitTestSuite) TestLdapSyncCmd() { s.client. EXPECT(). - SyncLdap(context.Background(), true). + SyncLdap(context.TODO(), true). Return(&model.Response{StatusCode: http.StatusOK}, nil). Times(1) @@ -89,7 +89,7 @@ func (s *MmctlUnitTestSuite) TestLdapMigrateID() { s.client. EXPECT(). - MigrateIdLdap(context.Background(), "test-id"). + MigrateIdLdap(context.TODO(), "test-id"). Return(&model.Response{StatusCode: http.StatusOK}, nil). Times(1) @@ -105,7 +105,7 @@ func (s *MmctlUnitTestSuite) TestLdapMigrateID() { s.client. EXPECT(). - MigrateIdLdap(context.Background(), "test-id"). + MigrateIdLdap(context.TODO(), "test-id"). Return(&model.Response{StatusCode: http.StatusBadRequest}, errors.New("test-error")). Times(1) diff --git a/server/cmd/mmctl/commands/license_test.go b/server/cmd/mmctl/commands/license_test.go index 7bd0e92815..311a7cb276 100644 --- a/server/cmd/mmctl/commands/license_test.go +++ b/server/cmd/mmctl/commands/license_test.go @@ -25,7 +25,7 @@ func (s *MmctlUnitTestSuite) TestRemoveLicenseCmd() { s.client. EXPECT(). - RemoveLicenseFile(context.Background()). + RemoveLicenseFile(context.TODO()). Return(&model.Response{StatusCode: http.StatusBadRequest}, nil). Times(1) @@ -42,7 +42,7 @@ func (s *MmctlUnitTestSuite) TestRemoveLicenseCmd() { s.client. EXPECT(). - RemoveLicenseFile(context.Background()). + RemoveLicenseFile(context.TODO()). Return(&model.Response{StatusCode: http.StatusBadRequest}, mockErr). Times(1) @@ -72,7 +72,7 @@ func (s *MmctlUnitTestSuite) TestUploadLicenseCmdF() { printer.Clean() s.client. EXPECT(). - UploadLicenseFile(context.Background(), mockLicenseFile). + UploadLicenseFile(context.TODO(), mockLicenseFile). Return(&model.Response{StatusCode: http.StatusOK}, nil). Times(1) @@ -86,7 +86,7 @@ func (s *MmctlUnitTestSuite) TestUploadLicenseCmdF() { errMsg := "open " + path + ": no such file or directory" s.client. EXPECT(). - UploadLicenseFile(context.Background(), mockLicenseFile). + UploadLicenseFile(context.TODO(), mockLicenseFile). Times(0) err := uploadLicenseCmdF(s.client, &cobra.Command{}, []string{path}) @@ -110,7 +110,7 @@ func (s *MmctlUnitTestSuite) TestUploadLicenseStringCmdF() { printer.Clean() s.client. EXPECT(). - UploadLicenseFile(context.Background(), mockLicenseFile). + UploadLicenseFile(context.TODO(), mockLicenseFile). Return(&model.Response{StatusCode: http.StatusOK}, nil). Times(1) diff --git a/server/cmd/mmctl/commands/logs_test.go b/server/cmd/mmctl/commands/logs_test.go index 91c4280618..ba951a011f 100644 --- a/server/cmd/mmctl/commands/logs_test.go +++ b/server/cmd/mmctl/commands/logs_test.go @@ -32,7 +32,7 @@ func (s *MmctlUnitTestSuite) TestLogsCmd() { s.client. EXPECT(). - GetLogs(context.Background(), 0, 1). + GetLogs(context.TODO(), 0, 1). Return(mockSingleLogLine, &model.Response{}, nil). Times(1) @@ -49,7 +49,7 @@ func (s *MmctlUnitTestSuite) TestLogsCmd() { s.client. EXPECT(). - GetLogs(context.Background(), 0, 0). + GetLogs(context.TODO(), 0, 0). Return(mockSingleLogLine, &model.Response{}, nil). Times(1) @@ -68,7 +68,7 @@ func (s *MmctlUnitTestSuite) TestLogsCmd() { s.client. EXPECT(). - GetLogs(context.Background(), 0, 1). + GetLogs(context.TODO(), 0, 1). Return(mockSingleLogLine, &model.Response{}, nil). Times(1) diff --git a/server/cmd/mmctl/commands/permission_role_test.go b/server/cmd/mmctl/commands/permission_role_test.go index b35b3f70e3..8674e8402f 100644 --- a/server/cmd/mmctl/commands/permission_role_test.go +++ b/server/cmd/mmctl/commands/permission_role_test.go @@ -34,25 +34,25 @@ func (s *MmctlUnitTestSuite) TestAssignUsersCmd() { s.client. EXPECT(). - GetRoleByName(context.Background(), mockRole.Name). + GetRoleByName(context.TODO(), mockRole.Name). Return(mockRole, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetUserByEmail(context.Background(), mockUser.Username, ""). + GetUserByEmail(context.TODO(), mockUser.Username, ""). Return(nil, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetUserByUsername(context.Background(), mockUser.Username, ""). + GetUserByUsername(context.TODO(), mockUser.Username, ""). Return(mockUser, &model.Response{}, nil). Times(1) s.client. EXPECT(). - UpdateUserRoles(context.Background(), mockUser.Id, fmt.Sprintf("%s %s", mockUser.Roles, mockRole.Name)). + UpdateUserRoles(context.TODO(), mockUser.Id, fmt.Sprintf("%s %s", mockUser.Roles, mockRole.Name)). Return(&model.Response{StatusCode: http.StatusOK}, nil). Times(1) @@ -86,45 +86,45 @@ func (s *MmctlUnitTestSuite) TestAssignUsersCmd() { s.client. EXPECT(). - GetRoleByName(context.Background(), mockRole.Name). + GetRoleByName(context.TODO(), mockRole.Name). Return(mockRole, &model.Response{}, nil). Times(1) for _, user := range []*model.User{mockUser1, mockUser2} { s.client. EXPECT(). - GetUserByEmail(context.Background(), user.Username, ""). + GetUserByEmail(context.TODO(), user.Username, ""). Return(nil, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetUserByUsername(context.Background(), user.Username, ""). + GetUserByUsername(context.TODO(), user.Username, ""). Return(user, &model.Response{}, nil). Times(1) s.client. EXPECT(). - UpdateUserRoles(context.Background(), user.Id, fmt.Sprintf("%s %s", user.Roles, mockRole.Name)). + UpdateUserRoles(context.TODO(), user.Id, fmt.Sprintf("%s %s", user.Roles, mockRole.Name)). Return(&model.Response{StatusCode: http.StatusOK}, nil). Times(1) } s.client. EXPECT(). - GetUserByEmail(context.Background(), notFoundUser.Username, ""). + GetUserByEmail(context.TODO(), notFoundUser.Username, ""). Return(nil, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetUserByUsername(context.Background(), notFoundUser.Username, ""). + GetUserByUsername(context.TODO(), notFoundUser.Username, ""). Return(nil, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetUser(context.Background(), notFoundUser.Username, ""). + GetUser(context.TODO(), notFoundUser.Username, ""). Return(nil, &model.Response{}, nil). Times(1) @@ -142,7 +142,7 @@ func (s *MmctlUnitTestSuite) TestAssignUsersCmd() { s.client. EXPECT(). - GetRoleByName(context.Background(), "non-existent"). + GetRoleByName(context.TODO(), "non-existent"). Return(nil, &model.Response{StatusCode: http.StatusNotFound}, expectedError). Times(1) @@ -167,19 +167,19 @@ func (s *MmctlUnitTestSuite) TestAssignUsersCmd() { s.client. EXPECT(). - GetRoleByName(context.Background(), mockRole.Name). + GetRoleByName(context.TODO(), mockRole.Name). Return(mockRole, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetUserByEmail(context.Background(), mockUser.Username, ""). + GetUserByEmail(context.TODO(), mockUser.Username, ""). Return(nil, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetUserByUsername(context.Background(), mockUser.Username, ""). + GetUserByUsername(context.TODO(), mockUser.Username, ""). Return(mockUser, &model.Response{}, nil). Times(1) @@ -199,25 +199,25 @@ func (s *MmctlUnitTestSuite) TestAssignUsersCmd() { s.client. EXPECT(). - GetRoleByName(context.Background(), mockRole.Name). + GetRoleByName(context.TODO(), mockRole.Name). Return(mockRole, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetUserByEmail(context.Background(), requestedUser, ""). + GetUserByEmail(context.TODO(), requestedUser, ""). Return(nil, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetUserByUsername(context.Background(), requestedUser, ""). + GetUserByUsername(context.TODO(), requestedUser, ""). Return(nil, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetUser(context.Background(), requestedUser, ""). + GetUser(context.TODO(), requestedUser, ""). Return(nil, &model.Response{}, nil). Times(1) @@ -243,19 +243,19 @@ func (s *MmctlUnitTestSuite) TestUnassignUsersCmd() { s.client. EXPECT(). - GetUserByEmail(context.Background(), mockUser.Username, ""). + GetUserByEmail(context.TODO(), mockUser.Username, ""). Return(nil, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetUserByUsername(context.Background(), mockUser.Username, ""). + GetUserByUsername(context.TODO(), mockUser.Username, ""). Return(mockUser, &model.Response{}, nil). Times(1) s.client. EXPECT(). - UpdateUserRoles(context.Background(), mockUser.Id, "system_user team_admin"). + UpdateUserRoles(context.TODO(), mockUser.Id, "system_user team_admin"). Return(&model.Response{StatusCode: http.StatusOK}, nil). Times(1) @@ -286,38 +286,38 @@ func (s *MmctlUnitTestSuite) TestUnassignUsersCmd() { for _, user := range []*model.User{mockUser1, mockUser2} { s.client. EXPECT(). - GetUserByEmail(context.Background(), user.Username, ""). + GetUserByEmail(context.TODO(), user.Username, ""). Return(nil, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetUserByUsername(context.Background(), user.Username, ""). + GetUserByUsername(context.TODO(), user.Username, ""). Return(user, &model.Response{}, nil). Times(1) s.client. EXPECT(). - UpdateUserRoles(context.Background(), user.Id, strings.TrimSpace(strings.ReplaceAll(user.Roles, roleName, ""))). + UpdateUserRoles(context.TODO(), user.Id, strings.TrimSpace(strings.ReplaceAll(user.Roles, roleName, ""))). Return(&model.Response{StatusCode: http.StatusOK}, nil). Times(1) } s.client. EXPECT(). - GetUserByEmail(context.Background(), notFoundUser.Username, ""). + GetUserByEmail(context.TODO(), notFoundUser.Username, ""). Return(nil, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetUserByUsername(context.Background(), notFoundUser.Username, ""). + GetUserByUsername(context.TODO(), notFoundUser.Username, ""). Return(nil, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetUser(context.Background(), notFoundUser.Username, ""). + GetUser(context.TODO(), notFoundUser.Username, ""). Return(nil, &model.Response{}, nil). Times(1) @@ -337,13 +337,13 @@ func (s *MmctlUnitTestSuite) TestUnassignUsersCmd() { s.client. EXPECT(). - GetUserByEmail(context.Background(), mockUser.Username, ""). + GetUserByEmail(context.TODO(), mockUser.Username, ""). Return(nil, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetUserByUsername(context.Background(), mockUser.Username, ""). + GetUserByUsername(context.TODO(), mockUser.Username, ""). Return(mockUser, &model.Response{}, nil). Times(1) @@ -357,19 +357,19 @@ func (s *MmctlUnitTestSuite) TestUnassignUsersCmd() { s.client. EXPECT(). - GetUserByEmail(context.Background(), requestedUser, ""). + GetUserByEmail(context.TODO(), requestedUser, ""). Return(nil, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetUserByUsername(context.Background(), requestedUser, ""). + GetUserByUsername(context.TODO(), requestedUser, ""). Return(nil, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetUser(context.Background(), requestedUser, ""). + GetUser(context.TODO(), requestedUser, ""). Return(nil, &model.Response{}, nil). Times(1) @@ -393,7 +393,7 @@ func (s *MmctlUnitTestSuite) TestShowRoleCmd() { s.client. EXPECT(). - GetRoleByName(context.Background(), mockRole.Name). + GetRoleByName(context.TODO(), mockRole.Name). Return(mockRole, &model.Response{}, nil). Times(1) @@ -425,7 +425,7 @@ SchemeManaged false s.client. EXPECT(). - GetRoleByName(context.Background(), mockRole.Name). + GetRoleByName(context.TODO(), mockRole.Name). Return(mockRole, &model.Response{}, nil). Times(1) @@ -455,7 +455,7 @@ Permissions edit_brand // showRoleCmdF will look up role by name s.client. EXPECT(). - GetRoleByName(context.Background(), commandArgBogus). + GetRoleByName(context.TODO(), commandArgBogus). Return(nil, &model.Response{StatusCode: http.StatusNotFound}, expectedError). Times(1) diff --git a/server/cmd/mmctl/commands/permissions_e2e_test.go b/server/cmd/mmctl/commands/permissions_e2e_test.go index 455a8885d9..e1570efc82 100644 --- a/server/cmd/mmctl/commands/permissions_e2e_test.go +++ b/server/cmd/mmctl/commands/permissions_e2e_test.go @@ -39,7 +39,7 @@ func (s *MmctlE2ETestSuite) TestShowRoleCmd() { func (s *MmctlE2ETestSuite) TestAddPermissionsCmd() { s.SetupEnterpriseTestHelper().InitBasic() - role, appErr := s.th.App.GetRoleByName(context.Background(), model.SystemUserRoleId) + role, appErr := s.th.App.GetRoleByName(context.TODO(), model.SystemUserRoleId) s.Require().Nil(appErr) s.Require().NotContains(role.Permissions, model.PermissionCreateBot.Id) @@ -66,7 +66,7 @@ func (s *MmctlE2ETestSuite) TestAddPermissionsCmd() { s.Require().Len(printer.GetLines(), 0) s.Require().Len(printer.GetErrorLines(), 0) - updatedRole, appErr := s.th.App.GetRoleByName(context.Background(), model.SystemUserRoleId) + updatedRole, appErr := s.th.App.GetRoleByName(context.TODO(), model.SystemUserRoleId) s.Require().Nil(appErr) s.Require().Contains(updatedRole.Permissions, model.PermissionCreateBot.Id) }) @@ -75,7 +75,7 @@ func (s *MmctlE2ETestSuite) TestAddPermissionsCmd() { func (s *MmctlE2ETestSuite) TestRemovePermissionsCmd() { s.SetupEnterpriseTestHelper().InitBasic() - role, appErr := s.th.App.GetRoleByName(context.Background(), model.SystemUserRoleId) + role, appErr := s.th.App.GetRoleByName(context.TODO(), model.SystemUserRoleId) s.Require().Nil(appErr) s.Require().Contains(role.Permissions, model.PermissionCreateDirectChannel.Id) @@ -103,7 +103,7 @@ func (s *MmctlE2ETestSuite) TestRemovePermissionsCmd() { s.Require().Len(printer.GetLines(), 0) s.Require().Len(printer.GetErrorLines(), 0) - updatedRole, appErr := s.th.App.GetRoleByName(context.Background(), model.SystemUserRoleId) + updatedRole, appErr := s.th.App.GetRoleByName(context.TODO(), model.SystemUserRoleId) s.Require().Nil(appErr) s.Require().NotContains(updatedRole.Permissions, model.PermissionCreateDirectChannel.Id) }) diff --git a/server/cmd/mmctl/commands/permissions_test.go b/server/cmd/mmctl/commands/permissions_test.go index 579606eba9..7e457a7983 100644 --- a/server/cmd/mmctl/commands/permissions_test.go +++ b/server/cmd/mmctl/commands/permissions_test.go @@ -32,13 +32,13 @@ func (s *MmctlUnitTestSuite) TestAddPermissionsCmd() { s.client. EXPECT(). - GetRoleByName(context.Background(), mockRole.Name). + GetRoleByName(context.TODO(), mockRole.Name). Return(mockRole, &model.Response{}, nil). Times(1) s.client. EXPECT(). - PatchRole(context.Background(), mockRole.Id, expectedPatch). + PatchRole(context.TODO(), mockRole.Id, expectedPatch). Return(&model.Role{}, &model.Response{}, nil). Times(1) @@ -52,7 +52,7 @@ func (s *MmctlUnitTestSuite) TestAddPermissionsCmd() { s.client. EXPECT(). - GetRoleByName(context.Background(), gomock.Any()). + GetRoleByName(context.TODO(), gomock.Any()). Return(nil, &model.Response{StatusCode: http.StatusNotFound}, expectedError). Times(1) @@ -71,7 +71,7 @@ func (s *MmctlUnitTestSuite) TestAddPermissionsCmd() { s.client. EXPECT(). - GetRoleByName(context.Background(), mockRole.Name). + GetRoleByName(context.TODO(), mockRole.Name). Return(mockRole, &model.Response{}, nil). Times(1) @@ -83,7 +83,7 @@ func (s *MmctlUnitTestSuite) TestAddPermissionsCmd() { } s.client. EXPECT(). - PatchRole(context.Background(), mockRole.Id, expectedPatch). + PatchRole(context.TODO(), mockRole.Id, expectedPatch). Return(&model.Role{}, &model.Response{}, nil). Times(1) args := []string{mockRole.Name, newPermission} @@ -107,12 +107,12 @@ func (s *MmctlUnitTestSuite) TestRemovePermissionsCmd() { } s.client. EXPECT(). - GetRoleByName(context.Background(), mockRole.Name). + GetRoleByName(context.TODO(), mockRole.Name). Return(mockRole, &model.Response{}, nil). Times(1) s.client. EXPECT(). - PatchRole(context.Background(), mockRole.Id, expectedPatch). + PatchRole(context.TODO(), mockRole.Id, expectedPatch). Return(&model.Role{}, &model.Response{}, nil). Times(1) @@ -133,12 +133,12 @@ func (s *MmctlUnitTestSuite) TestRemovePermissionsCmd() { } s.client. EXPECT(). - GetRoleByName(context.Background(), mockRole.Name). + GetRoleByName(context.TODO(), mockRole.Name). Return(mockRole, &model.Response{}, nil). Times(1) s.client. EXPECT(). - PatchRole(context.Background(), mockRole.Id, expectedPatch). + PatchRole(context.TODO(), mockRole.Id, expectedPatch). Return(&model.Role{}, &model.Response{}, nil). Times(1) @@ -159,12 +159,12 @@ func (s *MmctlUnitTestSuite) TestRemovePermissionsCmd() { } s.client. EXPECT(). - GetRoleByName(context.Background(), mockRole.Name). + GetRoleByName(context.TODO(), mockRole.Name). Return(mockRole, &model.Response{}, nil). Times(1) s.client. EXPECT(). - PatchRole(context.Background(), mockRole.Id, expectedPatch). + PatchRole(context.TODO(), mockRole.Id, expectedPatch). Return(&model.Role{}, &model.Response{}, nil). Times(1) @@ -181,7 +181,7 @@ func (s *MmctlUnitTestSuite) TestRemovePermissionsCmd() { mockError := errors.New("role_not_found") s.client. EXPECT(). - GetRoleByName(context.Background(), mockRole.Name). + GetRoleByName(context.TODO(), mockRole.Name). Return(nil, &model.Response{StatusCode: http.StatusNotFound}, mockError). Times(1) @@ -201,7 +201,7 @@ func (s *MmctlUnitTestSuite) TestResetPermissionsCmd() { s.client. EXPECT(). - GetRoleByName(context.Background(), mockRole.Name). + GetRoleByName(context.TODO(), mockRole.Name). Return(nil, &model.Response{StatusCode: http.StatusNotFound}, mockError). Times(1) @@ -219,7 +219,7 @@ func (s *MmctlUnitTestSuite) TestResetPermissionsCmd() { s.client. EXPECT(). - GetRoleByName(context.Background(), mockRole.Name). + GetRoleByName(context.TODO(), mockRole.Name). Return(&mockRole, &model.Response{}, nil). Times(1) @@ -253,13 +253,13 @@ func (s *MmctlUnitTestSuite) TestResetPermissionsCmd() { s.client. EXPECT(). - GetRoleByName(context.Background(), mockRole.Name). + GetRoleByName(context.TODO(), mockRole.Name). Return(&mockRole, &model.Response{}, nil). Times(1) s.client. EXPECT(). - PatchRole(context.Background(), mockRole.Id, expectedPatch). + PatchRole(context.TODO(), mockRole.Id, expectedPatch). Return(&model.Role{}, &model.Response{}, nil). Times(1) diff --git a/server/cmd/mmctl/commands/plugin_marketplace_test.go b/server/cmd/mmctl/commands/plugin_marketplace_test.go index 3129715ae7..15f10056de 100644 --- a/server/cmd/mmctl/commands/plugin_marketplace_test.go +++ b/server/cmd/mmctl/commands/plugin_marketplace_test.go @@ -33,7 +33,7 @@ func (s *MmctlUnitTestSuite) TestPluginMarketplaceInstallCmd() { s.client. EXPECT(). - InstallMarketplacePlugin(context.Background(), pluginRequest). + InstallMarketplacePlugin(context.TODO(), pluginRequest). Return(manifest, &model.Response{}, nil). Times(1) @@ -53,7 +53,7 @@ func (s *MmctlUnitTestSuite) TestPluginMarketplaceInstallCmd() { s.client. EXPECT(). - InstallMarketplacePlugin(context.Background(), pluginRequest). + InstallMarketplacePlugin(context.TODO(), pluginRequest). Return(nil, &model.Response{}, errors.New("mock error")). Times(1) @@ -77,7 +77,7 @@ func (s *MmctlUnitTestSuite) TestPluginMarketplaceListCmd() { s.client. EXPECT(). - GetMarketplacePlugins(context.Background(), pluginFilter). + GetMarketplacePlugins(context.TODO(), pluginFilter). Return(plugins, &model.Response{}, nil). Times(1) @@ -99,19 +99,19 @@ func (s *MmctlUnitTestSuite) TestPluginMarketplaceListCmd() { s.client. EXPECT(). - GetMarketplacePlugins(context.Background(), &model.MarketplacePluginFilter{Page: 0, PerPage: 1}). + GetMarketplacePlugins(context.TODO(), &model.MarketplacePluginFilter{Page: 0, PerPage: 1}). Return([]*model.MarketplacePlugin{mockPlugin1}, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetMarketplacePlugins(context.Background(), &model.MarketplacePluginFilter{Page: 1, PerPage: 1}). + GetMarketplacePlugins(context.TODO(), &model.MarketplacePluginFilter{Page: 1, PerPage: 1}). Return([]*model.MarketplacePlugin{mockPlugin2}, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetMarketplacePlugins(context.Background(), &model.MarketplacePluginFilter{Page: 2, PerPage: 1}). + GetMarketplacePlugins(context.TODO(), &model.MarketplacePluginFilter{Page: 2, PerPage: 1}). Return([]*model.MarketplacePlugin{}, &model.Response{}, nil). Times(1) @@ -131,7 +131,7 @@ func (s *MmctlUnitTestSuite) TestPluginMarketplaceListCmd() { s.client. EXPECT(). - GetMarketplacePlugins(context.Background(), &model.MarketplacePluginFilter{Page: 0, PerPage: 200}). + GetMarketplacePlugins(context.TODO(), &model.MarketplacePluginFilter{Page: 0, PerPage: 200}). Return(nil, &model.Response{}, errors.New("mock error")). Times(1) @@ -155,7 +155,7 @@ func (s *MmctlUnitTestSuite) TestPluginMarketplaceListCmd() { s.client. EXPECT(). - GetMarketplacePlugins(context.Background(), pluginFilter). + GetMarketplacePlugins(context.TODO(), pluginFilter). Return(plugins, &model.Response{}, nil). Times(1) diff --git a/server/cmd/mmctl/commands/plugin_test.go b/server/cmd/mmctl/commands/plugin_test.go index 7ef0381859..fd8f7a9c17 100644 --- a/server/cmd/mmctl/commands/plugin_test.go +++ b/server/cmd/mmctl/commands/plugin_test.go @@ -29,7 +29,7 @@ func (s *MmctlUnitTestSuite) TestPluginAddCmd() { s.client. EXPECT(). - UploadPlugin(context.Background(), gomock.AssignableToTypeOf(tmpFile)). + UploadPlugin(context.TODO(), gomock.AssignableToTypeOf(tmpFile)). Return(&model.Manifest{}, &model.Response{}, nil). Times(1) @@ -49,7 +49,7 @@ func (s *MmctlUnitTestSuite) TestPluginAddCmd() { s.client. EXPECT(). - UploadPluginForced(context.Background(), gomock.AssignableToTypeOf(tmpFile)). + UploadPluginForced(context.TODO(), gomock.AssignableToTypeOf(tmpFile)). Return(&model.Manifest{}, &model.Response{}, nil). Times(1) @@ -80,7 +80,7 @@ func (s *MmctlUnitTestSuite) TestPluginAddCmd() { s.client. EXPECT(). - UploadPlugin(context.Background(), gomock.AssignableToTypeOf(tmpFile)). + UploadPlugin(context.TODO(), gomock.AssignableToTypeOf(tmpFile)). Return(&model.Manifest{}, &model.Response{}, mockError). Times(1) @@ -102,13 +102,13 @@ func (s *MmctlUnitTestSuite) TestPluginAddCmd() { if arg == "fail" { s.client. EXPECT(). - UploadPlugin(context.Background(), gomock.AssignableToTypeOf(tmpFile)). + UploadPlugin(context.TODO(), gomock.AssignableToTypeOf(tmpFile)). Return(nil, &model.Response{}, mockError). Times(1) } else { s.client. EXPECT(). - UploadPlugin(context.Background(), gomock.AssignableToTypeOf(tmpFile)). + UploadPlugin(context.TODO(), gomock.AssignableToTypeOf(tmpFile)). Return(&model.Manifest{}, &model.Response{}, nil). Times(1) } @@ -137,13 +137,13 @@ func (s *MmctlUnitTestSuite) TestPluginInstallUrlCmd() { s.client. EXPECT(). - InstallPluginFromURL(context.Background(), pluginURL1, false). + InstallPluginFromURL(context.TODO(), pluginURL1, false). Return(manifest1, &model.Response{}, nil). Times(1) s.client. EXPECT(). - InstallPluginFromURL(context.Background(), pluginURL2, false). + InstallPluginFromURL(context.TODO(), pluginURL2, false). Return(manifest2, &model.Response{}, nil). Times(1) @@ -163,7 +163,7 @@ func (s *MmctlUnitTestSuite) TestPluginInstallUrlCmd() { s.client. EXPECT(). - InstallPluginFromURL(context.Background(), pluginURL, true). + InstallPluginFromURL(context.TODO(), pluginURL, true). Return(manifest, &model.Response{}, nil). Times(1) @@ -187,13 +187,13 @@ func (s *MmctlUnitTestSuite) TestPluginInstallUrlCmd() { s.client. EXPECT(). - InstallPluginFromURL(context.Background(), pluginURL1, false). + InstallPluginFromURL(context.TODO(), pluginURL1, false). Return(manifest1, &model.Response{}, nil). Times(1) s.client. EXPECT(). - InstallPluginFromURL(context.Background(), pluginURL2, false). + InstallPluginFromURL(context.TODO(), pluginURL2, false). Return(nil, &model.Response{}, errors.New("mock error")). Times(1) @@ -213,7 +213,7 @@ func (s *MmctlUnitTestSuite) TestPluginDisableCmd() { s.client. EXPECT(). - DisablePlugin(context.Background(), arg). + DisablePlugin(context.TODO(), arg). Return(&model.Response{StatusCode: http.StatusBadRequest}, nil). Times(1) @@ -231,7 +231,7 @@ func (s *MmctlUnitTestSuite) TestPluginDisableCmd() { s.client. EXPECT(). - DisablePlugin(context.Background(), arg). + DisablePlugin(context.TODO(), arg). Return(&model.Response{StatusCode: http.StatusBadRequest}, mockError). Times(1) @@ -251,13 +251,13 @@ func (s *MmctlUnitTestSuite) TestPluginDisableCmd() { if strings.HasPrefix(arg, "fail") { s.client. EXPECT(). - DisablePlugin(context.Background(), arg). + DisablePlugin(context.TODO(), arg). Return(&model.Response{StatusCode: http.StatusBadRequest}, mockError). Times(1) } else { s.client. EXPECT(). - DisablePlugin(context.Background(), arg). + DisablePlugin(context.TODO(), arg). Return(&model.Response{StatusCode: http.StatusBadRequest}, nil). Times(1) } @@ -281,7 +281,7 @@ func (s *MmctlUnitTestSuite) TestPluginEnableCmd() { s.client. EXPECT(). - EnablePlugin(context.Background(), pluginArg). + EnablePlugin(context.TODO(), pluginArg). Return(&model.Response{StatusCode: http.StatusBadRequest}, nil). Times(1) @@ -299,7 +299,7 @@ func (s *MmctlUnitTestSuite) TestPluginEnableCmd() { for _, plugin := range plugins { s.client. EXPECT(). - EnablePlugin(context.Background(), plugin). + EnablePlugin(context.TODO(), plugin). Return(&model.Response{StatusCode: http.StatusBadRequest}, nil). Times(1) } @@ -320,7 +320,7 @@ func (s *MmctlUnitTestSuite) TestPluginEnableCmd() { s.client. EXPECT(). - EnablePlugin(context.Background(), pluginArg). + EnablePlugin(context.TODO(), pluginArg). Return(&model.Response{StatusCode: http.StatusBadRequest}, mockErr). Times(1) @@ -343,7 +343,7 @@ func (s *MmctlUnitTestSuite) TestPluginEnableCmd() { for _, plugin := range okPlugins { s.client. EXPECT(). - EnablePlugin(context.Background(), plugin). + EnablePlugin(context.TODO(), plugin). Return(&model.Response{StatusCode: http.StatusBadRequest}, nil). Times(1) } @@ -351,7 +351,7 @@ func (s *MmctlUnitTestSuite) TestPluginEnableCmd() { for _, plugin := range failPlugins { s.client. EXPECT(). - EnablePlugin(context.Background(), plugin). + EnablePlugin(context.TODO(), plugin). Return(&model.Response{StatusCode: http.StatusBadRequest}, mockErr). Times(1) } @@ -420,7 +420,7 @@ func (s *MmctlUnitTestSuite) TestPluginListCmd() { s.client. EXPECT(). - GetPlugins(context.Background()). + GetPlugins(context.TODO()). Return(mockList, &model.Response{}, nil). Times(1) @@ -496,7 +496,7 @@ func (s *MmctlUnitTestSuite) TestPluginListCmd() { s.client. EXPECT(). - GetPlugins(context.Background()). + GetPlugins(context.TODO()). Return(mockList, &model.Response{}, nil). Times(1) @@ -523,7 +523,7 @@ func (s *MmctlUnitTestSuite) TestPluginListCmd() { s.client. EXPECT(). - GetPlugins(context.Background()). + GetPlugins(context.TODO()). Return(nil, &model.Response{}, mockError). Times(1) @@ -542,7 +542,7 @@ func (s *MmctlUnitTestSuite) TestPluginDeleteCmd() { s.client. EXPECT(). - RemovePlugin(context.Background(), args). + RemovePlugin(context.TODO(), args). Return(&model.Response{StatusCode: http.StatusBadRequest}, mockError). Times(1) @@ -559,7 +559,7 @@ func (s *MmctlUnitTestSuite) TestPluginDeleteCmd() { s.client. EXPECT(). - RemovePlugin(context.Background(), args). + RemovePlugin(context.TODO(), args). Return(&model.Response{StatusCode: http.StatusOK}, nil). Times(1) @@ -585,25 +585,25 @@ func (s *MmctlUnitTestSuite) TestPluginDeleteCmd() { s.client. EXPECT(). - RemovePlugin(context.Background(), args[0]). + RemovePlugin(context.TODO(), args[0]). Return(&model.Response{StatusCode: http.StatusOK}, nil). Times(1) s.client. EXPECT(). - RemovePlugin(context.Background(), args[1]). + RemovePlugin(context.TODO(), args[1]). Return(&model.Response{StatusCode: http.StatusBadRequest}, mockErrors[0]). Times(1) s.client. EXPECT(). - RemovePlugin(context.Background(), args[2]). + RemovePlugin(context.TODO(), args[2]). Return(&model.Response{StatusCode: http.StatusBadRequest}, mockErrors[1]). Times(1) s.client. EXPECT(). - RemovePlugin(context.Background(), args[3]). + RemovePlugin(context.TODO(), args[3]). Return(&model.Response{StatusCode: http.StatusOK}, nil). Times(1) diff --git a/server/cmd/mmctl/commands/post_test.go b/server/cmd/mmctl/commands/post_test.go index ca5f76dd2d..f272395782 100644 --- a/server/cmd/mmctl/commands/post_test.go +++ b/server/cmd/mmctl/commands/post_test.go @@ -42,7 +42,7 @@ func (s *MmctlUnitTestSuite) TestPostCreateCmdF() { s.client. EXPECT(). - GetPost(context.Background(), replyToArg, ""). + GetPost(context.TODO(), replyToArg, ""). Return(nil, &model.Response{}, errors.New("some-error")). Times(1) @@ -63,13 +63,13 @@ func (s *MmctlUnitTestSuite) TestPostCreateCmdF() { s.client. EXPECT(). - GetChannel(context.Background(), channelArg, ""). + GetChannel(context.TODO(), channelArg, ""). Return(&mockChannel, &model.Response{}, nil). Times(1) s.client. EXPECT(). - DoAPIPost(context.Background(), "/posts?set_online=false", data). + DoAPIPost(context.TODO(), "/posts?set_online=false", data). Return(nil, errors.New("some-error")). Times(1) @@ -90,13 +90,13 @@ func (s *MmctlUnitTestSuite) TestPostCreateCmdF() { s.client. EXPECT(). - GetChannel(context.Background(), channelArg, ""). + GetChannel(context.TODO(), channelArg, ""). Return(&mockChannel, &model.Response{}, nil). Times(1) s.client. EXPECT(). - DoAPIPost(context.Background(), "/posts?set_online=false", data). + DoAPIPost(context.TODO(), "/posts?set_online=false", data). Return(nil, nil). Times(1) @@ -122,19 +122,19 @@ func (s *MmctlUnitTestSuite) TestPostCreateCmdF() { s.client. EXPECT(). - GetChannel(context.Background(), channelArg, ""). + GetChannel(context.TODO(), channelArg, ""). Return(&mockChannel, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetPost(context.Background(), replyToArg, ""). + GetPost(context.TODO(), replyToArg, ""). Return(&mockReplyTo, &model.Response{}, nil). Times(1) s.client. EXPECT(). - DoAPIPost(context.Background(), "/posts?set_online=false", data). + DoAPIPost(context.TODO(), "/posts?set_online=false", data). Return(nil, nil). Times(1) @@ -161,7 +161,7 @@ func (s *MmctlUnitTestSuite) TestPostListCmdF() { s.client. EXPECT(). - GetChannel(context.Background(), channelName, ""). + GetChannel(context.TODO(), channelName, ""). Return(&mockChannel, &model.Response{}, nil). Times(1) @@ -186,19 +186,19 @@ func (s *MmctlUnitTestSuite) TestPostListCmdF() { s.client. EXPECT(). - GetChannel(context.Background(), channelName, ""). + GetChannel(context.TODO(), channelName, ""). Return(&mockChannel, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetPostsForChannel(context.Background(), channelID, 0, 1, "", false, false). + GetPostsForChannel(context.TODO(), channelID, 0, 1, "", false, false). Return(mockPostList, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetUser(context.Background(), userID, ""). + GetUser(context.TODO(), userID, ""). Return(&mockUser, &model.Response{}, nil). Times(1) @@ -234,19 +234,19 @@ func (s *MmctlUnitTestSuite) TestPostListCmdF() { s.client. EXPECT(). - GetChannel(context.Background(), channelName, ""). + GetChannel(context.TODO(), channelName, ""). Return(&mockChannel, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetPostsSince(context.Background(), channelID, sinceTimeMillis, false). + GetPostsSince(context.TODO(), channelID, sinceTimeMillis, false). Return(mockPostList, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetUser(context.Background(), userID, ""). + GetUser(context.TODO(), userID, ""). Return(&mockUser, &model.Response{}, nil). Times(1) diff --git a/server/cmd/mmctl/commands/roles_test.go b/server/cmd/mmctl/commands/roles_test.go index 0985802347..4c3c2702e0 100644 --- a/server/cmd/mmctl/commands/roles_test.go +++ b/server/cmd/mmctl/commands/roles_test.go @@ -25,13 +25,13 @@ func (s *MmctlUnitTestSuite) TestMakeAdminCmd() { s.client. EXPECT(). - GetUserByEmail(context.Background(), mockUser.Email, ""). + GetUserByEmail(context.TODO(), mockUser.Email, ""). Return(mockUser, &model.Response{}, nil). Times(1) s.client. EXPECT(). - UpdateUserRoles(context.Background(), mockUser.Id, newRoles). + UpdateUserRoles(context.TODO(), mockUser.Id, newRoles). Return(&model.Response{StatusCode: http.StatusOK}, nil). Times(1) @@ -51,7 +51,7 @@ func (s *MmctlUnitTestSuite) TestMakeAdminCmd() { s.client. EXPECT(). - GetUserByEmail(context.Background(), mockUser.Email, ""). + GetUserByEmail(context.TODO(), mockUser.Email, ""). Return(mockUser, &model.Response{}, nil). Times(1) @@ -69,19 +69,19 @@ func (s *MmctlUnitTestSuite) TestMakeAdminCmd() { s.client. EXPECT(). - GetUserByEmail(context.Background(), emailArg, ""). + GetUserByEmail(context.TODO(), emailArg, ""). Return(nil, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetUserByUsername(context.Background(), emailArg, ""). + GetUserByUsername(context.TODO(), emailArg, ""). Return(nil, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetUser(context.Background(), emailArg, ""). + GetUser(context.TODO(), emailArg, ""). Return(nil, &model.Response{}, nil). Times(1) @@ -101,13 +101,13 @@ func (s *MmctlUnitTestSuite) TestMakeAdminCmd() { s.client. EXPECT(). - GetUserByEmail(context.Background(), mockUser.Email, ""). + GetUserByEmail(context.TODO(), mockUser.Email, ""). Return(mockUser, &model.Response{}, nil). Times(1) s.client. EXPECT(). - UpdateUserRoles(context.Background(), mockUser.Id, newRoles). + UpdateUserRoles(context.TODO(), mockUser.Id, newRoles). Return(&model.Response{StatusCode: http.StatusBadRequest}, errors.New("mock error")). Times(1) @@ -128,13 +128,13 @@ func (s *MmctlUnitTestSuite) TestMakeMemberCmd() { s.client. EXPECT(). - GetUserByEmail(context.Background(), mockUser.Email, ""). + GetUserByEmail(context.TODO(), mockUser.Email, ""). Return(mockUser, &model.Response{}, nil). Times(1) s.client. EXPECT(). - UpdateUserRoles(context.Background(), mockUser.Id, "system_user"). + UpdateUserRoles(context.TODO(), mockUser.Id, "system_user"). Return(&model.Response{StatusCode: http.StatusOK}, nil). Times(1) @@ -153,7 +153,7 @@ func (s *MmctlUnitTestSuite) TestMakeMemberCmd() { s.client. EXPECT(). - GetUserByEmail(context.Background(), mockUser.Email, ""). + GetUserByEmail(context.TODO(), mockUser.Email, ""). Return(mockUser, &model.Response{}, nil). Times(1) @@ -171,13 +171,13 @@ func (s *MmctlUnitTestSuite) TestMakeMemberCmd() { s.client. EXPECT(). - GetUserByEmail(context.Background(), mockUser.Email, ""). + GetUserByEmail(context.TODO(), mockUser.Email, ""). Return(mockUser, &model.Response{}, nil). Times(1) s.client. EXPECT(). - UpdateUserRoles(context.Background(), mockUser.Id, "system_user"). + UpdateUserRoles(context.TODO(), mockUser.Id, "system_user"). Return(&model.Response{StatusCode: http.StatusBadRequest}, errors.New("mock error")). Times(1) @@ -196,19 +196,19 @@ func (s *MmctlUnitTestSuite) TestMakeMemberCmd() { s.client. EXPECT(). - GetUserByEmail(context.Background(), emailArg, ""). + GetUserByEmail(context.TODO(), emailArg, ""). Return(nil, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetUserByUsername(context.Background(), emailArg, ""). + GetUserByUsername(context.TODO(), emailArg, ""). Return(nil, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetUser(context.Background(), emailArg, ""). + GetUser(context.TODO(), emailArg, ""). Return(nil, &model.Response{}, nil). Times(1) diff --git a/server/cmd/mmctl/commands/saml_test.go b/server/cmd/mmctl/commands/saml_test.go index 4e0eeb97f1..38717eaee0 100644 --- a/server/cmd/mmctl/commands/saml_test.go +++ b/server/cmd/mmctl/commands/saml_test.go @@ -29,7 +29,7 @@ func (s *MmctlUnitTestSuite) TestSamlAuthDataReset() { s.client. EXPECT(). - ResetSamlAuthDataToEmail(context.Background(), false, false, []string{}). + ResetSamlAuthDataToEmail(context.TODO(), false, false, []string{}). Return(int64(1), &model.Response{}, nil). Times(1) @@ -49,7 +49,7 @@ func (s *MmctlUnitTestSuite) TestSamlAuthDataReset() { s.client. EXPECT(). - ResetSamlAuthDataToEmail(context.Background(), false, true, []string{}). + ResetSamlAuthDataToEmail(context.TODO(), false, true, []string{}). Return(int64(1), &model.Response{}, nil). Times(1) @@ -65,7 +65,7 @@ func (s *MmctlUnitTestSuite) TestSamlAuthDataReset() { users := []string{"user1"} s.client. EXPECT(). - ResetSamlAuthDataToEmail(context.Background(), false, false, users). + ResetSamlAuthDataToEmail(context.TODO(), false, false, users). Return(int64(1), &model.Response{}, nil). Times(1) diff --git a/server/cmd/mmctl/commands/system_test.go b/server/cmd/mmctl/commands/system_test.go index e0c84b371f..aabbafeebb 100644 --- a/server/cmd/mmctl/commands/system_test.go +++ b/server/cmd/mmctl/commands/system_test.go @@ -28,7 +28,7 @@ func (s *MmctlUnitTestSuite) TestGetBusyCmd() { s.client. EXPECT(). - GetServerBusy(context.Background()). + GetServerBusy(context.TODO()). Return(sbs, &model.Response{}, nil). Times(1) @@ -47,7 +47,7 @@ func (s *MmctlUnitTestSuite) TestGetBusyCmd() { s.client. EXPECT(). - GetServerBusy(context.Background()). + GetServerBusy(context.TODO()). Return(sbs, &model.Response{}, nil). Times(1) @@ -62,7 +62,7 @@ func (s *MmctlUnitTestSuite) TestGetBusyCmd() { printer.Clean() s.client. EXPECT(). - GetServerBusy(context.Background()). + GetServerBusy(context.TODO()). Return(nil, &model.Response{}, errors.New("mock error")). Times(1) @@ -83,7 +83,7 @@ func (s *MmctlUnitTestSuite) TestSetBusyCmd() { s.client. EXPECT(). - SetServerBusy(context.Background(), minutes*60). + SetServerBusy(context.TODO(), minutes*60). Return(&model.Response{StatusCode: http.StatusOK}, nil). Times(1) @@ -121,7 +121,7 @@ func (s *MmctlUnitTestSuite) TestClearBusyCmd() { printer.Clean() s.client. EXPECT(). - ClearServerBusy(context.Background()). + ClearServerBusy(context.TODO()). Return(&model.Response{StatusCode: http.StatusOK}, nil). Times(1) @@ -136,7 +136,7 @@ func (s *MmctlUnitTestSuite) TestClearBusyCmd() { printer.Clean() s.client. EXPECT(). - ClearServerBusy(context.Background()). + ClearServerBusy(context.TODO()). Return(&model.Response{StatusCode: http.StatusBadRequest}, errors.New("mock error")). Times(1) @@ -154,7 +154,7 @@ func (s *MmctlUnitTestSuite) TestServerVersionCmd() { expectedVersion := "1.23.4.dev" s.client. EXPECT(). - GetPing(context.Background()). + GetPing(context.TODO()). Return("", &model.Response{ServerVersion: expectedVersion}, nil). Times(1) @@ -170,7 +170,7 @@ func (s *MmctlUnitTestSuite) TestServerVersionCmd() { s.client. EXPECT(). - GetPing(context.Background()). + GetPing(context.TODO()). Return("", &model.Response{}, errors.New("mock error")). Times(1) @@ -188,7 +188,7 @@ func (s *MmctlUnitTestSuite) TestServerStatusCmd() { expectedStatus := map[string]string{"status": "OK"} s.client. EXPECT(). - GetPingWithOptions(context.Background(), model.SystemPingOptions{ + GetPingWithOptions(context.TODO(), model.SystemPingOptions{ FullStatus: true, RESTSemantics: true, }). @@ -207,7 +207,7 @@ func (s *MmctlUnitTestSuite) TestServerStatusCmd() { s.client. EXPECT(). - GetPingWithOptions(context.Background(), model.SystemPingOptions{ + GetPingWithOptions(context.TODO(), model.SystemPingOptions{ FullStatus: true, RESTSemantics: true, }). diff --git a/server/cmd/mmctl/commands/team_test.go b/server/cmd/mmctl/commands/team_test.go index 57ed42f21d..2080ed233f 100644 --- a/server/cmd/mmctl/commands/team_test.go +++ b/server/cmd/mmctl/commands/team_test.go @@ -56,7 +56,7 @@ func (s *MmctlUnitTestSuite) TestCreateTeamCmd() { s.client. EXPECT(). - CreateTeam(context.Background(), mockTeam). + CreateTeam(context.TODO(), mockTeam). Return(mockTeam, &model.Response{}, nil). Times(1) @@ -84,7 +84,7 @@ func (s *MmctlUnitTestSuite) TestCreateTeamCmd() { s.client. EXPECT(). - CreateTeam(context.Background(), mockTeam). + CreateTeam(context.TODO(), mockTeam). Return(mockTeam, &model.Response{}, nil). Times(1) @@ -110,7 +110,7 @@ func (s *MmctlUnitTestSuite) TestCreateTeamCmd() { s.client. EXPECT(). - CreateTeam(context.Background(), mockTeam). + CreateTeam(context.TODO(), mockTeam). Return(nil, &model.Response{}, mockError). Times(1) @@ -132,14 +132,14 @@ func (s *MmctlUnitTestSuite) TestRenameTeamCmdF() { // Mocking : GetTeam searches with team id, if team not found proceeds with team name search s.client. EXPECT(). - GetTeam(context.Background(), "existingName", ""). + GetTeam(context.TODO(), "existingName", ""). Return(nil, &model.Response{}, nil). Times(1) // Mocking : GetTeamByname is called, if GetTeam fails to return any team, as team name was passed instead of team id s.client. EXPECT(). - GetTeamByName(context.Background(), "existingName", ""). + GetTeamByName(context.TODO(), "existingName", ""). Return(nil, &model.Response{}, nil). // Error is nil as team not found will not return error from API Times(1) @@ -170,13 +170,13 @@ func (s *MmctlUnitTestSuite) TestRenameTeamCmdF() { s.client. EXPECT(). - GetTeam(context.Background(), args[0], ""). + GetTeam(context.TODO(), args[0], ""). Return(nil, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetTeamByName(context.Background(), args[0], ""). + GetTeamByName(context.TODO(), args[0], ""). Return(foundTeam, &model.Response{}, nil). Times(1) @@ -186,7 +186,7 @@ func (s *MmctlUnitTestSuite) TestRenameTeamCmdF() { // Mock out UpdateTeam which calls the api to rename team s.client. EXPECT(). - UpdateTeam(context.Background(), renamedTeam). + UpdateTeam(context.TODO(), renamedTeam). Return(nil, &model.Response{}, mockError). Times(1) @@ -216,19 +216,19 @@ func (s *MmctlUnitTestSuite) TestRenameTeamCmdF() { s.client. EXPECT(). - GetTeam(context.Background(), args[0], ""). + GetTeam(context.TODO(), args[0], ""). Return(nil, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetTeamByName(context.Background(), args[0], ""). + GetTeamByName(context.TODO(), args[0], ""). Return(foundTeam, &model.Response{}, nil). Times(1) s.client. EXPECT(). - UpdateTeam(context.Background(), updatedTeam). + UpdateTeam(context.TODO(), updatedTeam). Return(updatedTeam, &model.Response{}, nil). Times(1) @@ -248,7 +248,7 @@ func (s *MmctlUnitTestSuite) TestListTeamsCmdF() { s.client. EXPECT(). - GetAllTeams(context.Background(), "", 0, APILimitMaximum). + GetAllTeams(context.TODO(), "", 0, APILimitMaximum). Return(nil, &model.Response{}, mockError). Times(1) @@ -266,7 +266,7 @@ func (s *MmctlUnitTestSuite) TestListTeamsCmdF() { s.client. EXPECT(). - GetAllTeams(context.Background(), "", 0, APILimitMaximum). + GetAllTeams(context.TODO(), "", 0, APILimitMaximum). Return([]*model.Team{&mockTeam}, &model.Response{}, nil). Times(2) @@ -300,7 +300,7 @@ func (s *MmctlUnitTestSuite) TestListTeamsCmdF() { s.client. EXPECT(). - GetAllTeams(context.Background(), "", 0, APILimitMaximum). + GetAllTeams(context.TODO(), "", 0, APILimitMaximum). Return([]*model.Team{&mockTeam}, &model.Response{}, nil). Times(2) @@ -347,7 +347,7 @@ func (s *MmctlUnitTestSuite) TestListTeamsCmdF() { s.client. EXPECT(). - GetAllTeams(context.Background(), "", 0, APILimitMaximum). + GetAllTeams(context.TODO(), "", 0, APILimitMaximum). Return(mockTeams, &model.Response{}, nil). Times(2) @@ -391,13 +391,13 @@ func (s *MmctlUnitTestSuite) TestListTeamsCmdF() { s.client. EXPECT(). - GetAllTeams(context.Background(), "", 0, APILimitMaximum). + GetAllTeams(context.TODO(), "", 0, APILimitMaximum). Return(mockTeamsPage1, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetAllTeams(context.Background(), "", 1, APILimitMaximum). + GetAllTeams(context.TODO(), "", 1, APILimitMaximum). Return(mockTeamsPage2, &model.Response{}, nil). Times(1) @@ -428,13 +428,13 @@ func (s *MmctlUnitTestSuite) TestDeleteTeamsCmd() { s.client. EXPECT(). - GetTeamByName(context.Background(), teamName, ""). + GetTeamByName(context.TODO(), teamName, ""). Return(nil, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetTeam(context.Background(), teamName, ""). + GetTeam(context.TODO(), teamName, ""). Return(nil, &model.Response{}, nil). Times(1) @@ -455,13 +455,13 @@ func (s *MmctlUnitTestSuite) TestDeleteTeamsCmd() { s.client. EXPECT(). - GetTeam(context.Background(), teamName, ""). + GetTeam(context.TODO(), teamName, ""). Return(&mockTeam, &model.Response{}, nil). Times(1) s.client. EXPECT(). - PermanentDeleteTeam(context.Background(), teamID). + PermanentDeleteTeam(context.TODO(), teamID). Return(&model.Response{StatusCode: http.StatusOK}, nil). Times(1) @@ -484,13 +484,13 @@ func (s *MmctlUnitTestSuite) TestDeleteTeamsCmd() { s.client. EXPECT(). - GetTeam(context.Background(), teamName, ""). + GetTeam(context.TODO(), teamName, ""). Return(&mockTeam, &model.Response{}, nil). Times(1) s.client. EXPECT(). - PermanentDeleteTeam(context.Background(), teamID). + PermanentDeleteTeam(context.TODO(), teamID). Return(&model.Response{StatusCode: http.StatusBadRequest}, mockError). Times(1) @@ -512,7 +512,7 @@ func (s *MmctlUnitTestSuite) TestSearchTeamCmd() { s.client. EXPECT(). - SearchTeams(context.Background(), &model.TeamSearch{Term: teamName}). + SearchTeams(context.TODO(), &model.TeamSearch{Term: teamName}). Return([]*model.Team{mockTeam}, &model.Response{}, nil). Times(1) @@ -530,7 +530,7 @@ func (s *MmctlUnitTestSuite) TestSearchTeamCmd() { s.client. EXPECT(). - SearchTeams(context.Background(), &model.TeamSearch{Term: displayName}). + SearchTeams(context.TODO(), &model.TeamSearch{Term: displayName}). Return([]*model.Team{mockTeam}, &model.Response{}, nil). Times(1) @@ -547,7 +547,7 @@ func (s *MmctlUnitTestSuite) TestSearchTeamCmd() { s.client. EXPECT(). - SearchTeams(context.Background(), &model.TeamSearch{Term: teamName}). + SearchTeams(context.TODO(), &model.TeamSearch{Term: teamName}). Return(nil, &model.Response{}, nil). Times(1) @@ -564,7 +564,7 @@ func (s *MmctlUnitTestSuite) TestSearchTeamCmd() { s.client. EXPECT(). - SearchTeams(context.Background(), &model.TeamSearch{Term: displayName}). + SearchTeams(context.TODO(), &model.TeamSearch{Term: displayName}). Return(nil, &model.Response{}, nil). Times(1) @@ -585,13 +585,13 @@ func (s *MmctlUnitTestSuite) TestSearchTeamCmd() { s.client. EXPECT(). - SearchTeams(context.Background(), &model.TeamSearch{Term: mockTeam1Name}). + SearchTeams(context.TODO(), &model.TeamSearch{Term: mockTeam1Name}). Return([]*model.Team{mockTeam1}, &model.Response{}, nil). Times(1) s.client. EXPECT(). - SearchTeams(context.Background(), &model.TeamSearch{Term: mockTeam2DisplayName}). + SearchTeams(context.TODO(), &model.TeamSearch{Term: mockTeam2DisplayName}). Return([]*model.Team{mockTeam2}, &model.Response{}, nil). Times(1) @@ -612,7 +612,7 @@ func (s *MmctlUnitTestSuite) TestSearchTeamCmd() { s.client. EXPECT(). - SearchTeams(context.Background(), &model.TeamSearch{Term: teamVariableName}). + SearchTeams(context.TODO(), &model.TeamSearch{Term: teamVariableName}). Return([]*model.Team{mockTeam1, mockTeam2}, &model.Response{}, nil). Times(1) @@ -635,13 +635,13 @@ func (s *MmctlUnitTestSuite) TestSearchTeamCmd() { s.client. EXPECT(). - SearchTeams(context.Background(), &model.TeamSearch{Term: "team"}). + SearchTeams(context.TODO(), &model.TeamSearch{Term: "team"}). Return([]*model.Team{mockTeam1, mockTeam2, mockTeam3, mockTeam4}, &model.Response{}, nil). Times(1) s.client. EXPECT(). - SearchTeams(context.Background(), &model.TeamSearch{Term: teamVariableName}). + SearchTeams(context.TODO(), &model.TeamSearch{Term: teamVariableName}). Return([]*model.Team{mockTeam1, mockTeam2, mockTeam3, mockTeam4}, &model.Response{}, nil). Times(1) @@ -663,7 +663,7 @@ func (s *MmctlUnitTestSuite) TestSearchTeamCmd() { s.client. EXPECT(). - SearchTeams(context.Background(), &model.TeamSearch{Term: teamVariableName}). + SearchTeams(context.TODO(), &model.TeamSearch{Term: teamVariableName}). Return([]*model.Team{mockTeam1, mockTeam2, mockTeam3, mockTeam4, mockTeam5}, &model.Response{}, nil). Times(1) @@ -683,7 +683,7 @@ func (s *MmctlUnitTestSuite) TestSearchTeamCmd() { mockError := errors.New("remote error") teamName := "teamName" s.client.EXPECT(). - SearchTeams(context.Background(), &model.TeamSearch{Term: teamName}). + SearchTeams(context.TODO(), &model.TeamSearch{Term: teamName}). Return(nil, &model.Response{}, mockError). Times(1) @@ -720,13 +720,13 @@ func (s *MmctlUnitTestSuite) TestModifyTeamsCmd() { s.client. EXPECT(). - GetTeamByName(context.Background(), teamName, ""). + GetTeamByName(context.TODO(), teamName, ""). Return(nil, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetTeam(context.Background(), teamName, ""). + GetTeam(context.TODO(), teamName, ""). Return(nil, &model.Response{}, nil). Times(1) @@ -749,13 +749,13 @@ func (s *MmctlUnitTestSuite) TestModifyTeamsCmd() { s.client. EXPECT(). - GetTeam(context.Background(), teamName, ""). + GetTeam(context.TODO(), teamName, ""). Return(&mockTeam, &model.Response{}, nil). Times(1) s.client. EXPECT(). - UpdateTeamPrivacy(context.Background(), teamID, model.TeamInvite). + UpdateTeamPrivacy(context.TODO(), teamID, model.TeamInvite). Return(&mockTeam, &model.Response{}, nil). Times(1) @@ -778,13 +778,13 @@ func (s *MmctlUnitTestSuite) TestModifyTeamsCmd() { s.client. EXPECT(). - GetTeam(context.Background(), teamName, ""). + GetTeam(context.TODO(), teamName, ""). Return(&mockTeam, &model.Response{}, nil). Times(1) s.client. EXPECT(). - UpdateTeamPrivacy(context.Background(), teamID, model.TeamOpen). + UpdateTeamPrivacy(context.TODO(), teamID, model.TeamOpen). Return(&mockTeam, &model.Response{}, nil). Times(1) @@ -809,13 +809,13 @@ func (s *MmctlUnitTestSuite) TestModifyTeamsCmd() { s.client. EXPECT(). - GetTeam(context.Background(), teamName, ""). + GetTeam(context.TODO(), teamName, ""). Return(&mockTeam, &model.Response{}, nil). Times(1) s.client. EXPECT(). - UpdateTeamPrivacy(context.Background(), teamID, model.TeamOpen). + UpdateTeamPrivacy(context.TODO(), teamID, model.TeamOpen). Return(nil, &model.Response{}, mockError). Times(1) @@ -839,13 +839,13 @@ func (s *MmctlUnitTestSuite) TestRestoreTeamsCmd() { s.client. EXPECT(). - GetTeamByName(context.Background(), teamName, ""). + GetTeamByName(context.TODO(), teamName, ""). Return(nil, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetTeam(context.Background(), teamName, ""). + GetTeam(context.TODO(), teamName, ""). Return(nil, &model.Response{}, nil). Times(1) @@ -865,13 +865,13 @@ func (s *MmctlUnitTestSuite) TestRestoreTeamsCmd() { s.client. EXPECT(). - GetTeam(context.Background(), teamName, ""). + GetTeam(context.TODO(), teamName, ""). Return(&mockTeam, &model.Response{}, nil). Times(1) s.client. EXPECT(). - RestoreTeam(context.Background(), teamID). + RestoreTeam(context.TODO(), teamID). Return(&mockTeam, &model.Response{}, nil). Times(1) @@ -891,13 +891,13 @@ func (s *MmctlUnitTestSuite) TestRestoreTeamsCmd() { s.client. EXPECT(). - GetTeam(context.Background(), teamName, ""). + GetTeam(context.TODO(), teamName, ""). Return(&mockTeam, &model.Response{}, nil). Times(1) s.client. EXPECT(). - RestoreTeam(context.Background(), teamID). + RestoreTeam(context.TODO(), teamID). Return(nil, &model.Response{}, mockError). Times(1) diff --git a/server/cmd/mmctl/commands/team_users_test.go b/server/cmd/mmctl/commands/team_users_test.go index 3bc727ac52..9bd0b3acf0 100644 --- a/server/cmd/mmctl/commands/team_users_test.go +++ b/server/cmd/mmctl/commands/team_users_test.go @@ -22,13 +22,13 @@ func (s *MmctlUnitTestSuite) TestTeamUsersArchiveCmd() { s.client. EXPECT(). - GetTeam(context.Background(), teamArg, ""). + GetTeam(context.TODO(), teamArg, ""). Return(nil, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetTeamByName(context.Background(), teamArg, ""). + GetTeamByName(context.TODO(), teamArg, ""). Return(nil, &model.Response{}, nil). Times(1) @@ -44,25 +44,25 @@ func (s *MmctlUnitTestSuite) TestTeamUsersArchiveCmd() { s.client. EXPECT(). - GetTeam(context.Background(), teamArg, ""). + GetTeam(context.TODO(), teamArg, ""). Return(mockTeam, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetUserByEmail(context.Background(), mockUser.Id, ""). + GetUserByEmail(context.TODO(), mockUser.Id, ""). Return(nil, nil, nil). Times(1) s.client. EXPECT(). - GetUserByUsername(context.Background(), mockUser.Id, ""). + GetUserByUsername(context.TODO(), mockUser.Id, ""). Return(nil, nil, nil). Times(1) s.client. EXPECT(). - GetUser(context.Background(), mockUser.Id, ""). + GetUser(context.TODO(), mockUser.Id, ""). Return(nil, nil, nil). Times(1) @@ -80,25 +80,25 @@ func (s *MmctlUnitTestSuite) TestTeamUsersArchiveCmd() { s.client. EXPECT(). - GetTeam(context.Background(), teamArg, ""). + GetTeam(context.TODO(), teamArg, ""). Return(nil, nil, nil). Times(1) s.client. EXPECT(). - GetTeamByName(context.Background(), teamArg, ""). + GetTeamByName(context.TODO(), teamArg, ""). Return(mockTeam, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetUserByEmail(context.Background(), mockUser.Id, ""). + GetUserByEmail(context.TODO(), mockUser.Id, ""). Return(mockUser, nil, nil). Times(1) s.client. EXPECT(). - RemoveTeamMember(context.Background(), mockTeam.Id, mockUser.Id). + RemoveTeamMember(context.TODO(), mockTeam.Id, mockUser.Id). Return(&model.Response{StatusCode: http.StatusBadRequest}, nil). Times(1) @@ -115,19 +115,19 @@ func (s *MmctlUnitTestSuite) TestTeamUsersArchiveCmd() { s.client. EXPECT(). - GetTeam(context.Background(), teamArg, ""). + GetTeam(context.TODO(), teamArg, ""). Return(mockTeam, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetUserByEmail(context.Background(), mockUser.Id, ""). + GetUserByEmail(context.TODO(), mockUser.Id, ""). Return(mockUser, nil, nil). Times(1) s.client. EXPECT(). - RemoveTeamMember(context.Background(), mockTeam.Id, mockUser.Id). + RemoveTeamMember(context.TODO(), mockTeam.Id, mockUser.Id). Return(&model.Response{StatusCode: http.StatusBadRequest}, nil). Times(1) @@ -144,25 +144,25 @@ func (s *MmctlUnitTestSuite) TestTeamUsersArchiveCmd() { s.client. EXPECT(). - GetTeam(context.Background(), teamArg, ""). + GetTeam(context.TODO(), teamArg, ""). Return(mockTeam, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetUserByEmail(context.Background(), mockUser.Id, ""). + GetUserByEmail(context.TODO(), mockUser.Id, ""). Return(nil, nil, nil). Times(1) s.client. EXPECT(). - GetUserByUsername(context.Background(), mockUser.Id, ""). + GetUserByUsername(context.TODO(), mockUser.Id, ""). Return(mockUser, nil, nil). Times(1) s.client. EXPECT(). - RemoveTeamMember(context.Background(), mockTeam.Id, mockUser.Id). + RemoveTeamMember(context.TODO(), mockTeam.Id, mockUser.Id). Return(&model.Response{StatusCode: http.StatusBadRequest}, nil). Times(1) @@ -178,31 +178,31 @@ func (s *MmctlUnitTestSuite) TestTeamUsersArchiveCmd() { mockUser := &model.User{Id: userArg} s.client. EXPECT(). - GetTeam(context.Background(), teamArg, ""). + GetTeam(context.TODO(), teamArg, ""). Return(mockTeam, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetUserByEmail(context.Background(), mockUser.Id, ""). + GetUserByEmail(context.TODO(), mockUser.Id, ""). Return(nil, nil, nil). Times(1) s.client. EXPECT(). - GetUserByUsername(context.Background(), mockUser.Id, ""). + GetUserByUsername(context.TODO(), mockUser.Id, ""). Return(nil, nil, nil). Times(1) s.client. EXPECT(). - GetUser(context.Background(), mockUser.Id, ""). + GetUser(context.TODO(), mockUser.Id, ""). Return(mockUser, nil, nil). Times(1) s.client. EXPECT(). - RemoveTeamMember(context.Background(), mockTeam.Id, mockUser.Id). + RemoveTeamMember(context.TODO(), mockTeam.Id, mockUser.Id). Return(&model.Response{StatusCode: http.StatusBadRequest}, nil). Times(1) @@ -220,19 +220,19 @@ func (s *MmctlUnitTestSuite) TestTeamUsersArchiveCmd() { s.client. EXPECT(). - GetTeam(context.Background(), teamArg, ""). + GetTeam(context.TODO(), teamArg, ""). Return(mockTeam, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetUserByEmail(context.Background(), mockUser.Id, ""). + GetUserByEmail(context.TODO(), mockUser.Id, ""). Return(mockUser, nil, nil). Times(1) s.client. EXPECT(). - RemoveTeamMember(context.Background(), mockTeam.Id, mockUser.Id). + RemoveTeamMember(context.TODO(), mockTeam.Id, mockUser.Id). Return(&model.Response{StatusCode: http.StatusBadRequest}, mockError). Times(1) @@ -261,13 +261,13 @@ func (s *MmctlUnitTestSuite) TestAddUsersCmd() { s.client. EXPECT(). - GetTeam(context.Background(), "team1", ""). + GetTeam(context.TODO(), "team1", ""). Return(nil, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetTeamByName(context.Background(), "team1", ""). + GetTeamByName(context.TODO(), "team1", ""). Return(nil, &model.Response{}, nil). Times(1) @@ -282,25 +282,25 @@ func (s *MmctlUnitTestSuite) TestAddUsersCmd() { s.client. EXPECT(). - GetTeam(context.Background(), "team1", ""). + GetTeam(context.TODO(), "team1", ""). Return(&mockTeam, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetUserByEmail(context.Background(), "user1", ""). + GetUserByEmail(context.TODO(), "user1", ""). Return(nil, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetUserByUsername(context.Background(), "user1", ""). + GetUserByUsername(context.TODO(), "user1", ""). Return(nil, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetUser(context.Background(), "user1", ""). + GetUser(context.TODO(), "user1", ""). Return(nil, &model.Response{}, nil). Times(1) @@ -316,13 +316,13 @@ func (s *MmctlUnitTestSuite) TestAddUsersCmd() { s.client. EXPECT(). - GetTeam(context.Background(), "team1", ""). + GetTeam(context.TODO(), "team1", ""). Return(&mockTeam, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetUserByEmail(context.Background(), "user1", ""). + GetUserByEmail(context.TODO(), "user1", ""). Return(&mockUser, &model.Response{}, nil). Times(1) @@ -330,7 +330,7 @@ func (s *MmctlUnitTestSuite) TestAddUsersCmd() { s.client. EXPECT(). - AddTeamMember(context.Background(), "TeamId", "UserID"). + AddTeamMember(context.TODO(), "TeamId", "UserID"). Return(nil, &model.Response{}, mockError). Times(1) @@ -347,19 +347,19 @@ func (s *MmctlUnitTestSuite) TestAddUsersCmd() { cmd := &cobra.Command{} s.client. EXPECT(). - GetTeam(context.Background(), "team1", ""). + GetTeam(context.TODO(), "team1", ""). Return(&mockTeam, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetUserByEmail(context.Background(), "user1", ""). + GetUserByEmail(context.TODO(), "user1", ""). Return(&mockUser, &model.Response{}, nil). Times(1) s.client. EXPECT(). - AddTeamMember(context.Background(), "TeamId", "UserID"). + AddTeamMember(context.TODO(), "TeamId", "UserID"). Return(nil, &model.Response{}, nil). Times(1) diff --git a/server/cmd/mmctl/commands/teamargs_test.go b/server/cmd/mmctl/commands/teamargs_test.go index cb3bf0a19b..f93dd226c4 100644 --- a/server/cmd/mmctl/commands/teamargs_test.go +++ b/server/cmd/mmctl/commands/teamargs_test.go @@ -19,12 +19,12 @@ func (s *MmctlUnitTestSuite) TestGetTeamArgs() { s.client. EXPECT(). - GetTeam(context.Background(), notFoundTeam, ""). + GetTeam(context.TODO(), notFoundTeam, ""). Return(nil, &model.Response{StatusCode: http.StatusNotFound}, notFoundErr). Times(1) s.client. EXPECT(). - GetTeamByName(context.Background(), notFoundTeam, ""). + GetTeamByName(context.TODO(), notFoundTeam, ""). Return(nil, &model.Response{StatusCode: http.StatusNotFound}, notFoundErr). Times(1) @@ -39,12 +39,12 @@ func (s *MmctlUnitTestSuite) TestGetTeamArgs() { s.client. EXPECT(). - GetTeam(context.Background(), badRequestTeam, ""). + GetTeam(context.TODO(), badRequestTeam, ""). Return(nil, &model.Response{StatusCode: http.StatusBadRequest}, badRequestErr). Times(1) s.client. EXPECT(). - GetTeamByName(context.Background(), badRequestTeam, ""). + GetTeamByName(context.TODO(), badRequestTeam, ""). Return(nil, &model.Response{StatusCode: http.StatusBadRequest}, badRequestErr). Times(1) @@ -59,7 +59,7 @@ func (s *MmctlUnitTestSuite) TestGetTeamArgs() { s.client. EXPECT(). - GetTeam(context.Background(), forbidden, ""). + GetTeam(context.TODO(), forbidden, ""). Return(nil, &model.Response{StatusCode: http.StatusForbidden}, forbiddenErr). Times(1) @@ -74,7 +74,7 @@ func (s *MmctlUnitTestSuite) TestGetTeamArgs() { s.client. EXPECT(). - GetTeam(context.Background(), errTeam, ""). + GetTeam(context.TODO(), errTeam, ""). Return(nil, &model.Response{StatusCode: http.StatusInternalServerError}, internalServerErrorErr). Times(1) @@ -89,7 +89,7 @@ func (s *MmctlUnitTestSuite) TestGetTeamArgs() { s.client. EXPECT(). - GetTeam(context.Background(), successID, ""). + GetTeam(context.TODO(), successID, ""). Return(successTeam, nil, nil). Times(1) diff --git a/server/cmd/mmctl/commands/token_test.go b/server/cmd/mmctl/commands/token_test.go index ccbc39a8b9..8a97de1ebc 100644 --- a/server/cmd/mmctl/commands/token_test.go +++ b/server/cmd/mmctl/commands/token_test.go @@ -26,25 +26,25 @@ func (s *MmctlUnitTestSuite) TestGenerateTokenForAUserCmd() { s.client. EXPECT(). - GetUserByEmail(context.Background(), userArg, ""). + GetUserByEmail(context.TODO(), userArg, ""). Return(nil, &model.Response{}, errors.New("no user found with the given email")). Times(1) s.client. EXPECT(). - GetUserByUsername(context.Background(), userArg, ""). + GetUserByUsername(context.TODO(), userArg, ""). Return(nil, &model.Response{}, errors.New("no user found with the given username")). Times(1) s.client. EXPECT(). - GetUser(context.Background(), userArg, ""). + GetUser(context.TODO(), userArg, ""). Return(&mockUser, &model.Response{}, nil). Times(1) s.client. EXPECT(). - CreateUserAccessToken(context.Background(), mockUser.Id, mockToken.Description). + CreateUserAccessToken(context.TODO(), mockUser.Id, mockToken.Description). Return(&mockToken, &model.Response{}, nil). Times(1) @@ -60,19 +60,19 @@ func (s *MmctlUnitTestSuite) TestGenerateTokenForAUserCmd() { userArg := "some-text" s.client. EXPECT(). - GetUserByEmail(context.Background(), userArg, ""). + GetUserByEmail(context.TODO(), userArg, ""). Return(nil, &model.Response{}, errors.New("no user found with the given email")). Times(1) s.client. EXPECT(). - GetUserByUsername(context.Background(), userArg, ""). + GetUserByUsername(context.TODO(), userArg, ""). Return(nil, &model.Response{}, errors.New("no user found with the given username")). Times(1) s.client. EXPECT(). - GetUser(context.Background(), userArg, ""). + GetUser(context.TODO(), userArg, ""). Return(nil, &model.Response{}, errors.New("no user found with the given ID")). Times(1) @@ -89,19 +89,19 @@ func (s *MmctlUnitTestSuite) TestGenerateTokenForAUserCmd() { s.client. EXPECT(). - GetUserByEmail(context.Background(), userArg, ""). + GetUserByEmail(context.TODO(), userArg, ""). Return(nil, &model.Response{}, errors.New("no user found with the given email")). Times(1) s.client. EXPECT(). - GetUserByUsername(context.Background(), userArg, ""). + GetUserByUsername(context.TODO(), userArg, ""). Return(&mockUser, &model.Response{}, nil). Times(1) s.client. EXPECT(). - CreateUserAccessToken(context.Background(), mockUser.Id, "description"). + CreateUserAccessToken(context.TODO(), mockUser.Id, "description"). Return(nil, &model.Response{}, errors.New("error-message")). Times(1) @@ -128,25 +128,25 @@ func (s *MmctlUnitTestSuite) TestListTokensOfAUserCmdF() { s.client. EXPECT(). - GetUserByEmail(context.Background(), mockUser.Id, ""). + GetUserByEmail(context.TODO(), mockUser.Id, ""). Return(nil, &model.Response{}, errors.New("no user found with the given email")). Times(1) s.client. EXPECT(). - GetUserByUsername(context.Background(), mockUser.Id, ""). + GetUserByUsername(context.TODO(), mockUser.Id, ""). Return(nil, &model.Response{}, errors.New("no user found with the given username")). Times(1) s.client. EXPECT(). - GetUser(context.Background(), mockUser.Id, ""). + GetUser(context.TODO(), mockUser.Id, ""). Return(&mockUser, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetUserAccessTokensForUser(context.Background(), mockUser.Id, 0, 9999). + GetUserAccessTokensForUser(context.TODO(), mockUser.Id, 0, 9999). Return( []*model.UserAccessToken{&mockToken1, &mockToken2}, &model.Response{}, nil, @@ -175,13 +175,13 @@ func (s *MmctlUnitTestSuite) TestListTokensOfAUserCmdF() { s.client. EXPECT(). - GetUserByEmail(context.Background(), mockUser.Email, ""). + GetUserByEmail(context.TODO(), mockUser.Email, ""). Return(&mockUser, &model.Response{}, errors.New("no user found with the given email")). Times(1) s.client. EXPECT(). - GetUserAccessTokensForUser(context.Background(), mockUser.Id, 0, 2). + GetUserAccessTokensForUser(context.TODO(), mockUser.Id, 0, 2). Return( []*model.UserAccessToken{&mockToken1, &mockToken2}, &model.Response{}, nil, @@ -206,19 +206,19 @@ func (s *MmctlUnitTestSuite) TestListTokensOfAUserCmdF() { s.client. EXPECT(). - GetUserByEmail(context.Background(), userArg, ""). + GetUserByEmail(context.TODO(), userArg, ""). Return(nil, &model.Response{}, errors.New("no user found with the given email")). Times(1) s.client. EXPECT(). - GetUserByUsername(context.Background(), userArg, ""). + GetUserByUsername(context.TODO(), userArg, ""). Return(nil, &model.Response{}, errors.New("no user found with the given username")). Times(1) s.client. EXPECT(). - GetUser(context.Background(), userArg, ""). + GetUser(context.TODO(), userArg, ""). Return(nil, &model.Response{}, errors.New("no user found with the given user ID")). Times(1) @@ -241,13 +241,13 @@ func (s *MmctlUnitTestSuite) TestListTokensOfAUserCmdF() { s.client. EXPECT(). - GetUserByEmail(context.Background(), mockUser.Email, ""). + GetUserByEmail(context.TODO(), mockUser.Email, ""). Return(&mockUser, &model.Response{}, errors.New("no user found with the given email")). Times(1) s.client. EXPECT(). - GetUserAccessTokensForUser(context.Background(), mockUser.Id, 0, 2). + GetUserAccessTokensForUser(context.TODO(), mockUser.Id, 0, 2). Return( []*model.UserAccessToken{}, &model.Response{}, nil, @@ -268,13 +268,13 @@ func (s *MmctlUnitTestSuite) TestRevokeTokenForAUserCmdF() { s.client. EXPECT(). - RevokeUserAccessToken(context.Background(), mockToken1.Id). + RevokeUserAccessToken(context.TODO(), mockToken1.Id). Return(&model.Response{StatusCode: http.StatusOK}, nil). Times(1) s.client. EXPECT(). - RevokeUserAccessToken(context.Background(), mockToken2.Id). + RevokeUserAccessToken(context.TODO(), mockToken2.Id). Return(&model.Response{StatusCode: http.StatusOK}, nil). Times(1) @@ -286,7 +286,7 @@ func (s *MmctlUnitTestSuite) TestRevokeTokenForAUserCmdF() { s.Run("Should fail if can't revoke user access token", func() { s.client. EXPECT(). - RevokeUserAccessToken(context.Background(), "token-id"). + RevokeUserAccessToken(context.TODO(), "token-id"). Return(&model.Response{StatusCode: http.StatusBadRequest}, errors.New("some-error")). Times(1) diff --git a/server/cmd/mmctl/commands/user_e2e_test.go b/server/cmd/mmctl/commands/user_e2e_test.go index a2eec0f69c..ff51344222 100644 --- a/server/cmd/mmctl/commands/user_e2e_test.go +++ b/server/cmd/mmctl/commands/user_e2e_test.go @@ -1073,14 +1073,14 @@ func (s *MmctlE2ETestSuite) cleanUpPreferences(userID string) { s.T().Helper() // Delete any existing preferences - preferences, _, err := s.th.SystemAdminClient.GetPreferences(context.Background(), userID) + preferences, _, err := s.th.SystemAdminClient.GetPreferences(context.TODO(), userID) s.NoError(err) if len(preferences) == 0 { return } - _, err = s.th.SystemAdminClient.DeletePreferences(context.Background(), userID, preferences) + _, err = s.th.SystemAdminClient.DeletePreferences(context.TODO(), userID, preferences) s.NoError(err) } @@ -1091,17 +1091,17 @@ func (s *MmctlE2ETestSuite) TestPreferenceListCmd() { s.cleanUpPreferences(s.th.BasicUser2.Id) preference1 := model.Preference{UserId: s.th.BasicUser.Id, Category: "display_settings", Name: "collapsed_reply_threads", Value: "threads_view"} - _, err := s.th.SystemAdminClient.UpdatePreferences(context.Background(), s.th.BasicUser.Id, model.Preferences{preference1}) + _, err := s.th.SystemAdminClient.UpdatePreferences(context.TODO(), s.th.BasicUser.Id, model.Preferences{preference1}) s.NoError(err) preference2 := model.Preference{UserId: s.th.BasicUser.Id, Category: "display_settings", Name: "colorize_usernames", Value: "threads_view"} - _, err = s.th.SystemAdminClient.UpdatePreferences(context.Background(), s.th.BasicUser.Id, model.Preferences{preference2}) + _, err = s.th.SystemAdminClient.UpdatePreferences(context.TODO(), s.th.BasicUser.Id, model.Preferences{preference2}) s.NoError(err) preference3 := model.Preference{UserId: s.th.BasicUser.Id, Category: "drafts", Name: "drafts_tour_tip_showed", Value: `{"drafts_tour_tip_showed":true}`} - _, err = s.th.SystemAdminClient.UpdatePreferences(context.Background(), s.th.BasicUser.Id, model.Preferences{preference3}) + _, err = s.th.SystemAdminClient.UpdatePreferences(context.TODO(), s.th.BasicUser.Id, model.Preferences{preference3}) s.NoError(err) preference4 := model.Preference{UserId: s.th.BasicUser2.Id, Category: "display_settings", Name: "collapsed_reply_threads", Value: "threads_view"} - _, err = s.th.SystemAdminClient.UpdatePreferences(context.Background(), s.th.BasicUser2.Id, model.Preferences{preference4}) + _, err = s.th.SystemAdminClient.UpdatePreferences(context.TODO(), s.th.BasicUser2.Id, model.Preferences{preference4}) s.NoError(err) s.Run("list all preferences for single user", func() { @@ -1182,17 +1182,17 @@ func (s *MmctlE2ETestSuite) TestPreferenceGetCmd() { s.cleanUpPreferences(s.th.BasicUser2.Id) preference1 := model.Preference{UserId: s.th.BasicUser.Id, Category: "display_settings", Name: "collapsed_reply_threads", Value: "threads_view"} - _, err := s.th.SystemAdminClient.UpdatePreferences(context.Background(), s.th.BasicUser.Id, model.Preferences{preference1}) + _, err := s.th.SystemAdminClient.UpdatePreferences(context.TODO(), s.th.BasicUser.Id, model.Preferences{preference1}) s.NoError(err) preference2 := model.Preference{UserId: s.th.BasicUser.Id, Category: "display_settings", Name: "colorize_usernames", Value: "threads_view"} - _, err = s.th.SystemAdminClient.UpdatePreferences(context.Background(), s.th.BasicUser.Id, model.Preferences{preference2}) + _, err = s.th.SystemAdminClient.UpdatePreferences(context.TODO(), s.th.BasicUser.Id, model.Preferences{preference2}) s.NoError(err) preference3 := model.Preference{UserId: s.th.BasicUser.Id, Category: "drafts", Name: "drafts_tour_tip_showed", Value: `{"drafts_tour_tip_showed":true}`} - _, err = s.th.SystemAdminClient.UpdatePreferences(context.Background(), s.th.BasicUser.Id, model.Preferences{preference3}) + _, err = s.th.SystemAdminClient.UpdatePreferences(context.TODO(), s.th.BasicUser.Id, model.Preferences{preference3}) s.NoError(err) preference4 := model.Preference{UserId: s.th.BasicUser2.Id, Category: "display_settings", Name: "collapsed_reply_threads", Value: "threads_view"} - _, err = s.th.SystemAdminClient.UpdatePreferences(context.Background(), s.th.BasicUser2.Id, model.Preferences{preference4}) + _, err = s.th.SystemAdminClient.UpdatePreferences(context.TODO(), s.th.BasicUser2.Id, model.Preferences{preference4}) s.NoError(err) s.Run("get preference for single user", func() { @@ -1251,14 +1251,14 @@ func (s *MmctlE2ETestSuite) TestPreferenceUpdateCmd() { s.cleanUpPreferences(s.th.BasicUser.Id) s.cleanUpPreferences(s.th.BasicUser2.Id) - _, err := s.th.SystemAdminClient.UpdatePreferences(context.Background(), s.th.BasicUser.Id, model.Preferences{preference1}) + _, err := s.th.SystemAdminClient.UpdatePreferences(context.TODO(), s.th.BasicUser.Id, model.Preferences{preference1}) s.NoError(err) - _, err = s.th.SystemAdminClient.UpdatePreferences(context.Background(), s.th.BasicUser.Id, model.Preferences{preference2}) + _, err = s.th.SystemAdminClient.UpdatePreferences(context.TODO(), s.th.BasicUser.Id, model.Preferences{preference2}) s.NoError(err) - _, err = s.th.SystemAdminClient.UpdatePreferences(context.Background(), s.th.BasicUser.Id, model.Preferences{preference3}) + _, err = s.th.SystemAdminClient.UpdatePreferences(context.TODO(), s.th.BasicUser.Id, model.Preferences{preference3}) s.NoError(err) - _, err = s.th.SystemAdminClient.UpdatePreferences(context.Background(), s.th.BasicUser2.Id, model.Preferences{preference4}) + _, err = s.th.SystemAdminClient.UpdatePreferences(context.TODO(), s.th.BasicUser2.Id, model.Preferences{preference4}) s.NoError(err) } @@ -1277,7 +1277,7 @@ func (s *MmctlE2ETestSuite) TestPreferenceUpdateCmd() { s.Require().NoError(err) s.Require().Len(printer.GetErrorLines(), 0) - actualPreferencesUser1, _, err := s.th.SystemAdminClient.GetPreferences(context.Background(), s.th.BasicUser.Id) + actualPreferencesUser1, _, err := s.th.SystemAdminClient.GetPreferences(context.TODO(), s.th.BasicUser.Id) s.NoError(err) s.Require().Len(actualPreferencesUser1, 4) s.Require().Equal(preference1, actualPreferencesUser1[0]) @@ -1286,7 +1286,7 @@ func (s *MmctlE2ETestSuite) TestPreferenceUpdateCmd() { s.Require().Equal(preferenceNew, actualPreferencesUser1[3]) // Second user unaffected - actualPreferencesUser2, _, err := s.th.SystemAdminClient.GetPreferences(context.Background(), s.th.BasicUser2.Id) + actualPreferencesUser2, _, err := s.th.SystemAdminClient.GetPreferences(context.TODO(), s.th.BasicUser2.Id) s.NoError(err) s.Require().Len(actualPreferencesUser2, 1) s.Require().Equal(preference4, actualPreferencesUser2[0]) @@ -1308,7 +1308,7 @@ func (s *MmctlE2ETestSuite) TestPreferenceUpdateCmd() { s.Require().NoError(err) s.Require().Len(printer.GetErrorLines(), 0) - actualPreferencesUser1, _, err := s.th.SystemAdminClient.GetPreferences(context.Background(), s.th.BasicUser.Id) + actualPreferencesUser1, _, err := s.th.SystemAdminClient.GetPreferences(context.TODO(), s.th.BasicUser.Id) s.NoError(err) s.Require().Len(actualPreferencesUser1, 4) s.Require().Equal(preference1, actualPreferencesUser1[0]) @@ -1317,7 +1317,7 @@ func (s *MmctlE2ETestSuite) TestPreferenceUpdateCmd() { s.Require().Equal(preferenceNew, actualPreferencesUser1[3]) // Second user unaffected - actualPreferencesUser2, _, err := s.th.SystemAdminClient.GetPreferences(context.Background(), s.th.BasicUser2.Id) + actualPreferencesUser2, _, err := s.th.SystemAdminClient.GetPreferences(context.TODO(), s.th.BasicUser2.Id) s.NoError(err) s.Require().Len(actualPreferencesUser2, 2) s.Require().Equal(preference4, actualPreferencesUser2[0]) @@ -1354,7 +1354,7 @@ func (s *MmctlE2ETestSuite) TestPreferenceUpdateCmd() { s.Require().NoError(err) s.Require().Len(printer.GetErrorLines(), 0) - actualPreferencesUser1, _, err := s.th.SystemAdminClient.GetPreferences(context.Background(), s.th.BasicUser.Id) + actualPreferencesUser1, _, err := s.th.SystemAdminClient.GetPreferences(context.TODO(), s.th.BasicUser.Id) s.NoError(err) s.Require().Len(actualPreferencesUser1, 3) s.Require().Equal(preferenceUpdated, actualPreferencesUser1[0]) @@ -1362,7 +1362,7 @@ func (s *MmctlE2ETestSuite) TestPreferenceUpdateCmd() { s.Require().Equal(preference3, actualPreferencesUser1[2]) // Second user unaffected - actualPreferencesUser2, _, err := s.th.SystemAdminClient.GetPreferences(context.Background(), s.th.BasicUser2.Id) + actualPreferencesUser2, _, err := s.th.SystemAdminClient.GetPreferences(context.TODO(), s.th.BasicUser2.Id) s.NoError(err) s.Require().Len(actualPreferencesUser2, 1) s.Require().Equal(preference4, actualPreferencesUser2[0]) @@ -1384,14 +1384,14 @@ func (s *MmctlE2ETestSuite) TestPreferenceUpdateCmd() { s.Require().NoError(err) s.Require().Len(printer.GetErrorLines(), 0) - actualPreferencesUser1, _, err := s.th.SystemAdminClient.GetPreferences(context.Background(), s.th.BasicUser.Id) + actualPreferencesUser1, _, err := s.th.SystemAdminClient.GetPreferences(context.TODO(), s.th.BasicUser.Id) s.NoError(err) s.Require().Len(actualPreferencesUser1, 3) s.Require().Equal(preferenceUpdated, actualPreferencesUser1[0]) s.Require().Equal(preference2, actualPreferencesUser1[1]) s.Require().Equal(preference3, actualPreferencesUser1[2]) - actualPreferencesUser2, _, err := s.th.SystemAdminClient.GetPreferences(context.Background(), s.th.BasicUser2.Id) + actualPreferencesUser2, _, err := s.th.SystemAdminClient.GetPreferences(context.TODO(), s.th.BasicUser2.Id) s.NoError(err) s.Require().Len(actualPreferencesUser2, 1) s.Require().Equal(preferenceUpdated2, actualPreferencesUser2[0]) @@ -1420,17 +1420,17 @@ func (s *MmctlE2ETestSuite) TestPreferenceDeleteCmd() { s.cleanUpPreferences(s.th.BasicUser2.Id) preference1 := model.Preference{UserId: s.th.BasicUser.Id, Category: "display_settings", Name: "collapsed_reply_threads", Value: "threads_view"} - _, err := s.th.SystemAdminClient.UpdatePreferences(context.Background(), s.th.BasicUser.Id, model.Preferences{preference1}) + _, err := s.th.SystemAdminClient.UpdatePreferences(context.TODO(), s.th.BasicUser.Id, model.Preferences{preference1}) s.NoError(err) preference2 := model.Preference{UserId: s.th.BasicUser.Id, Category: "display_settings", Name: "colorize_usernames", Value: "threads_view"} - _, err = s.th.SystemAdminClient.UpdatePreferences(context.Background(), s.th.BasicUser.Id, model.Preferences{preference2}) + _, err = s.th.SystemAdminClient.UpdatePreferences(context.TODO(), s.th.BasicUser.Id, model.Preferences{preference2}) s.NoError(err) preference3 := model.Preference{UserId: s.th.BasicUser.Id, Category: "drafts", Name: "drafts_tour_tip_showed", Value: `{"drafts_tour_tip_showed":true}`} - _, err = s.th.SystemAdminClient.UpdatePreferences(context.Background(), s.th.BasicUser.Id, model.Preferences{preference3}) + _, err = s.th.SystemAdminClient.UpdatePreferences(context.TODO(), s.th.BasicUser.Id, model.Preferences{preference3}) s.NoError(err) preference4 := model.Preference{UserId: s.th.BasicUser2.Id, Category: "display_settings", Name: "collapsed_reply_threads", Value: "threads_view"} - _, err = s.th.SystemAdminClient.UpdatePreferences(context.Background(), s.th.BasicUser2.Id, model.Preferences{preference4}) + _, err = s.th.SystemAdminClient.UpdatePreferences(context.TODO(), s.th.BasicUser2.Id, model.Preferences{preference4}) s.NoError(err) s.Run("delete non-existing preference for single user", func() { @@ -1446,7 +1446,7 @@ func (s *MmctlE2ETestSuite) TestPreferenceDeleteCmd() { s.Require().NoError(err) s.Require().Len(printer.GetErrorLines(), 0) - actualPreferencesUser1, _, err := s.th.SystemAdminClient.GetPreferences(context.Background(), s.th.BasicUser.Id) + actualPreferencesUser1, _, err := s.th.SystemAdminClient.GetPreferences(context.TODO(), s.th.BasicUser.Id) s.NoError(err) s.Require().Len(actualPreferencesUser1, 3) s.Require().Equal(preference1, actualPreferencesUser1[0]) @@ -1454,7 +1454,7 @@ func (s *MmctlE2ETestSuite) TestPreferenceDeleteCmd() { s.Require().Equal(preference3, actualPreferencesUser1[2]) // Second user unaffected - actualPreferencesUser2, _, err := s.th.SystemAdminClient.GetPreferences(context.Background(), s.th.BasicUser2.Id) + actualPreferencesUser2, _, err := s.th.SystemAdminClient.GetPreferences(context.TODO(), s.th.BasicUser2.Id) s.NoError(err) s.Require().Len(actualPreferencesUser2, 1) s.Require().Equal(preference4, actualPreferencesUser2[0]) @@ -1471,14 +1471,14 @@ func (s *MmctlE2ETestSuite) TestPreferenceDeleteCmd() { s.Require().NoError(err) s.Require().Len(printer.GetErrorLines(), 0) - actualPreferencesUser1, _, err := s.th.SystemAdminClient.GetPreferences(context.Background(), s.th.BasicUser.Id) + actualPreferencesUser1, _, err := s.th.SystemAdminClient.GetPreferences(context.TODO(), s.th.BasicUser.Id) s.NoError(err) s.Require().Len(actualPreferencesUser1, 2) s.Require().Equal(preference2, actualPreferencesUser1[0]) s.Require().Equal(preference3, actualPreferencesUser1[1]) // Second user unaffected - actualPreferencesUser2, _, err := s.th.SystemAdminClient.GetPreferences(context.Background(), s.th.BasicUser2.Id) + actualPreferencesUser2, _, err := s.th.SystemAdminClient.GetPreferences(context.TODO(), s.th.BasicUser2.Id) s.NoError(err) s.Require().Len(actualPreferencesUser2, 1) s.Require().Equal(preference4, actualPreferencesUser2[0]) @@ -1495,14 +1495,14 @@ func (s *MmctlE2ETestSuite) TestPreferenceDeleteCmd() { s.Require().NoError(err) s.Require().Len(printer.GetErrorLines(), 0) - actualPreferencesUser1, _, err := s.th.SystemAdminClient.GetPreferences(context.Background(), s.th.BasicUser.Id) + actualPreferencesUser1, _, err := s.th.SystemAdminClient.GetPreferences(context.TODO(), s.th.BasicUser.Id) s.NoError(err) s.Require().Len(actualPreferencesUser1, 2) s.Require().Equal(preference2, actualPreferencesUser1[0]) s.Require().Equal(preference3, actualPreferencesUser1[1]) // Second user unaffected - actualPreferencesUser2, _, err := s.th.SystemAdminClient.GetPreferences(context.Background(), s.th.BasicUser2.Id) + actualPreferencesUser2, _, err := s.th.SystemAdminClient.GetPreferences(context.TODO(), s.th.BasicUser2.Id) s.NoError(err) s.Require().Len(actualPreferencesUser2, 0) }) diff --git a/server/cmd/mmctl/commands/user_test.go b/server/cmd/mmctl/commands/user_test.go index c41123bc09..6f67761d9c 100644 --- a/server/cmd/mmctl/commands/user_test.go +++ b/server/cmd/mmctl/commands/user_test.go @@ -29,13 +29,13 @@ func (s *MmctlUnitTestSuite) TestUserActivateCmd() { s.client. EXPECT(). - GetUserByEmail(context.Background(), emailArg, ""). + GetUserByEmail(context.TODO(), emailArg, ""). Return(&mockUser, &model.Response{}, nil). Times(1) s.client. EXPECT(). - UpdateUserActive(context.Background(), mockUser.Id, true). + UpdateUserActive(context.TODO(), mockUser.Id, true). Return(&model.Response{StatusCode: http.StatusOK}, nil). Times(1) @@ -51,19 +51,19 @@ func (s *MmctlUnitTestSuite) TestUserActivateCmd() { s.client. EXPECT(). - GetUserByEmail(context.Background(), emailArg, ""). + GetUserByEmail(context.TODO(), emailArg, ""). Return(nil, &model.Response{StatusCode: http.StatusNotFound}, errors.New("mock error")). Times(1) s.client. EXPECT(). - GetUserByUsername(context.Background(), emailArg, ""). + GetUserByUsername(context.TODO(), emailArg, ""). Return(nil, &model.Response{StatusCode: http.StatusNotFound}, errors.New("mock error")). Times(1) s.client. EXPECT(). - GetUser(context.Background(), emailArg, ""). + GetUser(context.TODO(), emailArg, ""). Return(nil, &model.Response{StatusCode: http.StatusNotFound}, errors.New("mock error")). Times(1) @@ -81,13 +81,13 @@ func (s *MmctlUnitTestSuite) TestUserActivateCmd() { s.client. EXPECT(). - GetUserByEmail(context.Background(), emailArg, ""). + GetUserByEmail(context.TODO(), emailArg, ""). Return(&mockUser, &model.Response{}, nil). Times(1) s.client. EXPECT(). - UpdateUserActive(context.Background(), mockUser.Id, true). + UpdateUserActive(context.TODO(), mockUser.Id, true). Return(&model.Response{StatusCode: http.StatusBadRequest}, errors.New("mock error")). Times(1) @@ -108,67 +108,67 @@ func (s *MmctlUnitTestSuite) TestUserActivateCmd() { s.client. EXPECT(). - GetUserByEmail(context.Background(), emailArgs[0], ""). + GetUserByEmail(context.TODO(), emailArgs[0], ""). Return(&mockUser0, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetUserByEmail(context.Background(), emailArgs[1], ""). + GetUserByEmail(context.TODO(), emailArgs[1], ""). Return(nil, &model.Response{StatusCode: http.StatusNotFound}, errors.New("mock error")). Times(1) s.client. EXPECT(). - GetUserByUsername(context.Background(), emailArgs[1], ""). + GetUserByUsername(context.TODO(), emailArgs[1], ""). Return(nil, &model.Response{StatusCode: http.StatusNotFound}, errors.New("mock error")). Times(1) s.client. EXPECT(). - GetUser(context.Background(), emailArgs[1], ""). + GetUser(context.TODO(), emailArgs[1], ""). Return(nil, &model.Response{StatusCode: http.StatusNotFound}, errors.New("mock error")). Times(1) s.client. EXPECT(). - GetUserByEmail(context.Background(), emailArgs[2], ""). + GetUserByEmail(context.TODO(), emailArgs[2], ""). Return(&mockUser2, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetUserByEmail(context.Background(), emailArgs[3], ""). + GetUserByEmail(context.TODO(), emailArgs[3], ""). Return(&mockUser3, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetUserByEmail(context.Background(), emailArgs[4], ""). + GetUserByEmail(context.TODO(), emailArgs[4], ""). Return(&mockUser4, &model.Response{}, nil). Times(1) s.client. EXPECT(). - UpdateUserActive(context.Background(), mockUser0.Id, true). + UpdateUserActive(context.TODO(), mockUser0.Id, true). Return(&model.Response{StatusCode: http.StatusOK}, nil). Times(1) s.client. EXPECT(). - UpdateUserActive(context.Background(), mockUser2.Id, true). + UpdateUserActive(context.TODO(), mockUser2.Id, true). Return(&model.Response{StatusCode: http.StatusOK}, nil). Times(1) s.client. EXPECT(). - UpdateUserActive(context.Background(), mockUser3.Id, true). + UpdateUserActive(context.TODO(), mockUser3.Id, true). Return(&model.Response{StatusCode: http.StatusBadRequest}, errors.New("mock error")). Times(1) s.client. EXPECT(). - UpdateUserActive(context.Background(), mockUser4.Id, true). + UpdateUserActive(context.TODO(), mockUser4.Id, true). Return(&model.Response{StatusCode: http.StatusOK}, nil). Times(1) @@ -189,13 +189,13 @@ func (s *MmctlUnitTestSuite) TestDeactivateUserCmd() { s.client. EXPECT(). - GetUserByEmail(context.Background(), emailArg, ""). + GetUserByEmail(context.TODO(), emailArg, ""). Return(&mockUser, &model.Response{}, nil). Times(1) s.client. EXPECT(). - UpdateUserActive(context.Background(), mockUser.Id, false). + UpdateUserActive(context.TODO(), mockUser.Id, false). Return(&model.Response{StatusCode: http.StatusOK}, nil). Times(1) @@ -211,19 +211,19 @@ func (s *MmctlUnitTestSuite) TestDeactivateUserCmd() { s.client. EXPECT(). - GetUserByEmail(context.Background(), emailArg, ""). + GetUserByEmail(context.TODO(), emailArg, ""). Return(nil, &model.Response{StatusCode: http.StatusNotFound}, errors.New("mock error")). Times(1) s.client. EXPECT(). - GetUserByUsername(context.Background(), emailArg, ""). + GetUserByUsername(context.TODO(), emailArg, ""). Return(nil, &model.Response{StatusCode: http.StatusNotFound}, errors.New("mock error")). Times(1) s.client. EXPECT(). - GetUser(context.Background(), emailArg, ""). + GetUser(context.TODO(), emailArg, ""). Return(nil, &model.Response{StatusCode: http.StatusBadRequest}, errors.New("mock error")). Times(1) @@ -241,13 +241,13 @@ func (s *MmctlUnitTestSuite) TestDeactivateUserCmd() { s.client. EXPECT(). - GetUserByEmail(context.Background(), emailArg, ""). + GetUserByEmail(context.TODO(), emailArg, ""). Return(&mockUser, &model.Response{}, nil). Times(1) s.client. EXPECT(). - UpdateUserActive(context.Background(), mockUser.Id, false). + UpdateUserActive(context.TODO(), mockUser.Id, false). Return(&model.Response{StatusCode: http.StatusBadRequest}, errors.New("mock error")). Times(1) @@ -265,13 +265,13 @@ func (s *MmctlUnitTestSuite) TestDeactivateUserCmd() { s.client. EXPECT(). - GetUserByEmail(context.Background(), emailArg, ""). + GetUserByEmail(context.TODO(), emailArg, ""). Return(&mockUser, &model.Response{}, nil). Times(1) s.client. EXPECT(). - UpdateUserActive(context.Background(), mockUser.Id, false). + UpdateUserActive(context.TODO(), mockUser.Id, false). Return(&model.Response{StatusCode: http.StatusOK}, nil). Times(1) @@ -292,67 +292,67 @@ func (s *MmctlUnitTestSuite) TestDeactivateUserCmd() { s.client. EXPECT(). - GetUserByEmail(context.Background(), emailArgs[0], ""). + GetUserByEmail(context.TODO(), emailArgs[0], ""). Return(&mockUser0, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetUserByEmail(context.Background(), emailArgs[1], ""). + GetUserByEmail(context.TODO(), emailArgs[1], ""). Return(nil, &model.Response{StatusCode: http.StatusNotFound}, errors.New("mock error")). Times(1) s.client. EXPECT(). - GetUserByUsername(context.Background(), emailArgs[1], ""). + GetUserByUsername(context.TODO(), emailArgs[1], ""). Return(nil, &model.Response{StatusCode: http.StatusNotFound}, errors.New("mock error")). Times(1) s.client. EXPECT(). - GetUser(context.Background(), emailArgs[1], ""). + GetUser(context.TODO(), emailArgs[1], ""). Return(nil, &model.Response{StatusCode: http.StatusNotFound}, errors.New("mock error")). Times(1) s.client. EXPECT(). - GetUserByEmail(context.Background(), emailArgs[2], ""). + GetUserByEmail(context.TODO(), emailArgs[2], ""). Return(&mockUser2, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetUserByEmail(context.Background(), emailArgs[3], ""). + GetUserByEmail(context.TODO(), emailArgs[3], ""). Return(&mockUser3, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetUserByEmail(context.Background(), emailArgs[4], ""). + GetUserByEmail(context.TODO(), emailArgs[4], ""). Return(&mockUser4, &model.Response{}, nil). Times(1) s.client. EXPECT(). - UpdateUserActive(context.Background(), mockUser0.Id, false). + UpdateUserActive(context.TODO(), mockUser0.Id, false). Return(&model.Response{StatusCode: http.StatusOK}, nil). Times(1) s.client. EXPECT(). - UpdateUserActive(context.Background(), mockUser2.Id, false). + UpdateUserActive(context.TODO(), mockUser2.Id, false). Return(&model.Response{StatusCode: http.StatusOK}, nil). Times(1) s.client. EXPECT(). - UpdateUserActive(context.Background(), mockUser3.Id, false). + UpdateUserActive(context.TODO(), mockUser3.Id, false). Return(&model.Response{StatusCode: http.StatusBadRequest}, errors.New("mock error")). Times(1) s.client. EXPECT(). - UpdateUserActive(context.Background(), mockUser4.Id, false). + UpdateUserActive(context.TODO(), mockUser4.Id, false). Return(&model.Response{StatusCode: http.StatusOK}, nil). Times(1) @@ -388,19 +388,19 @@ func (s *MmctlUnitTestSuite) TestDeleteUsersCmd() { s.client. EXPECT(). - GetUserByEmail(context.Background(), arg, ""). + GetUserByEmail(context.TODO(), arg, ""). Return(nil, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetUserByUsername(context.Background(), arg, ""). + GetUserByUsername(context.TODO(), arg, ""). Return(nil, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetUser(context.Background(), arg, ""). + GetUser(context.TODO(), arg, ""). Return(nil, &model.Response{}, nil). Times(1) @@ -417,23 +417,23 @@ func (s *MmctlUnitTestSuite) TestDeleteUsersCmd() { s.client. EXPECT(). - GetUserByEmail(context.Background(), email1, ""). + GetUserByEmail(context.TODO(), email1, ""). Return(&mockUser1, &model.Response{}, nil). Times(1) s.client. EXPECT(). - PermanentDeleteUser(context.Background(), userID1). + PermanentDeleteUser(context.TODO(), userID1). Return(&model.Response{StatusCode: http.StatusOK}, nil). Times(1) s.client. EXPECT(). - GetUserByEmail(context.Background(), email2, ""). + GetUserByEmail(context.TODO(), email2, ""). Return(&mockUser2, &model.Response{}, nil). Times(1) s.client. EXPECT(). - PermanentDeleteUser(context.Background(), userID2). + PermanentDeleteUser(context.TODO(), userID2). Return(&model.Response{StatusCode: http.StatusOK}, nil). Times(1) @@ -453,13 +453,13 @@ func (s *MmctlUnitTestSuite) TestDeleteUsersCmd() { s.client. EXPECT(). - GetUserByEmail(context.Background(), email1, ""). + GetUserByEmail(context.TODO(), email1, ""). Return(&mockUser1, &model.Response{}, nil). Times(1) s.client. EXPECT(). - PermanentDeleteUser(context.Background(), userID1). + PermanentDeleteUser(context.TODO(), userID1). Return(&model.Response{StatusCode: http.StatusBadRequest}, mockError). Times(1) @@ -480,23 +480,23 @@ func (s *MmctlUnitTestSuite) TestDeleteUsersCmd() { s.client. EXPECT(). - GetUserByEmail(context.Background(), email1, ""). + GetUserByEmail(context.TODO(), email1, ""). Return(&mockUser1, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetUserByEmail(context.Background(), email2, ""). + GetUserByEmail(context.TODO(), email2, ""). Return(&mockUser2, &model.Response{}, nil). Times(1) s.client. EXPECT(). - PermanentDeleteUser(context.Background(), userID1). + PermanentDeleteUser(context.TODO(), userID1). Return(&model.Response{StatusCode: http.StatusBadRequest}, mockError). Times(1) s.client. EXPECT(). - PermanentDeleteUser(context.Background(), userID2). + PermanentDeleteUser(context.TODO(), userID2). Return(&model.Response{StatusCode: http.StatusOK}, nil). Times(1) @@ -517,12 +517,12 @@ func (s *MmctlUnitTestSuite) TestDeleteUsersCmd() { s.client. EXPECT(). - GetUserByEmail(context.Background(), email1, ""). + GetUserByEmail(context.TODO(), email1, ""). Return(&mockUser1, &model.Response{}, nil). Times(1) s.client. EXPECT(). - PermanentDeleteUser(context.Background(), userID1). + PermanentDeleteUser(context.TODO(), userID1). Return(&model.Response{StatusCode: http.StatusAccepted}, nil). Times(1) @@ -545,7 +545,7 @@ func (s *MmctlUnitTestSuite) TestDeleteAllUsersCmd() { s.client. EXPECT(). - PermanentDeleteAllUsers(context.Background()). + PermanentDeleteAllUsers(context.TODO()). Return(&model.Response{StatusCode: http.StatusOK}, nil). Times(1) @@ -563,7 +563,7 @@ func (s *MmctlUnitTestSuite) TestDeleteAllUsersCmd() { s.client. EXPECT(). - PermanentDeleteAllUsers(context.Background()). + PermanentDeleteAllUsers(context.TODO()). Return(&model.Response{StatusCode: http.StatusBadRequest}, errors.New("mock error")). Times(1) @@ -581,7 +581,7 @@ func (s *MmctlUnitTestSuite) TestSearchUserCmd() { s.client. EXPECT(). - GetUserByEmail(context.Background(), emailArg, ""). + GetUserByEmail(context.TODO(), emailArg, ""). Return(&mockUser, &model.Response{}, nil). Times(1) @@ -597,19 +597,19 @@ func (s *MmctlUnitTestSuite) TestSearchUserCmd() { s.client. EXPECT(). - GetUserByEmail(context.Background(), arg, ""). + GetUserByEmail(context.TODO(), arg, ""). Return(nil, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetUserByUsername(context.Background(), arg, ""). + GetUserByUsername(context.TODO(), arg, ""). Return(nil, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetUser(context.Background(), arg, ""). + GetUser(context.TODO(), arg, ""). Return(nil, &model.Response{}, nil). Times(1) @@ -634,7 +634,7 @@ func (s *MmctlUnitTestSuite) TestSearchUserCmd() { s.client. EXPECT(). - GetUserByEmail(context.Background(), emailArg, ""). + GetUserByEmail(context.TODO(), emailArg, ""). Return(nil, &model.Response{}, errors.New("Error while getting user by email")). Times(1) @@ -651,13 +651,13 @@ func (s *MmctlUnitTestSuite) TestSearchUserCmd() { s.client. EXPECT(). - GetUserByEmail(context.Background(), usernameArg, ""). + GetUserByEmail(context.TODO(), usernameArg, ""). Return(nil, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetUserByUsername(context.Background(), usernameArg, ""). + GetUserByUsername(context.TODO(), usernameArg, ""). Return(nil, &model.Response{}, errors.New("Error while getting user by username")). Times(1) @@ -674,19 +674,19 @@ func (s *MmctlUnitTestSuite) TestSearchUserCmd() { s.client. EXPECT(). - GetUserByEmail(context.Background(), userArg, ""). + GetUserByEmail(context.TODO(), userArg, ""). Return(nil, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetUserByUsername(context.Background(), userArg, ""). + GetUserByUsername(context.TODO(), userArg, ""). Return(nil, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetUser(context.Background(), userArg, ""). + GetUser(context.TODO(), userArg, ""). Return(nil, &model.Response{}, errors.New("Error while getting user")). Times(1) @@ -708,13 +708,13 @@ func (s *MmctlUnitTestSuite) TestChangePasswordUserCmdF() { s.client. EXPECT(). - GetUserByEmail(context.Background(), emailArg, ""). + GetUserByEmail(context.TODO(), emailArg, ""). Return(&mockUser, &model.Response{}, nil). Times(1) s.client. EXPECT(). - UpdateUserPassword(context.Background(), mockUser.Id, currentPassword, password). + UpdateUserPassword(context.TODO(), mockUser.Id, currentPassword, password). Return(&model.Response{StatusCode: http.StatusOK}, nil). Times(1) @@ -737,13 +737,13 @@ func (s *MmctlUnitTestSuite) TestChangePasswordUserCmdF() { s.client. EXPECT(). - GetUserByEmail(context.Background(), emailArg, ""). + GetUserByEmail(context.TODO(), emailArg, ""). Return(&mockUser, &model.Response{}, nil). Times(1) s.client. EXPECT(). - UpdateUserPassword(context.Background(), mockUser.Id, "", password). + UpdateUserPassword(context.TODO(), mockUser.Id, "", password). Return(&model.Response{StatusCode: http.StatusOK}, nil). Times(1) @@ -767,13 +767,13 @@ func (s *MmctlUnitTestSuite) TestChangePasswordUserCmdF() { s.client. EXPECT(). - GetUserByEmail(context.Background(), emailArg, ""). + GetUserByEmail(context.TODO(), emailArg, ""). Return(&mockUser, &model.Response{}, nil). Times(1) s.client. EXPECT(). - UpdateUserPassword(context.Background(), mockUser.Id, currentPassword, password). + UpdateUserPassword(context.TODO(), mockUser.Id, currentPassword, password). Return(&model.Response{StatusCode: http.StatusOK}, mockError). Times(1) @@ -797,13 +797,13 @@ func (s *MmctlUnitTestSuite) TestChangePasswordUserCmdF() { s.client. EXPECT(). - GetUserByEmail(context.Background(), emailArg, ""). + GetUserByEmail(context.TODO(), emailArg, ""). Return(&mockUser, &model.Response{}, nil). Times(1) s.client. EXPECT(). - UpdateUserPassword(context.Background(), mockUser.Id, "", password). + UpdateUserPassword(context.TODO(), mockUser.Id, "", password). Return(&model.Response{StatusCode: http.StatusOK}, mockError). Times(1) @@ -824,19 +824,19 @@ func (s *MmctlUnitTestSuite) TestChangePasswordUserCmdF() { s.client. EXPECT(). - GetUserByEmail(context.Background(), arg, ""). + GetUserByEmail(context.TODO(), arg, ""). Return(nil, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetUserByUsername(context.Background(), arg, ""). + GetUserByUsername(context.TODO(), arg, ""). Return(nil, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetUser(context.Background(), arg, ""). + GetUser(context.TODO(), arg, ""). Return(nil, &model.Response{}, nil). Times(1) @@ -858,13 +858,13 @@ func (s *MmctlUnitTestSuite) TestChangePasswordUserCmdF() { s.client. EXPECT(). - GetUserByEmail(context.Background(), emailArg, ""). + GetUserByEmail(context.TODO(), emailArg, ""). Return(&mockUser, &model.Response{}, nil). Times(1) s.client. EXPECT(). - UpdateUserHashedPassword(context.Background(), mockUser.Id, hashedPassword). + UpdateUserHashedPassword(context.TODO(), mockUser.Id, hashedPassword). Return(&model.Response{StatusCode: http.StatusOK}, nil). Times(1) @@ -888,13 +888,13 @@ func (s *MmctlUnitTestSuite) TestChangePasswordUserCmdF() { s.client. EXPECT(). - GetUserByEmail(context.Background(), emailArg, ""). + GetUserByEmail(context.TODO(), emailArg, ""). Return(&mockUser, &model.Response{}, nil). Times(1) s.client. EXPECT(). - UpdateUserHashedPassword(context.Background(), mockUser.Id, hashedPassword). + UpdateUserHashedPassword(context.TODO(), mockUser.Id, hashedPassword). Return(&model.Response{StatusCode: http.StatusOK}, mockError). Times(1) @@ -916,7 +916,7 @@ func (s *MmctlUnitTestSuite) TestSendPasswordResetEmailCmd() { s.client. EXPECT(). - SendPasswordResetEmail(context.Background(), emailArg). + SendPasswordResetEmail(context.TODO(), emailArg). Return(&model.Response{StatusCode: http.StatusBadRequest}, nil). Times(1) @@ -949,7 +949,7 @@ func (s *MmctlUnitTestSuite) TestSendPasswordResetEmailCmd() { s.client. EXPECT(). - SendPasswordResetEmail(context.Background(), emailArg). + SendPasswordResetEmail(context.TODO(), emailArg). Return(&model.Response{StatusCode: http.StatusBadRequest}, mockError). Times(1) @@ -981,7 +981,7 @@ func (s *MmctlUnitTestSuite) TestSendPasswordResetEmailCmd() { case strings.HasPrefix(email, "error"): s.client. EXPECT(). - SendPasswordResetEmail(context.Background(), email). + SendPasswordResetEmail(context.TODO(), email). Return(&model.Response{StatusCode: http.StatusBadRequest}, mockError). Times(1) expected = multierror.Append(expected, fmt.Errorf("unable send reset password email to email %s: %w", email, mockError)) @@ -990,7 +990,7 @@ func (s *MmctlUnitTestSuite) TestSendPasswordResetEmailCmd() { default: s.client. EXPECT(). - SendPasswordResetEmail(context.Background(), email). + SendPasswordResetEmail(context.TODO(), email). Return(&model.Response{StatusCode: http.StatusBadRequest}, nil). Times(1) } @@ -1014,13 +1014,13 @@ func (s *MmctlUnitTestSuite) TestUserInviteCmd() { s.client. EXPECT(). - GetTeam(context.Background(), argTeam, ""). + GetTeam(context.TODO(), argTeam, ""). Return(&model.Team{Id: argTeam}, &model.Response{}, nil). Times(1) s.client. EXPECT(). - InviteUsersToTeam(context.Background(), argTeam, []string{argUser}). + InviteUsersToTeam(context.TODO(), argTeam, []string{argUser}). Return(&model.Response{StatusCode: http.StatusBadRequest}, nil). Times(1) @@ -1039,19 +1039,19 @@ func (s *MmctlUnitTestSuite) TestUserInviteCmd() { s.client. EXPECT(). - GetTeam(context.Background(), argTeam, ""). + GetTeam(context.TODO(), argTeam, ""). Return(nil, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetTeamByName(context.Background(), argTeam, ""). + GetTeamByName(context.TODO(), argTeam, ""). Return(&model.Team{Id: resultID}, &model.Response{}, nil). Times(1) s.client. EXPECT(). - InviteUsersToTeam(context.Background(), resultID, []string{argUser}). + InviteUsersToTeam(context.TODO(), resultID, []string{argUser}). Return(&model.Response{StatusCode: http.StatusBadRequest}, nil). Times(1) @@ -1076,38 +1076,38 @@ func (s *MmctlUnitTestSuite) TestUserInviteCmd() { // Setup GetTeam s.client. EXPECT(). - GetTeam(context.Background(), argTeam[0], ""). + GetTeam(context.TODO(), argTeam[0], ""). Return(nil, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetTeam(context.Background(), argTeam[1], ""). + GetTeam(context.TODO(), argTeam[1], ""). Return(resultTeamModels[1], &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetTeam(context.Background(), argTeam[2], ""). + GetTeam(context.TODO(), argTeam[2], ""). Return(resultTeamModels[2], &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetTeam(context.Background(), argTeam[3], ""). + GetTeam(context.TODO(), argTeam[3], ""). Return(nil, &model.Response{}, nil). Times(1) // Setup GetTeamByName s.client. EXPECT(). - GetTeamByName(context.Background(), argTeam[0], ""). + GetTeamByName(context.TODO(), argTeam[0], ""). Return(resultTeamModels[0], &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetTeamByName(context.Background(), argTeam[3], ""). + GetTeamByName(context.TODO(), argTeam[3], ""). Return(resultTeamModels[3], &model.Response{}, nil). Times(1) @@ -1115,7 +1115,7 @@ func (s *MmctlUnitTestSuite) TestUserInviteCmd() { for _, resultTeamModel := range resultTeamModels { s.client. EXPECT(). - InviteUsersToTeam(context.Background(), resultTeamModel.Id, []string{argUser}). + InviteUsersToTeam(context.TODO(), resultTeamModel.Id, []string{argUser}). Return(&model.Response{StatusCode: http.StatusBadRequest}, nil). Times(1) } @@ -1136,13 +1136,13 @@ func (s *MmctlUnitTestSuite) TestUserInviteCmd() { s.client. EXPECT(). - GetTeam(context.Background(), argTeam, ""). + GetTeam(context.TODO(), argTeam, ""). Return(nil, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetTeamByName(context.Background(), argTeam, ""). + GetTeamByName(context.TODO(), argTeam, ""). Return(nil, &model.Response{}, nil). Times(1) @@ -1162,13 +1162,13 @@ func (s *MmctlUnitTestSuite) TestUserInviteCmd() { s.client. EXPECT(). - GetTeam(context.Background(), argTeam, ""). + GetTeam(context.TODO(), argTeam, ""). Return(&model.Team{Id: argTeam, Name: resultName}, &model.Response{}, nil). Times(1) s.client. EXPECT(). - InviteUsersToTeam(context.Background(), argTeam, []string{argUser}). + InviteUsersToTeam(context.TODO(), argTeam, []string{argUser}). Return(&model.Response{StatusCode: http.StatusBadRequest}, mockError). Times(1) @@ -1196,87 +1196,87 @@ func (s *MmctlUnitTestSuite) TestUserInviteCmd() { // Setup GetTeam s.client. EXPECT(). - GetTeam(context.Background(), argTeam[0], ""). + GetTeam(context.TODO(), argTeam[0], ""). Return(nil, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetTeam(context.Background(), argTeam[1], ""). + GetTeam(context.TODO(), argTeam[1], ""). Return(nil, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetTeam(context.Background(), argTeam[2], ""). + GetTeam(context.TODO(), argTeam[2], ""). Return(resultTeamModels[2], &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetTeam(context.Background(), argTeam[3], ""). + GetTeam(context.TODO(), argTeam[3], ""). Return(nil, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetTeam(context.Background(), argTeam[4], ""). + GetTeam(context.TODO(), argTeam[4], ""). Return(resultTeamModels[4], &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetTeam(context.Background(), argTeam[5], ""). + GetTeam(context.TODO(), argTeam[5], ""). Return(resultTeamModels[5], &model.Response{}, nil). Times(1) // Setup GetTeamByName s.client. EXPECT(). - GetTeamByName(context.Background(), argTeam[0], ""). + GetTeamByName(context.TODO(), argTeam[0], ""). Return(resultTeamModels[0], &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetTeamByName(context.Background(), argTeam[1], ""). + GetTeamByName(context.TODO(), argTeam[1], ""). Return(nil, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetTeamByName(context.Background(), argTeam[3], ""). + GetTeamByName(context.TODO(), argTeam[3], ""). Return(resultTeamModels[3], &model.Response{}, nil). Times(1) // Setup InviteUsersToTeam s.client. EXPECT(). - InviteUsersToTeam(context.Background(), resultTeamModels[0].Id, []string{argUser}). + InviteUsersToTeam(context.TODO(), resultTeamModels[0].Id, []string{argUser}). Return(&model.Response{StatusCode: http.StatusBadRequest}, nil). Times(1) s.client. EXPECT(). - InviteUsersToTeam(context.Background(), resultTeamModels[2].Id, []string{argUser}). + InviteUsersToTeam(context.TODO(), resultTeamModels[2].Id, []string{argUser}). Return(&model.Response{StatusCode: http.StatusBadRequest}, nil). Times(1) s.client. EXPECT(). - InviteUsersToTeam(context.Background(), resultTeamModels[3].Id, []string{argUser}). + InviteUsersToTeam(context.TODO(), resultTeamModels[3].Id, []string{argUser}). Return(&model.Response{StatusCode: http.StatusBadRequest}, nil). Times(1) s.client. EXPECT(). - InviteUsersToTeam(context.Background(), resultTeamModels[4].Id, []string{argUser}). + InviteUsersToTeam(context.TODO(), resultTeamModels[4].Id, []string{argUser}). Return(&model.Response{StatusCode: http.StatusBadRequest}, mockError). Times(1) s.client. EXPECT(). - InviteUsersToTeam(context.Background(), resultTeamModels[5].Id, []string{argUser}). + InviteUsersToTeam(context.TODO(), resultTeamModels[5].Id, []string{argUser}). Return(&model.Response{StatusCode: http.StatusBadRequest}, nil). Times(1) @@ -1340,7 +1340,7 @@ func (s *MmctlUnitTestSuite) TestUserCreateCmd() { s.client. EXPECT(). - CreateUser(context.Background(), &mockUser). + CreateUser(context.TODO(), &mockUser). Return(&mockUser, &model.Response{}, nil). Times(1) @@ -1365,7 +1365,7 @@ func (s *MmctlUnitTestSuite) TestUserCreateCmd() { s.client. EXPECT(). - CreateUser(context.Background(), &mockUser). + CreateUser(context.TODO(), &mockUser). Return(&mockUser, &model.Response{}, nil). Times(1) @@ -1391,7 +1391,7 @@ func (s *MmctlUnitTestSuite) TestUserCreateCmd() { s.client. EXPECT(). - CreateUser(context.Background(), &mockUser). + CreateUser(context.TODO(), &mockUser). Return(&mockUser, &model.Response{}, errors.New("remote error")). Times(1) @@ -1410,13 +1410,13 @@ func (s *MmctlUnitTestSuite) TestUserCreateCmd() { s.client. EXPECT(). - CreateUser(context.Background(), &mockUser). + CreateUser(context.TODO(), &mockUser). Return(&mockUser, &model.Response{}, nil). Times(1) s.client. EXPECT(). - UpdateUserRoles(context.Background(), mockUser.Id, "system_user system_admin"). + UpdateUserRoles(context.TODO(), mockUser.Id, "system_user system_admin"). Return(&model.Response{StatusCode: http.StatusOK}, nil). Times(1) @@ -1438,13 +1438,13 @@ func (s *MmctlUnitTestSuite) TestUserCreateCmd() { s.client. EXPECT(). - CreateUser(context.Background(), &mockUser). + CreateUser(context.TODO(), &mockUser). Return(&mockUser, &model.Response{}, nil). Times(1) s.client. EXPECT(). - DemoteUserToGuest(context.Background(), mockUser.Id). + DemoteUserToGuest(context.TODO(), mockUser.Id). Return(&model.Response{StatusCode: http.StatusOK}, nil). Times(1) @@ -1466,13 +1466,13 @@ func (s *MmctlUnitTestSuite) TestUserCreateCmd() { s.client. EXPECT(). - CreateUser(context.Background(), &mockUser). + CreateUser(context.TODO(), &mockUser). Return(&mockUser, &model.Response{}, nil). Times(1) s.client. EXPECT(). - UpdateUserRoles(context.Background(), mockUser.Id, "system_user system_admin"). + UpdateUserRoles(context.TODO(), mockUser.Id, "system_user system_admin"). Return(&model.Response{StatusCode: http.StatusBadRequest}, errors.New("remote error")). Times(1) @@ -1520,19 +1520,19 @@ func (s *MmctlUnitTestSuite) TestUpdateUserEmailCmd() { s.client. EXPECT(). - GetUserByEmail(context.Background(), userArg, ""). + GetUserByEmail(context.TODO(), userArg, ""). Return(nil, &model.Response{StatusCode: http.StatusNotFound}, errors.New("no user found with the given email")). Times(1) s.client. EXPECT(). - GetUserByUsername(context.Background(), userArg, ""). + GetUserByUsername(context.TODO(), userArg, ""). Return(nil, &model.Response{StatusCode: http.StatusNotFound}, errors.New("no user found with the given username")). Times(1) s.client. EXPECT(). - GetUser(context.Background(), userArg, ""). + GetUser(context.TODO(), userArg, ""). Return(nil, &model.Response{StatusCode: http.StatusNotFound}, errors.New("no user found with the given id")). Times(1) @@ -1552,19 +1552,19 @@ func (s *MmctlUnitTestSuite) TestUpdateUserEmailCmd() { s.client. EXPECT(). - GetUserByEmail(context.Background(), userArg, ""). + GetUserByEmail(context.TODO(), userArg, ""). Return(nil, &model.Response{StatusCode: http.StatusNotFound}, errors.New("no user found with the given email")). Times(1) s.client. EXPECT(). - GetUserByUsername(context.Background(), userArg, ""). + GetUserByUsername(context.TODO(), userArg, ""). Return(¤tUser, &model.Response{}, nil). Times(1) s.client. EXPECT(). - UpdateUser(context.Background(), ¤tUser). + UpdateUser(context.TODO(), ¤tUser). Return(nil, &model.Response{}, errors.New("remote error")). Times(1) @@ -1585,19 +1585,19 @@ func (s *MmctlUnitTestSuite) TestUpdateUserEmailCmd() { s.client. EXPECT(). - GetUserByEmail(context.Background(), userArg, ""). + GetUserByEmail(context.TODO(), userArg, ""). Return(nil, &model.Response{StatusCode: http.StatusNotFound}, errors.New("no user found with the given email")). Times(1) s.client. EXPECT(). - GetUserByUsername(context.Background(), userArg, ""). + GetUserByUsername(context.TODO(), userArg, ""). Return(¤tUser, &model.Response{}, nil). Times(1) s.client. EXPECT(). - UpdateUser(context.Background(), ¤tUser). + UpdateUser(context.TODO(), ¤tUser). Return(&updatedUser, &model.Response{}, nil). Times(1) @@ -1620,13 +1620,13 @@ func (s *MmctlUnitTestSuite) TestUpdateUserEmailCmd() { s.client. EXPECT(). - GetUserByEmail(context.Background(), userArg, ""). + GetUserByEmail(context.TODO(), userArg, ""). Return(¤tUser, &model.Response{}, nil). Times(1) s.client. EXPECT(). - UpdateUser(context.Background(), ¤tUser). + UpdateUser(context.TODO(), ¤tUser). Return(&updatedUser, &model.Response{}, nil). Times(1) @@ -1649,25 +1649,25 @@ func (s *MmctlUnitTestSuite) TestUpdateUserEmailCmd() { s.client. EXPECT(). - GetUserByEmail(context.Background(), userArg, ""). + GetUserByEmail(context.TODO(), userArg, ""). Return(nil, &model.Response{StatusCode: http.StatusNotFound}, errors.New("no user found with the given email")). Times(1) s.client. EXPECT(). - GetUserByUsername(context.Background(), userArg, ""). + GetUserByUsername(context.TODO(), userArg, ""). Return(nil, &model.Response{StatusCode: http.StatusNotFound}, errors.New("no user found with the given username")). Times(1) s.client. EXPECT(). - GetUser(context.Background(), userArg, ""). + GetUser(context.TODO(), userArg, ""). Return(¤tUser, &model.Response{}, nil). Times(1) s.client. EXPECT(). - UpdateUser(context.Background(), ¤tUser). + UpdateUser(context.TODO(), ¤tUser). Return(&updatedUser, &model.Response{}, nil). Times(1) @@ -1685,13 +1685,13 @@ func (s *MmctlUnitTestSuite) TestResetUserMfaCmd() { s.client. EXPECT(). - GetUserByEmail(context.Background(), "userId", ""). + GetUserByEmail(context.TODO(), "userId", ""). Return(&model.User{Id: "userId"}, nil, nil). Times(1) s.client. EXPECT(). - UpdateUserMfa(context.Background(), "userId", "", false). + UpdateUserMfa(context.TODO(), "userId", "", false). Return(&model.Response{StatusCode: http.StatusOK}, nil). Times(1) @@ -1706,19 +1706,19 @@ func (s *MmctlUnitTestSuite) TestResetUserMfaCmd() { s.client. EXPECT(). - GetUserByEmail(context.Background(), "userId", ""). + GetUserByEmail(context.TODO(), "userId", ""). Return(nil, nil, nil). Times(1) s.client. EXPECT(). - GetUserByUsername(context.Background(), "userId", ""). + GetUserByUsername(context.TODO(), "userId", ""). Return(nil, nil, nil). Times(1) s.client. EXPECT(). - GetUser(context.Background(), "userId", ""). + GetUser(context.TODO(), "userId", ""). Return(nil, nil, nil). Times(1) @@ -1743,13 +1743,13 @@ func (s *MmctlUnitTestSuite) TestResetUserMfaCmd() { s.client. EXPECT(). - GetUserByEmail(context.Background(), "userId", ""). + GetUserByEmail(context.TODO(), "userId", ""). Return(&model.User{Id: "userId"}, nil, nil). Times(1) s.client. EXPECT(). - UpdateUserMfa(context.Background(), "userId", "", false). + UpdateUserMfa(context.TODO(), "userId", "", false). Return(&model.Response{StatusCode: http.StatusBadRequest}, mockError). Times(1) @@ -1774,25 +1774,25 @@ func (s *MmctlUnitTestSuite) TestResetUserMfaCmd() { if user == "notfounduser" { s.client. EXPECT(). - GetUserByEmail(context.Background(), user, ""). + GetUserByEmail(context.TODO(), user, ""). Return(nil, nil, nil). Times(1) s.client. EXPECT(). - GetUserByUsername(context.Background(), user, ""). + GetUserByUsername(context.TODO(), user, ""). Return(nil, nil, nil). Times(1) s.client. EXPECT(). - GetUser(context.Background(), user, ""). + GetUser(context.TODO(), user, ""). Return(nil, nil, nil). Times(1) } else { s.client. EXPECT(). - GetUserByEmail(context.Background(), user, ""). + GetUserByEmail(context.TODO(), user, ""). Return(&model.User{Id: user}, nil, nil). Times(1) } @@ -1802,13 +1802,13 @@ func (s *MmctlUnitTestSuite) TestResetUserMfaCmd() { if user == "error1" { s.client. EXPECT(). - UpdateUserMfa(context.Background(), user, "", false). + UpdateUserMfa(context.TODO(), user, "", false). Return(&model.Response{StatusCode: http.StatusBadRequest}, mockError). Times(1) } else if user != "notfounduser" { s.client. EXPECT(). - UpdateUserMfa(context.Background(), user, "", false). + UpdateUserMfa(context.TODO(), user, "", false). Return(&model.Response{StatusCode: http.StatusOK}, nil). Times(1) } @@ -1855,7 +1855,7 @@ func (s *MmctlUnitTestSuite) TestListUserCmdF() { s.client. EXPECT(). - GetUsers(context.Background(), page, perPage, ""). + GetUsers(context.TODO(), page, perPage, ""). Return([]*model.User{&mockUser}, &model.Response{}, nil). Times(1) @@ -1882,19 +1882,19 @@ func (s *MmctlUnitTestSuite) TestListUserCmdF() { s.client. EXPECT(). - GetUsers(context.Background(), 0, perPage, ""). + GetUsers(context.TODO(), 0, perPage, ""). Return([]*model.User{&mockUser1}, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetUsers(context.Background(), 1, perPage, ""). + GetUsers(context.TODO(), 1, perPage, ""). Return([]*model.User{&mockUser2}, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetUsers(context.Background(), 2, perPage, ""). + GetUsers(context.TODO(), 2, perPage, ""). Return([]*model.User{}, &model.Response{}, nil). Times(1) @@ -1917,7 +1917,7 @@ func (s *MmctlUnitTestSuite) TestListUserCmdF() { s.client. EXPECT(). - GetUsers(context.Background(), page, perPage, ""). + GetUsers(context.TODO(), page, perPage, ""). Return([]*model.User{}, &model.Response{}, nil). Times(1) @@ -1941,7 +1941,7 @@ func (s *MmctlUnitTestSuite) TestListUserCmdF() { s.client. EXPECT(). - GetUsers(context.Background(), page, perPage, ""). + GetUsers(context.TODO(), page, perPage, ""). Return(nil, &model.Response{}, mockError). Times(1) @@ -1965,7 +1965,7 @@ func (s *MmctlUnitTestSuite) TestListUserCmdF() { s.client. EXPECT(). - GetUsers(context.Background(), page, perPage, ""). + GetUsers(context.TODO(), page, perPage, ""). Return([]*model.User{&mockUser}, &model.Response{}, nil). Times(1) @@ -1993,13 +1993,13 @@ func (s *MmctlUnitTestSuite) TestListUserCmdF() { s.client. EXPECT(). - GetTeamByName(context.Background(), team, ""). + GetTeamByName(context.TODO(), team, ""). Return(&model.Team{Id: resultID}, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetUsersInTeam(context.Background(), resultID, page, perPage, ""). + GetUsersInTeam(context.TODO(), resultID, page, perPage, ""). Return([]*model.User{&mockUser}, &model.Response{}, nil). Times(1) @@ -2018,13 +2018,13 @@ func (s *MmctlUnitTestSuite) TestUserDeactivateCmd() { s.client. EXPECT(). - GetUserByEmail(context.Background(), emailArg, ""). + GetUserByEmail(context.TODO(), emailArg, ""). Return(&mockUser, &model.Response{}, nil). Times(1) s.client. EXPECT(). - UpdateUserActive(context.Background(), mockUser.Id, false). + UpdateUserActive(context.TODO(), mockUser.Id, false). Return(&model.Response{StatusCode: http.StatusOK}, nil). Times(1) @@ -2041,19 +2041,19 @@ func (s *MmctlUnitTestSuite) TestUserDeactivateCmd() { s.client. EXPECT(). - GetUserByEmail(context.Background(), usernameArg, ""). + GetUserByEmail(context.TODO(), usernameArg, ""). Return(nil, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetUserByUsername(context.Background(), usernameArg, ""). + GetUserByUsername(context.TODO(), usernameArg, ""). Return(&mockUser, &model.Response{}, nil). Times(1) s.client. EXPECT(). - UpdateUserActive(context.Background(), mockUser.Id, false). + UpdateUserActive(context.TODO(), mockUser.Id, false). Return(&model.Response{StatusCode: http.StatusOK}, nil). Times(1) @@ -2069,25 +2069,25 @@ func (s *MmctlUnitTestSuite) TestUserDeactivateCmd() { s.client. EXPECT(). - GetUserByEmail(context.Background(), mockUser.Id, ""). + GetUserByEmail(context.TODO(), mockUser.Id, ""). Return(nil, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetUserByUsername(context.Background(), mockUser.Id, ""). + GetUserByUsername(context.TODO(), mockUser.Id, ""). Return(nil, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetUser(context.Background(), mockUser.Id, ""). + GetUser(context.TODO(), mockUser.Id, ""). Return(&mockUser, &model.Response{}, nil). Times(1) s.client. EXPECT(). - UpdateUserActive(context.Background(), mockUser.Id, false). + UpdateUserActive(context.TODO(), mockUser.Id, false). Return(&model.Response{StatusCode: http.StatusOK}, nil). Times(1) @@ -2104,13 +2104,13 @@ func (s *MmctlUnitTestSuite) TestUserDeactivateCmd() { s.client. EXPECT(). - GetUserByEmail(context.Background(), arg, ""). + GetUserByEmail(context.TODO(), arg, ""). Return(&mockUser, &model.Response{}, nil). Times(1) s.client. EXPECT(). - UpdateUserActive(context.Background(), mockUser.Id, false). + UpdateUserActive(context.TODO(), mockUser.Id, false). Return(&model.Response{StatusCode: http.StatusOK}, nil). Times(1) @@ -2127,19 +2127,19 @@ func (s *MmctlUnitTestSuite) TestUserDeactivateCmd() { s.client. EXPECT(). - GetUserByEmail(context.Background(), arg, ""). + GetUserByEmail(context.TODO(), arg, ""). Return(nil, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetUserByUsername(context.Background(), arg, ""). + GetUserByUsername(context.TODO(), arg, ""). Return(nil, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetUser(context.Background(), arg, ""). + GetUser(context.TODO(), arg, ""). Return(nil, &model.Response{}, nil). Times(1) @@ -2162,7 +2162,7 @@ func (s *MmctlUnitTestSuite) TestUserDeactivateCmd() { for i := 0; i < len(argEmails); i++ { s.client. EXPECT(). - GetUserByEmail(context.Background(), argEmails[i], ""). + GetUserByEmail(context.TODO(), argEmails[i], ""). Return(&argUsers[i], &model.Response{}, nil). Times(1) } @@ -2170,7 +2170,7 @@ func (s *MmctlUnitTestSuite) TestUserDeactivateCmd() { for i := 0; i < len(argEmails); i++ { s.client. EXPECT(). - UpdateUserActive(context.Background(), argUsers[i].Id, false). + UpdateUserActive(context.TODO(), argUsers[i].Id, false). Return(&model.Response{StatusCode: http.StatusOK}, nil). Times(1) } @@ -2193,45 +2193,45 @@ func (s *MmctlUnitTestSuite) TestUserDeactivateCmd() { // mockUser1 s.client. EXPECT(). - GetUserByEmail(context.Background(), argsDelete[0], ""). + GetUserByEmail(context.TODO(), argsDelete[0], ""). Return(nil, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetUserByUsername(context.Background(), argsDelete[0], ""). + GetUserByUsername(context.TODO(), argsDelete[0], ""). Return(nil, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetUser(context.Background(), argsDelete[0], ""). + GetUser(context.TODO(), argsDelete[0], ""). Return(&argUsers[0], &model.Response{}, nil). Times(1) // mockUser2 s.client. EXPECT(). - GetUserByEmail(context.Background(), argsDelete[1], ""). + GetUserByEmail(context.TODO(), argsDelete[1], ""). Return(&argUsers[1], &model.Response{}, nil). Times(1) // mockUser3 s.client. EXPECT(). - GetUserByEmail(context.Background(), argsDelete[2], ""). + GetUserByEmail(context.TODO(), argsDelete[2], ""). Return(nil, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetUserByUsername(context.Background(), argsDelete[2], ""). + GetUserByUsername(context.TODO(), argsDelete[2], ""). Return(&argUsers[2], &model.Response{}, nil). Times(1) for _, user := range argUsers { s.client. EXPECT(). - UpdateUserActive(context.Background(), user.Id, false). + UpdateUserActive(context.TODO(), user.Id, false). Return(&model.Response{StatusCode: http.StatusOK}, nil). Times(1) } @@ -2250,32 +2250,32 @@ func (s *MmctlUnitTestSuite) TestUserDeactivateCmd() { // mockUser1 s.client. EXPECT(). - GetUserByEmail(context.Background(), mockUser1.Email, ""). + GetUserByEmail(context.TODO(), mockUser1.Email, ""). Return(&mockUser1, &model.Response{}, nil). Times(1) // nonexistent email s.client. EXPECT(). - GetUserByEmail(context.Background(), nonexistentEmail, ""). + GetUserByEmail(context.TODO(), nonexistentEmail, ""). Return(nil, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetUserByUsername(context.Background(), nonexistentEmail, ""). + GetUserByUsername(context.TODO(), nonexistentEmail, ""). Return(nil, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetUser(context.Background(), nonexistentEmail, ""). + GetUser(context.TODO(), nonexistentEmail, ""). Return(nil, &model.Response{}, nil). Times(1) s.client. EXPECT(). - UpdateUserActive(context.Background(), mockUser1.Id, false). + UpdateUserActive(context.TODO(), mockUser1.Id, false). Return(&model.Response{StatusCode: http.StatusOK}, nil). Times(1) @@ -2295,13 +2295,13 @@ func (s *MmctlUnitTestSuite) TestVerifyUserEmailWithoutTokenCmd() { s.client. EXPECT(). - GetUserByEmail(context.Background(), emailArg, ""). + GetUserByEmail(context.TODO(), emailArg, ""). Return(&mockUser, &model.Response{}, nil). Times(1) s.client. EXPECT(). - VerifyUserEmailWithoutToken(context.Background(), mockUser.Id). + VerifyUserEmailWithoutToken(context.TODO(), mockUser.Id). Return(&mockUser, &model.Response{}, nil). Times(1) @@ -2318,19 +2318,19 @@ func (s *MmctlUnitTestSuite) TestVerifyUserEmailWithoutTokenCmd() { s.client. EXPECT(). - GetUserByEmail(context.Background(), userArg, ""). + GetUserByEmail(context.TODO(), userArg, ""). Return(nil, &model.Response{StatusCode: http.StatusNotFound}, errors.New("")). Times(1) s.client. EXPECT(). - GetUserByUsername(context.Background(), userArg, ""). + GetUserByUsername(context.TODO(), userArg, ""). Return(nil, &model.Response{StatusCode: http.StatusNotFound}, errors.New("")). Times(1) s.client. EXPECT(). - GetUser(context.Background(), userArg, ""). + GetUser(context.TODO(), userArg, ""). Return(nil, &model.Response{StatusCode: http.StatusNotFound}, errors.New("")). Times(1) @@ -2356,13 +2356,13 @@ func (s *MmctlUnitTestSuite) TestVerifyUserEmailWithoutTokenCmd() { s.client. EXPECT(). - GetUserByEmail(context.Background(), emailArg, ""). + GetUserByEmail(context.TODO(), emailArg, ""). Return(&mockUser, &model.Response{}, nil). Times(1) s.client. EXPECT(). - VerifyUserEmailWithoutToken(context.Background(), mockUser.Id). + VerifyUserEmailWithoutToken(context.TODO(), mockUser.Id). Return(nil, &model.Response{}, errors.New("some-message")). Times(1) @@ -2391,13 +2391,13 @@ func (s *MmctlUnitTestSuite) TestUserConvertCmd() { s.client. EXPECT(). - GetUserByEmail(context.Background(), emailArg, ""). + GetUserByEmail(context.TODO(), emailArg, ""). Return(&mockUser, &model.Response{}, nil). Times(1) s.client. EXPECT(). - ConvertUserToBot(context.Background(), mockUser.Id). + ConvertUserToBot(context.TODO(), mockUser.Id). Return(&mockBot, &model.Response{}, nil). Times(1) @@ -2429,19 +2429,19 @@ func (s *MmctlUnitTestSuite) TestUserConvertCmd() { s.client. EXPECT(). - GetUserByEmail(context.Background(), userNameArg, ""). + GetUserByEmail(context.TODO(), userNameArg, ""). Return(nil, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetUserByUsername(context.Background(), userNameArg, ""). + GetUserByUsername(context.TODO(), userNameArg, ""). Return(&mockBotUser, &model.Response{}, nil). Times(1) s.client. EXPECT(). - ConvertBotToUser(context.Background(), mockBot.UserId, &userPatch, false). + ConvertBotToUser(context.TODO(), mockBot.UserId, &userPatch, false). Return(&mockUser, &model.Response{}, nil). Times(1) @@ -2473,13 +2473,13 @@ func (s *MmctlUnitTestSuite) TestUserConvertCmd() { s.client. EXPECT(). - GetUserByEmail(context.Background(), emailArg, ""). + GetUserByEmail(context.TODO(), emailArg, ""). Return(&mockUser, &model.Response{}, nil). Times(1) s.client. EXPECT(). - ConvertUserToBot(context.Background(), mockUser.Id). + ConvertUserToBot(context.TODO(), mockUser.Id). Return(nil, &model.Response{}, errors.New("some-message")). Times(1) @@ -2509,19 +2509,19 @@ func (s *MmctlUnitTestSuite) TestUserConvertCmd() { s.client. EXPECT(). - GetUserByEmail(context.Background(), userNameArg, ""). + GetUserByEmail(context.TODO(), userNameArg, ""). Return(nil, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetUserByUsername(context.Background(), userNameArg, ""). + GetUserByUsername(context.TODO(), userNameArg, ""). Return(&mockBotUser, &model.Response{}, nil). Times(1) s.client. EXPECT(). - ConvertBotToUser(context.Background(), mockBot.UserId, &userPatch, false). + ConvertBotToUser(context.TODO(), mockBot.UserId, &userPatch, false). Return(nil, &model.Response{}, errors.New("some-message")). Times(1) @@ -2544,7 +2544,7 @@ func (s *MmctlUnitTestSuite) TestMigrateAuthCmd() { s.client. EXPECT(). - MigrateAuthToLdap(context.Background(), fromAuth, matchField, false). + MigrateAuthToLdap(context.TODO(), fromAuth, matchField, false). Return(&model.Response{StatusCode: http.StatusOK}, nil). Times(1) @@ -2583,7 +2583,7 @@ func (s *MmctlUnitTestSuite) TestMigrateAuthCmd() { s.client. EXPECT(). - MigrateAuthToSaml(context.Background(), fromAuth, userData, false). + MigrateAuthToSaml(context.TODO(), fromAuth, userData, false). Return(&model.Response{StatusCode: http.StatusOK}, nil). Times(1) @@ -2605,7 +2605,7 @@ func (s *MmctlUnitTestSuite) TestMigrateAuthCmd() { s.client. EXPECT(). - MigrateAuthToSaml(context.Background(), fromAuth, map[string]string{}, true). + MigrateAuthToSaml(context.TODO(), fromAuth, map[string]string{}, true). Return(&model.Response{StatusCode: http.StatusOK}, nil). Times(1) @@ -2673,7 +2673,7 @@ func (s *MmctlUnitTestSuite) TestMigrateAuthCmd() { s.client. EXPECT(). - MigrateAuthToLdap(context.Background(), fromAuth, matchField, false). + MigrateAuthToLdap(context.TODO(), fromAuth, matchField, false). Return(&model.Response{StatusCode: http.StatusBadRequest}, errors.New("some-error")). Times(1) @@ -2694,7 +2694,7 @@ func (s *MmctlUnitTestSuite) TestMigrateAuthCmd() { s.client. EXPECT(). - MigrateAuthToSaml(context.Background(), fromAuth, map[string]string{}, true). + MigrateAuthToSaml(context.TODO(), fromAuth, map[string]string{}, true). Return(&model.Response{StatusCode: http.StatusBadRequest}, errors.New("some-error")). Times(1) @@ -2712,13 +2712,13 @@ func (s *MmctlUnitTestSuite) TestPromoteGuestToUserCmd() { s.client. EXPECT(). - GetUserByEmail(context.Background(), emailArg, ""). + GetUserByEmail(context.TODO(), emailArg, ""). Return(&mockUser, &model.Response{}, nil). Times(1) s.client. EXPECT(). - PromoteGuestToUser(context.Background(), mockUser.Id). + PromoteGuestToUser(context.TODO(), mockUser.Id). Return(&model.Response{StatusCode: http.StatusOK}, nil). Times(1) @@ -2736,13 +2736,13 @@ func (s *MmctlUnitTestSuite) TestPromoteGuestToUserCmd() { s.client. EXPECT(). - GetUserByEmail(context.Background(), emailArg, ""). + GetUserByEmail(context.TODO(), emailArg, ""). Return(&mockUser, &model.Response{}, nil). Times(1) s.client. EXPECT(). - PromoteGuestToUser(context.Background(), mockUser.Id). + PromoteGuestToUser(context.TODO(), mockUser.Id). Return(&model.Response{StatusCode: http.StatusBadRequest}, errors.New("some-error")). Times(1) @@ -2762,13 +2762,13 @@ func (s *MmctlUnitTestSuite) TestDemoteUserToGuestCmd() { s.client. EXPECT(). - GetUserByEmail(context.Background(), emailArg, ""). + GetUserByEmail(context.TODO(), emailArg, ""). Return(&mockUser, &model.Response{}, nil). Times(1) s.client. EXPECT(). - DemoteUserToGuest(context.Background(), mockUser.Id). + DemoteUserToGuest(context.TODO(), mockUser.Id). Return(&model.Response{StatusCode: http.StatusOK}, nil). Times(1) @@ -2786,13 +2786,13 @@ func (s *MmctlUnitTestSuite) TestDemoteUserToGuestCmd() { s.client. EXPECT(). - GetUserByEmail(context.Background(), emailArg, ""). + GetUserByEmail(context.TODO(), emailArg, ""). Return(&mockUser, &model.Response{}, nil). Times(1) s.client. EXPECT(). - DemoteUserToGuest(context.Background(), mockUser.Id). + DemoteUserToGuest(context.TODO(), mockUser.Id). Return(&model.Response{StatusCode: http.StatusBadRequest}, errors.New("some-error")). Times(1) diff --git a/server/cmd/mmctl/commands/userargs_test.go b/server/cmd/mmctl/commands/userargs_test.go index ae2dd49ee3..d732564e21 100644 --- a/server/cmd/mmctl/commands/userargs_test.go +++ b/server/cmd/mmctl/commands/userargs_test.go @@ -20,17 +20,17 @@ func (s *MmctlUnitTestSuite) TestGetUserFromArgs() { printer.Clean() s.client. EXPECT(). - GetUserByEmail(context.Background(), notFoundEmail, ""). + GetUserByEmail(context.TODO(), notFoundEmail, ""). Return(nil, &model.Response{StatusCode: http.StatusNotFound}, notFoundErr). Times(1) s.client. EXPECT(). - GetUserByUsername(context.Background(), notFoundEmail, ""). + GetUserByUsername(context.TODO(), notFoundEmail, ""). Return(nil, &model.Response{StatusCode: http.StatusNotFound}, notFoundErr). Times(1) s.client. EXPECT(). - GetUser(context.Background(), notFoundEmail, ""). + GetUser(context.TODO(), notFoundEmail, ""). Return(nil, &model.Response{StatusCode: http.StatusNotFound}, notFoundErr). Times(1) @@ -46,17 +46,17 @@ func (s *MmctlUnitTestSuite) TestGetUserFromArgs() { printer.Clean() s.client. EXPECT(). - GetUserByEmail(context.Background(), badRequestEmail, ""). + GetUserByEmail(context.TODO(), badRequestEmail, ""). Return(nil, &model.Response{StatusCode: http.StatusBadRequest}, badRequestErr). Times(1) s.client. EXPECT(). - GetUserByUsername(context.Background(), badRequestEmail, ""). + GetUserByUsername(context.TODO(), badRequestEmail, ""). Return(nil, &model.Response{StatusCode: http.StatusBadRequest}, badRequestErr). Times(1) s.client. EXPECT(). - GetUser(context.Background(), badRequestEmail, ""). + GetUser(context.TODO(), badRequestEmail, ""). Return(nil, &model.Response{StatusCode: http.StatusBadRequest}, badRequestErr). Times(1) @@ -72,7 +72,7 @@ func (s *MmctlUnitTestSuite) TestGetUserFromArgs() { printer.Clean() s.client. EXPECT(). - GetUserByEmail(context.Background(), unexpectedErrEmail, ""). + GetUserByEmail(context.TODO(), unexpectedErrEmail, ""). Return(nil, &model.Response{StatusCode: http.StatusInternalServerError}, unexpectedErr). Times(1) users, err := getUsersFromArgs(s.client, []string{unexpectedErrEmail}) @@ -86,7 +86,7 @@ func (s *MmctlUnitTestSuite) TestGetUserFromArgs() { printer.Clean() s.client. EXPECT(). - GetUserByEmail(context.Background(), forbiddenErrEmail, ""). + GetUserByEmail(context.TODO(), forbiddenErrEmail, ""). Return(nil, &model.Response{StatusCode: http.StatusForbidden}, forbiddenErr). Times(1) users, err := getUsersFromArgs(s.client, []string{forbiddenErrEmail}) @@ -100,7 +100,7 @@ func (s *MmctlUnitTestSuite) TestGetUserFromArgs() { printer.Clean() s.client. EXPECT(). - GetUserByEmail(context.Background(), successEmail, ""). + GetUserByEmail(context.TODO(), successEmail, ""). Return(successUser, nil, nil). Times(1) users, err := getUsersFromArgs(s.client, []string{successEmail}) diff --git a/server/cmd/mmctl/commands/webhook_test.go b/server/cmd/mmctl/commands/webhook_test.go index ba59d8a3b1..06a4b16ce6 100644 --- a/server/cmd/mmctl/commands/webhook_test.go +++ b/server/cmd/mmctl/commands/webhook_test.go @@ -40,19 +40,19 @@ func (s *MmctlUnitTestSuite) TestListWebhookCmd() { s.client. EXPECT(). - GetAllTeams(context.Background(), "", 0, 100000000). + GetAllTeams(context.TODO(), "", 0, 100000000). Return([]*model.Team{&mockTeam}, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetIncomingWebhooksForTeam(context.Background(), teamID, 0, 100000000, ""). + GetIncomingWebhooksForTeam(context.TODO(), teamID, 0, 100000000, ""). Return([]*model.IncomingWebhook{&mockIncomingWebhook}, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetOutgoingWebhooksForTeam(context.Background(), teamID, 0, 100000000, ""). + GetOutgoingWebhooksForTeam(context.TODO(), teamID, 0, 100000000, ""). Return([]*model.OutgoingWebhook{&mockOutgoingWebhook}, &model.Response{}, nil). Times(1) @@ -80,19 +80,19 @@ func (s *MmctlUnitTestSuite) TestListWebhookCmd() { } s.client. EXPECT(). - GetTeam(context.Background(), teamID, ""). + GetTeam(context.TODO(), teamID, ""). Return(&mockTeam, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetIncomingWebhooksForTeam(context.Background(), teamID, 0, 100000000, ""). + GetIncomingWebhooksForTeam(context.TODO(), teamID, 0, 100000000, ""). Return([]*model.IncomingWebhook{&mockIncomingWebhook}, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetOutgoingWebhooksForTeam(context.Background(), teamID, 0, 100000000, ""). + GetOutgoingWebhooksForTeam(context.TODO(), teamID, 0, 100000000, ""). Return([]*model.OutgoingWebhook{&mockOutgoingWebhook}, &model.Response{}, nil). Times(1) @@ -114,19 +114,19 @@ func (s *MmctlUnitTestSuite) TestListWebhookCmd() { s.client. EXPECT(). - GetAllTeams(context.Background(), "", 0, 100000000). + GetAllTeams(context.TODO(), "", 0, 100000000). Return([]*model.Team{&mockTeam}, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetIncomingWebhooksForTeam(context.Background(), teamID, 0, 100000000, ""). + GetIncomingWebhooksForTeam(context.TODO(), teamID, 0, 100000000, ""). Return(nil, &model.Response{}, mockError). Times(1) s.client. EXPECT(). - GetOutgoingWebhooksForTeam(context.Background(), teamID, 0, 100000000, ""). + GetOutgoingWebhooksForTeam(context.TODO(), teamID, 0, 100000000, ""). Return(nil, &model.Response{}, mockError). Times(1) @@ -174,19 +174,19 @@ func (s *MmctlUnitTestSuite) TestCreateIncomingWebhookCmd() { s.client. EXPECT(). - GetChannel(context.Background(), channelID, ""). + GetChannel(context.TODO(), channelID, ""). Return(&mockChannel, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetUserByEmail(context.Background(), emailID, ""). + GetUserByEmail(context.TODO(), emailID, ""). Return(&mockUser, &model.Response{}, nil). Times(1) s.client. EXPECT(). - CreateIncomingWebhook(context.Background(), &mockIncomingWebhook). + CreateIncomingWebhook(context.TODO(), &mockIncomingWebhook). Return(&returnedIncomingWebhook, &model.Response{}, nil). Times(1) @@ -218,19 +218,19 @@ func (s *MmctlUnitTestSuite) TestCreateIncomingWebhookCmd() { s.client. EXPECT(). - GetChannel(context.Background(), channelID, ""). + GetChannel(context.TODO(), channelID, ""). Return(&mockChannel, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetUserByEmail(context.Background(), emailID, ""). + GetUserByEmail(context.TODO(), emailID, ""). Return(&mockUser, &model.Response{}, nil). Times(1) s.client. EXPECT(). - CreateIncomingWebhook(context.Background(), &mockIncomingWebhook). + CreateIncomingWebhook(context.TODO(), &mockIncomingWebhook). Return(nil, &model.Response{}, mockError). Times(1) @@ -269,13 +269,13 @@ func (s *MmctlUnitTestSuite) TestModifyIncomingWebhookCmd() { s.client. EXPECT(). - GetIncomingWebhook(context.Background(), incomingWebhookID, ""). + GetIncomingWebhook(context.TODO(), incomingWebhookID, ""). Return(&mockIncomingWebhook, &model.Response{}, nil). Times(1) s.client. EXPECT(). - UpdateIncomingWebhook(context.Background(), &mockIncomingWebhook). + UpdateIncomingWebhook(context.TODO(), &mockIncomingWebhook). Return(&updatedIncomingWebhook, &model.Response{}, nil). Times(1) @@ -307,13 +307,13 @@ func (s *MmctlUnitTestSuite) TestModifyIncomingWebhookCmd() { s.client. EXPECT(). - GetIncomingWebhook(context.Background(), incomingWebhookID, ""). + GetIncomingWebhook(context.TODO(), incomingWebhookID, ""). Return(&mockIncomingWebhook, &model.Response{}, nil). Times(1) s.client. EXPECT(). - UpdateIncomingWebhook(context.Background(), &mockIncomingWebhook). + UpdateIncomingWebhook(context.TODO(), &mockIncomingWebhook). Return(nil, &model.Response{}, mockError). Times(1) @@ -363,19 +363,19 @@ func (s *MmctlUnitTestSuite) TestCreateOutgoingWebhookCmd() { s.client. EXPECT(). - GetTeam(context.Background(), teamID, ""). + GetTeam(context.TODO(), teamID, ""). Return(&mockTeam, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetUserByEmail(context.Background(), emailID, ""). + GetUserByEmail(context.TODO(), emailID, ""). Return(&mockUser, &model.Response{}, nil). Times(1) s.client. EXPECT(). - CreateOutgoingWebhook(context.Background(), &mockOutgoingWebhook). + CreateOutgoingWebhook(context.TODO(), &mockOutgoingWebhook). Return(&createdOutgoingWebhook, &model.Response{}, nil). Times(1) @@ -409,19 +409,19 @@ func (s *MmctlUnitTestSuite) TestCreateOutgoingWebhookCmd() { s.client. EXPECT(). - GetTeam(context.Background(), teamID, ""). + GetTeam(context.TODO(), teamID, ""). Return(&mockTeam, &model.Response{}, nil). Times(1) s.client. EXPECT(). - GetUserByEmail(context.Background(), emailID, ""). + GetUserByEmail(context.TODO(), emailID, ""). Return(&mockUser, &model.Response{}, nil). Times(1) s.client. EXPECT(). - CreateOutgoingWebhook(context.Background(), &mockOutgoingWebhook). + CreateOutgoingWebhook(context.TODO(), &mockOutgoingWebhook). Return(nil, &model.Response{}, mockError). Times(1) @@ -456,13 +456,13 @@ func (s *MmctlUnitTestSuite) TestModifyOutgoingWebhookCmd() { s.client. EXPECT(). - GetOutgoingWebhook(context.Background(), outgoingWebhookID). + GetOutgoingWebhook(context.TODO(), outgoingWebhookID). Return(&mockOutgoingWebhook, &model.Response{}, nil). Times(1) s.client. EXPECT(). - UpdateOutgoingWebhook(context.Background(), &mockOutgoingWebhook). + UpdateOutgoingWebhook(context.TODO(), &mockOutgoingWebhook). Return(&updatedOutgoingWebhook, &model.Response{}, nil). Times(1) @@ -491,13 +491,13 @@ func (s *MmctlUnitTestSuite) TestModifyOutgoingWebhookCmd() { s.client. EXPECT(). - GetOutgoingWebhook(context.Background(), outgoingWebhookID). + GetOutgoingWebhook(context.TODO(), outgoingWebhookID). Return(&mockOutgoingWebhook, &model.Response{}, nil). Times(1) s.client. EXPECT(). - UpdateOutgoingWebhook(context.Background(), &mockOutgoingWebhook). + UpdateOutgoingWebhook(context.TODO(), &mockOutgoingWebhook). Return(nil, &model.Response{}, mockError). Times(1) @@ -520,13 +520,13 @@ func (s *MmctlUnitTestSuite) TestDeleteWebhookCmd() { s.client. EXPECT(). - GetIncomingWebhook(context.Background(), incomingWebhookID, ""). + GetIncomingWebhook(context.TODO(), incomingWebhookID, ""). Return(&mockIncomingWebhook, &model.Response{}, nil). Times(1) s.client. EXPECT(). - DeleteIncomingWebhook(context.Background(), incomingWebhookID). + DeleteIncomingWebhook(context.TODO(), incomingWebhookID). Return(&model.Response{StatusCode: http.StatusOK}, nil). Times(1) @@ -545,19 +545,19 @@ func (s *MmctlUnitTestSuite) TestDeleteWebhookCmd() { s.client. EXPECT(). - GetIncomingWebhook(context.Background(), outgoingWebhookID, ""). + GetIncomingWebhook(context.TODO(), outgoingWebhookID, ""). Return(nil, &model.Response{}, mockError). Times(1) s.client. EXPECT(). - GetOutgoingWebhook(context.Background(), outgoingWebhookID). + GetOutgoingWebhook(context.TODO(), outgoingWebhookID). Return(&mockOutgoingWebhook, &model.Response{}, nil). Times(1) s.client. EXPECT(). - DeleteOutgoingWebhook(context.Background(), outgoingWebhookID). + DeleteOutgoingWebhook(context.TODO(), outgoingWebhookID). Return(&model.Response{StatusCode: http.StatusOK}, nil). Times(1) @@ -576,13 +576,13 @@ func (s *MmctlUnitTestSuite) TestDeleteWebhookCmd() { s.client. EXPECT(). - GetIncomingWebhook(context.Background(), incomingWebhookID, ""). + GetIncomingWebhook(context.TODO(), incomingWebhookID, ""). Return(&mockIncomingWebhook, &model.Response{}, nil). Times(1) s.client. EXPECT(). - DeleteIncomingWebhook(context.Background(), incomingWebhookID). + DeleteIncomingWebhook(context.TODO(), incomingWebhookID). Return(&model.Response{StatusCode: http.StatusBadRequest}, mockError). Times(1) @@ -601,19 +601,19 @@ func (s *MmctlUnitTestSuite) TestDeleteWebhookCmd() { s.client. EXPECT(). - GetIncomingWebhook(context.Background(), outgoingWebhookID, ""). + GetIncomingWebhook(context.TODO(), outgoingWebhookID, ""). Return(nil, &model.Response{}, mockError). Times(1) s.client. EXPECT(). - GetOutgoingWebhook(context.Background(), outgoingWebhookID). + GetOutgoingWebhook(context.TODO(), outgoingWebhookID). Return(&mockOutgoingWebhook, &model.Response{}, nil). Times(1) s.client. EXPECT(). - DeleteOutgoingWebhook(context.Background(), outgoingWebhookID). + DeleteOutgoingWebhook(context.TODO(), outgoingWebhookID). Return(&model.Response{StatusCode: http.StatusBadRequest}, mockError). Times(1) @@ -637,7 +637,7 @@ func (s *MmctlUnitTestSuite) TestShowWebhookCmd() { s.client. EXPECT(). - GetIncomingWebhook(context.Background(), incomingWebhookID, ""). + GetIncomingWebhook(context.TODO(), incomingWebhookID, ""). Return(&mockIncomingWebhook, &model.Response{}, nil). Times(1) @@ -656,13 +656,13 @@ func (s *MmctlUnitTestSuite) TestShowWebhookCmd() { s.client. EXPECT(). - GetIncomingWebhook(context.Background(), outgoingWebhookID, ""). + GetIncomingWebhook(context.TODO(), outgoingWebhookID, ""). Return(nil, &model.Response{}, mockError). Times(1) s.client. EXPECT(). - GetOutgoingWebhook(context.Background(), outgoingWebhookID). + GetOutgoingWebhook(context.TODO(), outgoingWebhookID). Return(&mockOutgoingWebhook, &model.Response{}, nil). Times(1) @@ -680,13 +680,13 @@ func (s *MmctlUnitTestSuite) TestShowWebhookCmd() { s.client. EXPECT(). - GetIncomingWebhook(context.Background(), nonExistentID, ""). + GetIncomingWebhook(context.TODO(), nonExistentID, ""). Return(nil, &model.Response{}, mockError). Times(1) s.client. EXPECT(). - GetOutgoingWebhook(context.Background(), nonExistentID). + GetOutgoingWebhook(context.TODO(), nonExistentID). Return(nil, &model.Response{}, mockError). Times(1) diff --git a/server/go.mod b/server/go.mod index a8225f5f13..b286c1a46c 100644 --- a/server/go.mod +++ b/server/go.mod @@ -1,6 +1,8 @@ module github.com/mattermost/mattermost/server/v8 -go 1.20 +go 1.21 + +toolchain go1.21.8 require ( code.sajari.com/docconv/v2 v2.0.0-pre.4 diff --git a/server/public/go.mod b/server/public/go.mod index 64e51c6765..b5d14ebaa5 100644 --- a/server/public/go.mod +++ b/server/public/go.mod @@ -1,6 +1,8 @@ module github.com/mattermost/mattermost/server/public -go 1.20 +go 1.21 + +toolchain go1.21.8 require ( github.com/blang/semver/v4 v4.0.0 diff --git a/server/public/go.sum b/server/public/go.sum index 0e0b52a574..edaae5de72 100644 --- a/server/public/go.sum +++ b/server/public/go.sum @@ -9,6 +9,7 @@ dmitri.shuralyov.com/state v0.0.0-20180228185332-28bcc343414c/go.mod h1:0PRwlb0D git.apache.org/thrift.git v0.0.0-20180902110319-2566ecd5d999/go.mod h1:fPE2ZNJGynbRyZ4dJvy6G277gSllfV2HJqblrnkyeyg= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/toml v1.3.2 h1:o7IhLm0Msx3BaB+n3Ag7L8EVlByGnpq14C4YWiu/gL8= +github.com/BurntSushi/toml v1.3.2/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/blang/semver/v4 v4.0.0 h1:1PFHFE6yCCTv8C1TeyNNarDzntLi7wMI5i/pzqYIsAM= @@ -17,6 +18,7 @@ github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869 h1:DDGfHa7BWjL4Yn github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869/go.mod h1:Ekp36dRnpXw/yCqJaO+ZrUyxD+3VXMFFr56k5XYrpB4= github.com/bradfitz/go-smtpd v0.0.0-20170404230938-deb6d6237625/go.mod h1:HYsPBTaaSFSlLx/70C2HPIMNZpVV8+vt/A+FMnYP11g= github.com/bufbuild/protocompile v0.4.0 h1:LbFKd2XowZvQ/kajzguUp2DC9UEIQhIq77fZZlaQsNA= +github.com/bufbuild/protocompile v0.4.0/go.mod h1:3v93+mbWn/v3xzN+31nwkJfrEpAUwp+BagBSZWx+TP8= github.com/buger/jsonparser v0.0.0-20181115193947-bf1c66bbce23/go.mod h1:bbYlZJ7hK1yFx9hf58LP0zeX7UjIGs20ufpu3evjr+s= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/coreos/go-systemd v0.0.0-20181012123002-c6f51f82210d/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= @@ -58,6 +60,7 @@ github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Z github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-github v17.0.0+incompatible/go.mod h1:zLgOLi98H3fifZn+44m+umXrS52loVEgC2AApnigrVQ= github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= @@ -82,6 +85,7 @@ github.com/hashicorp/yamux v0.1.1 h1:yrQxtgseBDrq9Y652vSRDvsKCJKOUD+GzTS4Y0Y8pvE github.com/hashicorp/yamux v0.1.1/go.mod h1:CtWFDAQgb7dxtzFs4tWbplKIe2jSi3+5vKbgIO0SLnQ= github.com/jellevandenhooff/dkim v0.0.0-20150330215556-f50fe3d243e1/go.mod h1:E0B/fFc00Y+Rasa88328GlI/XbtyysCtTHZS8h7IrBU= github.com/jhump/protoreflect v1.15.1 h1:HUMERORf3I3ZdX05WaQ6MIpd/NJ434hTp5YiKgfCL6c= +github.com/jhump/protoreflect v1.15.1/go.mod h1:jD/2GMKKE6OqX8qTjhADU1e6DShO+gavG9e0Q693nKo= github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= @@ -265,6 +269,7 @@ golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ= +golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181029174526-d69651ed3497/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=