[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"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"os"
|
||||
@@ -25,7 +26,7 @@ func (s *MmctlUnitTestSuite) TestRemoveLicenseCmd() {
|
||||
|
||||
s.client.
|
||||
EXPECT().
|
||||
RemoveLicenseFile().
|
||||
RemoveLicenseFile(context.Background()).
|
||||
Return(&model.Response{StatusCode: http.StatusBadRequest}, nil).
|
||||
Times(1)
|
||||
|
||||
@@ -42,7 +43,7 @@ func (s *MmctlUnitTestSuite) TestRemoveLicenseCmd() {
|
||||
|
||||
s.client.
|
||||
EXPECT().
|
||||
RemoveLicenseFile().
|
||||
RemoveLicenseFile(context.Background()).
|
||||
Return(&model.Response{StatusCode: http.StatusBadRequest}, mockErr).
|
||||
Times(1)
|
||||
|
||||
@@ -72,7 +73,7 @@ func (s *MmctlUnitTestSuite) TestUploadLicenseCmdF() {
|
||||
printer.Clean()
|
||||
s.client.
|
||||
EXPECT().
|
||||
UploadLicenseFile(mockLicenseFile).
|
||||
UploadLicenseFile(context.Background(), mockLicenseFile).
|
||||
Return(&model.Response{StatusCode: http.StatusOK}, nil).
|
||||
Times(1)
|
||||
|
||||
@@ -86,7 +87,7 @@ func (s *MmctlUnitTestSuite) TestUploadLicenseCmdF() {
|
||||
errMsg := "open " + path + ": no such file or directory"
|
||||
s.client.
|
||||
EXPECT().
|
||||
UploadLicenseFile(mockLicenseFile).
|
||||
UploadLicenseFile(context.Background(), mockLicenseFile).
|
||||
Times(0)
|
||||
|
||||
err := uploadLicenseCmdF(s.client, &cobra.Command{}, []string{path})
|
||||
@@ -110,7 +111,7 @@ func (s *MmctlUnitTestSuite) TestUploadLicenseStringCmdF() {
|
||||
printer.Clean()
|
||||
s.client.
|
||||
EXPECT().
|
||||
UploadLicenseFile(mockLicenseFile).
|
||||
UploadLicenseFile(context.Background(), mockLicenseFile).
|
||||
Return(&model.Response{StatusCode: http.StatusOK}, nil).
|
||||
Times(1)
|
||||
|
||||
|
||||
Ссылка в новой задаче
Block a user