[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 manualtesting
import (
"context"
"errors"
"hash/fnv"
"math/rand"
@@ -107,7 +108,7 @@ func manualTest(c *web.Context, w http.ResponseWriter, r *http.Request) {
Nickname: username[0],
Password: slashcommands.UserPassword}
user, _, err = client.CreateUser(user)
user, _, err = client.CreateUser(context.Background(), user)
if err != nil {
var appErr *model.AppError
ok = errors.As(err, &appErr)
@@ -126,7 +127,7 @@ func manualTest(c *web.Context, w http.ResponseWriter, r *http.Request) {
userID = user.Id
// Login as user to generate auth token
_, _, err = client.LoginById(user.Id, slashcommands.UserPassword)
_, _, err = client.LoginById(context.Background(), user.Id, slashcommands.UserPassword)
if err != nil {
var appErr *model.AppError
ok = errors.As(err, &appErr)

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

@@ -4,6 +4,7 @@
package manualtesting
import (
"context"
"errors"
"net/http"
@@ -32,7 +33,7 @@ func testAutoLink(env TestEnvironment) *model.AppError {
post := &model.Post{
ChannelId: channelID,
Message: linkPostText}
_, _, err := env.Client.CreatePost(post)
_, _, err := env.Client.CreatePost(context.Background(), post)
var appErr *model.AppError
if ok = errors.As(err, &appErr); !ok {