[MM-49989] Pass a context.Context to Client4 methods (#22922)

* Migrate all method in model/client4.go to accept a context.Context

* Fix th.*Client

* Fix remaining issues

* Empty commit to triger CI

* Fix test

* Add cancellation test

* Test that returned error is context.Canceled

* Fix bad merge

* Update mmctl code

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
Этот коммит содержится в:
Ben Schumacher
2023-06-06 23:29:29 +02:00
коммит произвёл GitHub
родитель 7116e9267a
Коммит 6c82605df0
140 изменённых файлов: 7516 добавлений и 7333 удалений

Просмотреть файл

@@ -4,6 +4,7 @@
package commands
import (
"context"
"net/http"
"github.com/mattermost/mattermost-server/server/public/model"
@@ -21,7 +22,7 @@ func (s *MmctlUnitTestSuite) TestLdapSyncCmd() {
s.client.
EXPECT().
SyncLdap(false).
SyncLdap(context.Background(), false).
Return(&model.Response{StatusCode: http.StatusOK}, nil).
Times(1)
@@ -38,7 +39,7 @@ func (s *MmctlUnitTestSuite) TestLdapSyncCmd() {
s.client.
EXPECT().
SyncLdap(false).
SyncLdap(context.Background(), false).
Return(&model.Response{StatusCode: http.StatusBadRequest}, nil).
Times(1)
@@ -55,7 +56,7 @@ func (s *MmctlUnitTestSuite) TestLdapSyncCmd() {
s.client.
EXPECT().
SyncLdap(false).
SyncLdap(context.Background(), false).
Return(&model.Response{StatusCode: http.StatusBadRequest}, mockError).
Times(1)
@@ -73,7 +74,7 @@ func (s *MmctlUnitTestSuite) TestLdapSyncCmd() {
s.client.
EXPECT().
SyncLdap(true).
SyncLdap(context.Background(), true).
Return(&model.Response{StatusCode: http.StatusOK}, nil).
Times(1)
@@ -88,7 +89,7 @@ func (s *MmctlUnitTestSuite) TestLdapMigrateID() {
s.client.
EXPECT().
MigrateIdLdap("test-id").
MigrateIdLdap(context.Background(), "test-id").
Return(&model.Response{StatusCode: http.StatusOK}, nil).
Times(1)
@@ -104,7 +105,7 @@ func (s *MmctlUnitTestSuite) TestLdapMigrateID() {
s.client.
EXPECT().
MigrateIdLdap("test-id").
MigrateIdLdap(context.Background(), "test-id").
Return(&model.Response{StatusCode: http.StatusBadRequest}, errors.New("test-error")).
Times(1)