[MM-45769] Properly initialize the request.Context for imports and tests (#20659)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
ae482e6214
Коммит
cb6cee1883
@@ -14,7 +14,6 @@ import (
|
|||||||
|
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
"github.com/mattermost/mattermost-server/v6/app/request"
|
|
||||||
"github.com/mattermost/mattermost-server/v6/model"
|
"github.com/mattermost/mattermost-server/v6/model"
|
||||||
"github.com/mattermost/mattermost-server/v6/store/storetest/mocks"
|
"github.com/mattermost/mattermost-server/v6/store/storetest/mocks"
|
||||||
)
|
)
|
||||||
@@ -720,7 +719,7 @@ func TestNoticeFetch(t *testing.T) {
|
|||||||
require.Nil(t, appErr)
|
require.Nil(t, appErr)
|
||||||
|
|
||||||
// get them for specified user
|
// get them for specified user
|
||||||
messages, appErr := th.App.GetProductNotices(&request.Context{}, th.BasicUser.Id, th.BasicTeam.Id, model.NoticeClientTypeAll, "1.2.3", "en")
|
messages, appErr := th.App.GetProductNotices(th.Context, th.BasicUser.Id, th.BasicTeam.Id, model.NoticeClientTypeAll, "1.2.3", "en")
|
||||||
require.Nil(t, appErr)
|
require.Nil(t, appErr)
|
||||||
require.Len(t, messages, 1)
|
require.Len(t, messages, 1)
|
||||||
|
|
||||||
@@ -729,7 +728,7 @@ func TestNoticeFetch(t *testing.T) {
|
|||||||
require.Nil(t, appErr)
|
require.Nil(t, appErr)
|
||||||
|
|
||||||
// get them again, see that none are returned
|
// get them again, see that none are returned
|
||||||
messages, appErr = th.App.GetProductNotices(&request.Context{}, th.BasicUser.Id, th.BasicTeam.Id, model.NoticeClientTypeAll, "1.2.3", "en")
|
messages, appErr = th.App.GetProductNotices(th.Context, th.BasicUser.Id, th.BasicTeam.Id, model.NoticeClientTypeAll, "1.2.3", "en")
|
||||||
require.Nil(t, appErr)
|
require.Nil(t, appErr)
|
||||||
require.Len(t, messages, 0)
|
require.Len(t, messages, 0)
|
||||||
|
|
||||||
@@ -748,7 +747,7 @@ func TestNoticeFetch(t *testing.T) {
|
|||||||
require.Nil(t, appErr)
|
require.Nil(t, appErr)
|
||||||
|
|
||||||
// get them again, since conditions don't match we should be zero
|
// get them again, since conditions don't match we should be zero
|
||||||
messages, appErr = th.App.GetProductNotices(&request.Context{}, th.BasicUser.Id, th.BasicTeam.Id, model.NoticeClientTypeAll, "1.2.3", "en")
|
messages, appErr = th.App.GetProductNotices(th.Context, th.BasicUser.Id, th.BasicTeam.Id, model.NoticeClientTypeAll, "1.2.3", "en")
|
||||||
require.Nil(t, appErr)
|
require.Nil(t, appErr)
|
||||||
require.Len(t, messages, 0)
|
require.Len(t, messages, 0)
|
||||||
|
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ func setupTestHelper(s store.Store, includeCacheLayer bool, tb testing.TB) *Test
|
|||||||
},
|
},
|
||||||
wh: &mockWebHub{},
|
wh: &mockWebHub{},
|
||||||
},
|
},
|
||||||
Context: &request.Context{},
|
Context: request.EmptyContext(nil),
|
||||||
configStore: configStore,
|
configStore: configStore,
|
||||||
dbStore: s,
|
dbStore: s,
|
||||||
LogBuffer: buffer,
|
LogBuffer: buffer,
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ func setupTestHelper(s store.Store, includeCacheLayer bool, tb testing.TB) *Test
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Context: &request.Context{},
|
Context: request.EmptyContext(nil),
|
||||||
configStore: configStore,
|
configStore: configStore,
|
||||||
dbStore: s,
|
dbStore: s,
|
||||||
LogBuffer: buffer,
|
LogBuffer: buffer,
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ func slackImportCmdF(command *cobra.Command, args []string) error {
|
|||||||
|
|
||||||
CommandPrettyPrintln("Running Slack Import. This may take a long time for large teams or teams with many messages.")
|
CommandPrettyPrintln("Running Slack Import. This may take a long time for large teams or teams with many messages.")
|
||||||
|
|
||||||
importErr, log := a.SlackImport(&request.Context{}, fileReader, fileInfo.Size(), team.Id)
|
importErr, log := a.SlackImport(request.EmptyContext(nil), fileReader, fileInfo.Size(), team.Id)
|
||||||
|
|
||||||
if importErr != nil {
|
if importErr != nil {
|
||||||
return err
|
return err
|
||||||
@@ -152,7 +152,7 @@ func bulkImportCmdF(command *cobra.Command, args []string) error {
|
|||||||
|
|
||||||
CommandPrettyPrintln("")
|
CommandPrettyPrintln("")
|
||||||
|
|
||||||
if err, lineNumber := a.BulkImportWithPath(&request.Context{}, fileReader, nil, !apply, workers, importPath); err != nil {
|
if err, lineNumber := a.BulkImportWithPath(request.EmptyContext(nil), fileReader, nil, !apply, workers, importPath); err != nil {
|
||||||
CommandPrintErrorln(err.Error())
|
CommandPrintErrorln(err.Error())
|
||||||
if lineNumber != 0 {
|
if lineNumber != 0 {
|
||||||
CommandPrintErrorln(fmt.Sprintf("Error occurred on data file line %v", lineNumber))
|
CommandPrintErrorln(fmt.Sprintf("Error occurred on data file line %v", lineNumber))
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ func initDBCommandContextCobra(command *cobra.Command, readOnlyConfigStore bool)
|
|||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
a.InitPlugins(&request.Context{}, *a.Config().PluginSettings.Directory, *a.Config().PluginSettings.ClientDirectory)
|
a.InitPlugins(request.EmptyContext(a.Log()), *a.Config().PluginSettings.Directory, *a.Config().PluginSettings.ClientDirectory)
|
||||||
a.DoAppMigrations()
|
a.DoAppMigrations()
|
||||||
|
|
||||||
return a, nil
|
return a, nil
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ type AppIface interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func MakeWorker(jobServer *jobs.JobServer, app AppIface) model.Worker {
|
func MakeWorker(jobServer *jobs.JobServer, app AppIface) model.Worker {
|
||||||
appContext := &request.Context{}
|
appContext := request.EmptyContext(nil)
|
||||||
isEnabled := func(cfg *model.Config) bool {
|
isEnabled := func(cfg *model.Config) bool {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -327,7 +327,7 @@ func TestOldImportChannel(t *testing.T) {
|
|||||||
store := &mocks.Store{}
|
store := &mocks.Store{}
|
||||||
config := &model.Config{}
|
config := &model.Config{}
|
||||||
config.SetDefaults()
|
config.SetDefaults()
|
||||||
ctx := &request.Context{}
|
ctx := request.EmptyContext(nil)
|
||||||
ctx.SetLogger(mlog.CreateConsoleTestLogger(true, mlog.LvlDebug))
|
ctx.SetLogger(mlog.CreateConsoleTestLogger(true, mlog.LvlDebug))
|
||||||
|
|
||||||
t.Run("No panic on direct channel", func(t *testing.T) {
|
t.Run("No panic on direct channel", func(t *testing.T) {
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ import (
|
|||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
"github.com/mattermost/mattermost-server/v6/app/request"
|
|
||||||
"github.com/mattermost/mattermost-server/v6/model"
|
"github.com/mattermost/mattermost-server/v6/model"
|
||||||
"github.com/mattermost/mattermost-server/v6/plugin/plugintest/mock"
|
"github.com/mattermost/mattermost-server/v6/plugin/plugintest/mock"
|
||||||
"github.com/mattermost/mattermost-server/v6/store/storetest/mocks"
|
"github.com/mattermost/mattermost-server/v6/store/storetest/mocks"
|
||||||
@@ -43,7 +42,7 @@ func TestCloudKeyRequired(t *testing.T) {
|
|||||||
|
|
||||||
c := &Context{
|
c := &Context{
|
||||||
App: th.App,
|
App: th.App,
|
||||||
AppContext: &request.Context{},
|
AppContext: th.Context,
|
||||||
}
|
}
|
||||||
|
|
||||||
c.CloudKeyRequired()
|
c.CloudKeyRequired()
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ import (
|
|||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
"github.com/mattermost/mattermost-server/v6/app/request"
|
|
||||||
"github.com/mattermost/mattermost-server/v6/einterfaces"
|
"github.com/mattermost/mattermost-server/v6/einterfaces"
|
||||||
"github.com/mattermost/mattermost-server/v6/model"
|
"github.com/mattermost/mattermost-server/v6/model"
|
||||||
"github.com/mattermost/mattermost-server/v6/shared/i18n"
|
"github.com/mattermost/mattermost-server/v6/shared/i18n"
|
||||||
@@ -368,7 +367,7 @@ func TestMobileLoginWithOAuth(t *testing.T) {
|
|||||||
defer th.TearDown()
|
defer th.TearDown()
|
||||||
c := &Context{
|
c := &Context{
|
||||||
App: th.App,
|
App: th.App,
|
||||||
AppContext: &request.Context{},
|
AppContext: th.Context,
|
||||||
Params: &Params{
|
Params: &Params{
|
||||||
Service: "gitlab",
|
Service: "gitlab",
|
||||||
},
|
},
|
||||||
@@ -573,7 +572,7 @@ func TestOAuthComplete_ErrorMessages(t *testing.T) {
|
|||||||
defer th.TearDown()
|
defer th.TearDown()
|
||||||
c := &Context{
|
c := &Context{
|
||||||
App: th.App,
|
App: th.App,
|
||||||
AppContext: &request.Context{},
|
AppContext: th.Context,
|
||||||
Params: &Params{
|
Params: &Params{
|
||||||
Service: "gitlab",
|
Service: "gitlab",
|
||||||
},
|
},
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user