[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 api4
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
@@ -60,7 +61,7 @@ func TestAPIRestrictedViewMembers(t *testing.T) {
|
||||
th.App.SetStatusOnline(user4.Id, true)
|
||||
th.App.SetStatusOnline(user5.Id, true)
|
||||
|
||||
_, _, err := th.Client.Login(user1.Username, "test-password-1")
|
||||
_, _, err := th.Client.Login(context.Background(), user1.Username, "test-password-1")
|
||||
require.NoError(t, err)
|
||||
|
||||
t.Run("getUser", func(t *testing.T) {
|
||||
@@ -134,7 +135,7 @@ func TestAPIRestrictedViewMembers(t *testing.T) {
|
||||
th.AddPermissionToRole(model.PermissionViewMembers.Id, model.SystemUserRoleId)
|
||||
}
|
||||
|
||||
_, _, err := th.Client.GetUser(tc.UserId, "")
|
||||
_, _, err := th.Client.GetUser(context.Background(), tc.UserId, "")
|
||||
if tc.ExpectedError != "" {
|
||||
CheckErrorID(t, err, tc.ExpectedError)
|
||||
} else {
|
||||
@@ -215,7 +216,7 @@ func TestAPIRestrictedViewMembers(t *testing.T) {
|
||||
th.AddPermissionToRole(model.PermissionViewMembers.Id, model.SystemUserRoleId)
|
||||
}
|
||||
|
||||
_, _, err := th.Client.GetUserByUsername(tc.Username, "")
|
||||
_, _, err := th.Client.GetUserByUsername(context.Background(), tc.Username, "")
|
||||
if tc.ExpectedError != "" {
|
||||
CheckErrorID(t, err, tc.ExpectedError)
|
||||
} else {
|
||||
@@ -296,7 +297,7 @@ func TestAPIRestrictedViewMembers(t *testing.T) {
|
||||
th.AddPermissionToRole(model.PermissionViewMembers.Id, model.SystemUserRoleId)
|
||||
}
|
||||
|
||||
_, _, err := th.Client.GetUserByEmail(tc.Email, "")
|
||||
_, _, err := th.Client.GetUserByEmail(context.Background(), tc.Email, "")
|
||||
if tc.ExpectedError != "" {
|
||||
CheckErrorID(t, err, tc.ExpectedError)
|
||||
} else {
|
||||
@@ -377,7 +378,7 @@ func TestAPIRestrictedViewMembers(t *testing.T) {
|
||||
th.AddPermissionToRole(model.PermissionViewMembers.Id, model.SystemUserRoleId)
|
||||
}
|
||||
|
||||
_, _, err := th.Client.GetDefaultProfileImage(tc.UserId)
|
||||
_, _, err := th.Client.GetDefaultProfileImage(context.Background(), tc.UserId)
|
||||
if tc.ExpectedError != "" {
|
||||
CheckErrorID(t, err, tc.ExpectedError)
|
||||
} else {
|
||||
@@ -458,7 +459,7 @@ func TestAPIRestrictedViewMembers(t *testing.T) {
|
||||
th.AddPermissionToRole(model.PermissionViewMembers.Id, model.SystemUserRoleId)
|
||||
}
|
||||
|
||||
_, _, err := th.Client.GetProfileImage(tc.UserId, "")
|
||||
_, _, err := th.Client.GetProfileImage(context.Background(), tc.UserId, "")
|
||||
if tc.ExpectedError != "" {
|
||||
CheckErrorID(t, err, tc.ExpectedError)
|
||||
} else {
|
||||
|
||||
Ссылка в новой задаче
Block a user