[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 slashcommands
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"io"
|
||||
"net/http"
|
||||
@@ -248,7 +249,7 @@ func (*LoadTestProvider) SetupCommand(a *app.App, c request.CTX, args *model.Com
|
||||
if err := CreateBasicUser(a, client); err != nil {
|
||||
return &model.CommandResponse{Text: "Failed to create testing environment", ResponseType: model.CommandResponseTypeEphemeral}, err
|
||||
}
|
||||
_, _, err := client.Login(BTestUserEmail, BTestUserPassword)
|
||||
_, _, err := client.Login(context.Background(), BTestUserEmail, BTestUserPassword)
|
||||
if err != nil {
|
||||
return &model.CommandResponse{Text: "Failed to create testing environment", ResponseType: model.CommandResponseTypeEphemeral}, err
|
||||
}
|
||||
@@ -604,7 +605,7 @@ func (*LoadTestProvider) PostCommand(a *app.App, c request.CTX, args *model.Comm
|
||||
}
|
||||
|
||||
client := model.NewAPIv4Client(args.SiteURL)
|
||||
_, _, nErr := client.LoginById(user.Id, passwd)
|
||||
_, _, nErr := client.LoginById(context.Background(), user.Id, passwd)
|
||||
if nErr != nil {
|
||||
return &model.CommandResponse{Text: "Failed to login a user", ResponseType: model.CommandResponseTypeEphemeral}, nErr
|
||||
}
|
||||
@@ -613,7 +614,7 @@ func (*LoadTestProvider) PostCommand(a *app.App, c request.CTX, args *model.Comm
|
||||
ChannelId: channel.Id,
|
||||
Message: textMessage,
|
||||
}
|
||||
_, _, nErr = client.CreatePost(post)
|
||||
_, _, nErr = client.CreatePost(context.Background(), post)
|
||||
if nErr != nil {
|
||||
return &model.CommandResponse{Text: "Failed to create a post", ResponseType: model.CommandResponseTypeEphemeral}, nErr
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user