[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/assert"
|
||||
@@ -20,7 +21,7 @@ func TestGetTermsOfService(t *testing.T) {
|
||||
_, appErr := th.App.CreateTermsOfService("abc", th.BasicUser.Id)
|
||||
require.Nil(t, appErr)
|
||||
|
||||
termsOfService, _, err := client.GetTermsOfService("")
|
||||
termsOfService, _, err := client.GetTermsOfService(context.Background(), "")
|
||||
require.NoError(t, err)
|
||||
|
||||
assert.NotNil(t, termsOfService)
|
||||
@@ -34,7 +35,7 @@ func TestCreateTermsOfService(t *testing.T) {
|
||||
defer th.TearDown()
|
||||
client := th.Client
|
||||
|
||||
_, _, err := client.CreateTermsOfService("terms of service new", th.BasicUser.Id)
|
||||
_, _, err := client.CreateTermsOfService(context.Background(), "terms of service new", th.BasicUser.Id)
|
||||
CheckErrorID(t, err, "api.context.permissions.app_error")
|
||||
}
|
||||
|
||||
@@ -43,13 +44,13 @@ func TestCreateTermsOfServiceAdminUser(t *testing.T) {
|
||||
defer th.TearDown()
|
||||
client := th.SystemAdminClient
|
||||
|
||||
termsOfService, _, err := client.CreateTermsOfService("terms of service new", th.SystemAdminUser.Id)
|
||||
termsOfService, _, err := client.CreateTermsOfService(context.Background(), "terms of service new", th.SystemAdminUser.Id)
|
||||
CheckErrorID(t, err, "api.create_terms_of_service.custom_terms_of_service_disabled.app_error")
|
||||
assert.Nil(t, termsOfService)
|
||||
|
||||
th.App.Srv().SetLicense(model.NewTestLicense("EnableCustomTermsOfService"))
|
||||
|
||||
termsOfService, _, err = client.CreateTermsOfService("terms of service new_2", th.SystemAdminUser.Id)
|
||||
termsOfService, _, err = client.CreateTermsOfService(context.Background(), "terms of service new_2", th.SystemAdminUser.Id)
|
||||
require.NoError(t, err)
|
||||
assert.NotEmpty(t, termsOfService.Id)
|
||||
assert.NotEmpty(t, termsOfService.CreateAt)
|
||||
|
||||
Ссылка в новой задаче
Block a user