[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>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
7116e9267a
Коммит
6c82605df0
@@ -4,6 +4,7 @@
|
||||
package commands
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"time"
|
||||
@@ -23,7 +24,7 @@ func (s *MmctlUnitTestSuite) TestGetBusyCmd() {
|
||||
|
||||
s.client.
|
||||
EXPECT().
|
||||
GetServerBusy().
|
||||
GetServerBusy(context.Background()).
|
||||
Return(sbs, &model.Response{}, nil).
|
||||
Times(1)
|
||||
|
||||
@@ -42,7 +43,7 @@ func (s *MmctlUnitTestSuite) TestGetBusyCmd() {
|
||||
|
||||
s.client.
|
||||
EXPECT().
|
||||
GetServerBusy().
|
||||
GetServerBusy(context.Background()).
|
||||
Return(sbs, &model.Response{}, nil).
|
||||
Times(1)
|
||||
|
||||
@@ -57,7 +58,7 @@ func (s *MmctlUnitTestSuite) TestGetBusyCmd() {
|
||||
printer.Clean()
|
||||
s.client.
|
||||
EXPECT().
|
||||
GetServerBusy().
|
||||
GetServerBusy(context.Background()).
|
||||
Return(nil, &model.Response{}, errors.New("mock error")).
|
||||
Times(1)
|
||||
|
||||
@@ -78,7 +79,7 @@ func (s *MmctlUnitTestSuite) TestSetBusyCmd() {
|
||||
|
||||
s.client.
|
||||
EXPECT().
|
||||
SetServerBusy(minutes*60).
|
||||
SetServerBusy(context.Background(), minutes*60).
|
||||
Return(&model.Response{StatusCode: http.StatusOK}, nil).
|
||||
Times(1)
|
||||
|
||||
@@ -116,7 +117,7 @@ func (s *MmctlUnitTestSuite) TestClearBusyCmd() {
|
||||
printer.Clean()
|
||||
s.client.
|
||||
EXPECT().
|
||||
ClearServerBusy().
|
||||
ClearServerBusy(context.Background()).
|
||||
Return(&model.Response{StatusCode: http.StatusOK}, nil).
|
||||
Times(1)
|
||||
|
||||
@@ -131,7 +132,7 @@ func (s *MmctlUnitTestSuite) TestClearBusyCmd() {
|
||||
printer.Clean()
|
||||
s.client.
|
||||
EXPECT().
|
||||
ClearServerBusy().
|
||||
ClearServerBusy(context.Background()).
|
||||
Return(&model.Response{StatusCode: http.StatusBadRequest}, errors.New("mock error")).
|
||||
Times(1)
|
||||
|
||||
@@ -149,7 +150,7 @@ func (s *MmctlUnitTestSuite) TestServerVersionCmd() {
|
||||
expectedVersion := "1.23.4.dev"
|
||||
s.client.
|
||||
EXPECT().
|
||||
GetPing().
|
||||
GetPing(context.Background()).
|
||||
Return("", &model.Response{ServerVersion: expectedVersion}, nil).
|
||||
Times(1)
|
||||
|
||||
@@ -165,7 +166,7 @@ func (s *MmctlUnitTestSuite) TestServerVersionCmd() {
|
||||
|
||||
s.client.
|
||||
EXPECT().
|
||||
GetPing().
|
||||
GetPing(context.Background()).
|
||||
Return("", &model.Response{}, errors.New("mock error")).
|
||||
Times(1)
|
||||
|
||||
@@ -183,7 +184,7 @@ func (s *MmctlUnitTestSuite) TestServerStatusCmd() {
|
||||
expectedStatus := map[string]string{"status": "OK"}
|
||||
s.client.
|
||||
EXPECT().
|
||||
GetPingWithFullServerStatus().
|
||||
GetPingWithFullServerStatus(context.Background()).
|
||||
Return(expectedStatus, &model.Response{}, nil).
|
||||
Times(1)
|
||||
|
||||
@@ -199,7 +200,7 @@ func (s *MmctlUnitTestSuite) TestServerStatusCmd() {
|
||||
|
||||
s.client.
|
||||
EXPECT().
|
||||
GetPingWithFullServerStatus().
|
||||
GetPingWithFullServerStatus(context.Background()).
|
||||
Return(nil, &model.Response{}, errors.New("mock error")).
|
||||
Times(1)
|
||||
|
||||
|
||||
Ссылка в новой задаче
Block a user