[MM-16751] golint model (#17896)
Этот коммит содержится в:
коммит произвёл
Claudio Costa
родитель
953eebdef4
Коммит
97ccf0bdf6
@@ -413,13 +413,13 @@ func TestShouldProcessMessage(t *testing.T) {
|
||||
api := setupAPI()
|
||||
api.On("KVGet", plugin.BotUserKey).Return([]byte(expectedBotID), nil)
|
||||
p.API = api
|
||||
shouldProcessMessage, _ := p.ShouldProcessMessage(&model.Post{Type: model.POST_HEADER_CHANGE, UserId: expectedBotID}, plugin.AllowSystemMessages(), plugin.AllowBots())
|
||||
shouldProcessMessage, _ := p.ShouldProcessMessage(&model.Post{Type: model.PostTypeHeaderChange, UserId: expectedBotID}, plugin.AllowSystemMessages(), plugin.AllowBots())
|
||||
|
||||
assert.False(t, shouldProcessMessage)
|
||||
})
|
||||
|
||||
t.Run("should not process as the post is generated by system", func(t *testing.T) {
|
||||
shouldProcessMessage, _ := p.ShouldProcessMessage(&model.Post{Type: model.POST_HEADER_CHANGE})
|
||||
shouldProcessMessage, _ := p.ShouldProcessMessage(&model.Post{Type: model.PostTypeHeaderChange})
|
||||
|
||||
assert.False(t, shouldProcessMessage)
|
||||
})
|
||||
@@ -427,7 +427,7 @@ func TestShouldProcessMessage(t *testing.T) {
|
||||
t.Run("should not process as the post is sent to another channel", func(t *testing.T) {
|
||||
channelID := "channel-id"
|
||||
api := setupAPI()
|
||||
api.On("GetChannel", channelID).Return(&model.Channel{Id: channelID, Type: model.CHANNEL_GROUP}, nil)
|
||||
api.On("GetChannel", channelID).Return(&model.Channel{Id: channelID, Type: model.ChannelTypeGroup}, nil)
|
||||
p.API = api
|
||||
api.On("KVGet", plugin.BotUserKey).Return([]byte(expectedBotID), nil)
|
||||
|
||||
@@ -455,7 +455,7 @@ func TestShouldProcessMessage(t *testing.T) {
|
||||
channelID := "1"
|
||||
channel := model.Channel{
|
||||
Name: "user1__" + expectedBotID,
|
||||
Type: model.CHANNEL_OPEN,
|
||||
Type: model.ChannelTypeOpen,
|
||||
}
|
||||
api := setupAPI()
|
||||
api.On("GetChannel", channelID).Return(&channel, nil)
|
||||
@@ -473,7 +473,7 @@ func TestShouldProcessMessage(t *testing.T) {
|
||||
api.On("KVGet", plugin.BotUserKey).Return([]byte(expectedBotID), nil)
|
||||
p.API = api
|
||||
|
||||
shouldProcessMessage, _ := p.ShouldProcessMessage(&model.Post{UserId: "1", Type: model.POST_HEADER_CHANGE, ChannelId: channelID},
|
||||
shouldProcessMessage, _ := p.ShouldProcessMessage(&model.Post{UserId: "1", Type: model.PostTypeHeaderChange, ChannelId: channelID},
|
||||
plugin.AllowSystemMessages(), plugin.FilterChannelIDs([]string{channelID}), plugin.AllowBots(), plugin.FilterUserIDs([]string{"1"}))
|
||||
|
||||
assert.True(t, shouldProcessMessage)
|
||||
@@ -485,7 +485,7 @@ func TestShouldProcessMessage(t *testing.T) {
|
||||
api.On("KVGet", plugin.BotUserKey).Return(nil, nil)
|
||||
p.API = api
|
||||
|
||||
shouldProcessMessage, _ := p.ShouldProcessMessage(&model.Post{UserId: "1", Type: model.POST_HEADER_CHANGE, ChannelId: channelID},
|
||||
shouldProcessMessage, _ := p.ShouldProcessMessage(&model.Post{UserId: "1", Type: model.PostTypeHeaderChange, ChannelId: channelID},
|
||||
plugin.AllowSystemMessages(), plugin.FilterChannelIDs([]string{channelID}), plugin.AllowBots(), plugin.FilterUserIDs([]string{"1"}))
|
||||
|
||||
assert.True(t, shouldProcessMessage)
|
||||
@@ -496,13 +496,13 @@ func TestShouldProcessMessage(t *testing.T) {
|
||||
api := setupAPI()
|
||||
channel := model.Channel{
|
||||
Name: "user1__" + expectedBotID,
|
||||
Type: model.CHANNEL_DIRECT,
|
||||
Type: model.ChannelTypeDirect,
|
||||
}
|
||||
api.On("GetChannel", channelID).Return(&channel, nil)
|
||||
api.On("KVGet", plugin.BotUserKey).Return([]byte(expectedBotID), nil)
|
||||
p.API = api
|
||||
|
||||
shouldProcessMessage, _ := p.ShouldProcessMessage(&model.Post{UserId: "1", Type: model.POST_HEADER_CHANGE, ChannelId: channelID},
|
||||
shouldProcessMessage, _ := p.ShouldProcessMessage(&model.Post{UserId: "1", Type: model.PostTypeHeaderChange, ChannelId: channelID},
|
||||
plugin.AllowSystemMessages(), plugin.AllowBots())
|
||||
|
||||
assert.True(t, shouldProcessMessage)
|
||||
@@ -511,7 +511,7 @@ func TestShouldProcessMessage(t *testing.T) {
|
||||
t.Run("should not process the message which have from_webhook", func(t *testing.T) {
|
||||
channelID := "1"
|
||||
api := setupAPI()
|
||||
api.On("GetChannel", channelID).Return(&model.Channel{Id: channelID, Type: model.CHANNEL_GROUP}, nil)
|
||||
api.On("GetChannel", channelID).Return(&model.Channel{Id: channelID, Type: model.ChannelTypeGroup}, nil)
|
||||
p.API = api
|
||||
api.On("KVGet", plugin.BotUserKey).Return([]byte(expectedBotID), nil)
|
||||
|
||||
@@ -524,7 +524,7 @@ func TestShouldProcessMessage(t *testing.T) {
|
||||
t.Run("should process the message which have from_webhook with allow webhook plugin", func(t *testing.T) {
|
||||
channelID := "1"
|
||||
api := setupAPI()
|
||||
api.On("GetChannel", channelID).Return(&model.Channel{Id: channelID, Type: model.CHANNEL_GROUP}, nil)
|
||||
api.On("GetChannel", channelID).Return(&model.Channel{Id: channelID, Type: model.ChannelTypeGroup}, nil)
|
||||
p.API = api
|
||||
api.On("KVGet", plugin.BotUserKey).Return([]byte(expectedBotID), nil)
|
||||
|
||||
@@ -537,7 +537,7 @@ func TestShouldProcessMessage(t *testing.T) {
|
||||
t.Run("should process the message where from_webhook is not set", func(t *testing.T) {
|
||||
channelID := "1"
|
||||
api := setupAPI()
|
||||
api.On("GetChannel", channelID).Return(&model.Channel{Id: channelID, Type: model.CHANNEL_GROUP}, nil)
|
||||
api.On("GetChannel", channelID).Return(&model.Channel{Id: channelID, Type: model.ChannelTypeGroup}, nil)
|
||||
p.API = api
|
||||
api.On("KVGet", plugin.BotUserKey).Return([]byte(expectedBotID), nil)
|
||||
|
||||
@@ -550,7 +550,7 @@ func TestShouldProcessMessage(t *testing.T) {
|
||||
t.Run("should process the message which have from_webhook false", func(t *testing.T) {
|
||||
channelID := "1"
|
||||
api := setupAPI()
|
||||
api.On("GetChannel", channelID).Return(&model.Channel{Id: channelID, Type: model.CHANNEL_GROUP}, nil)
|
||||
api.On("GetChannel", channelID).Return(&model.Channel{Id: channelID, Type: model.ChannelTypeGroup}, nil)
|
||||
p.API = api
|
||||
api.On("KVGet", plugin.BotUserKey).Return([]byte(expectedBotID), nil)
|
||||
|
||||
@@ -564,7 +564,7 @@ func TestShouldProcessMessage(t *testing.T) {
|
||||
userID := "user-id"
|
||||
channelID := "1"
|
||||
api := setupAPI()
|
||||
api.On("GetChannel", channelID).Return(&model.Channel{Id: channelID, Type: model.CHANNEL_GROUP}, nil)
|
||||
api.On("GetChannel", channelID).Return(&model.Channel{Id: channelID, Type: model.ChannelTypeGroup}, nil)
|
||||
p.API = api
|
||||
api.On("GetUser", userID).Return(&model.User{IsBot: false}, nil)
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ func (scheduler *Scheduler) Name() string {
|
||||
}
|
||||
|
||||
func (scheduler *Scheduler) JobType() string {
|
||||
return model.JOB_TYPE_PLUGINS
|
||||
return model.JobTypePlugins
|
||||
}
|
||||
|
||||
func (scheduler *Scheduler) Enabled(cfg *model.Config) bool {
|
||||
@@ -41,7 +41,7 @@ func (scheduler *Scheduler) NextScheduleTime(cfg *model.Config, now time.Time, p
|
||||
func (scheduler *Scheduler) ScheduleJob(cfg *model.Config, pendingJobs bool, lastSuccessfulJob *model.Job) (*model.Job, *model.AppError) {
|
||||
mlog.Debug("Scheduling Job", mlog.String("scheduler", scheduler.Name()))
|
||||
|
||||
job, err := scheduler.App.Srv().Jobs.CreateJob(model.JOB_TYPE_PLUGINS, nil)
|
||||
job, err := scheduler.App.Srv().Jobs.CreateJob(model.JobTypePlugins, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user