MM-10703 Adding blank request context to plugin hooks for future use. (#9043)

* Adding blank request context to plugin hooks for future use.

* Rename RequestContext to Context

* Adding context to ServeHTTP and ExecuteCommand

* Fixing import cycle in test.
Этот коммит содержится в:
Christopher Speller
2018-07-06 06:07:09 -07:00
коммит произвёл Joram Wilander
родитель 7bfb5aec26
Коммит 4c1ddcff10
13 изменённых файлов: 890 добавлений и 74 удалений

Просмотреть файл

@@ -7,19 +7,20 @@ package plugintest
import http "net/http"
import mock "github.com/stretchr/testify/mock"
import model "github.com/mattermost/mattermost-server/model"
import plugin "github.com/mattermost/mattermost-server/plugin"
// Hooks is an autogenerated mock type for the Hooks type
type Hooks struct {
mock.Mock
}
// ExecuteCommand provides a mock function with given fields: args
func (_m *Hooks) ExecuteCommand(args *model.CommandArgs) (*model.CommandResponse, *model.AppError) {
ret := _m.Called(args)
// ExecuteCommand provides a mock function with given fields: c, args
func (_m *Hooks) ExecuteCommand(c *plugin.Context, args *model.CommandArgs) (*model.CommandResponse, *model.AppError) {
ret := _m.Called(c, args)
var r0 *model.CommandResponse
if rf, ok := ret.Get(0).(func(*model.CommandArgs) *model.CommandResponse); ok {
r0 = rf(args)
if rf, ok := ret.Get(0).(func(*plugin.Context, *model.CommandArgs) *model.CommandResponse); ok {
r0 = rf(c, args)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(*model.CommandResponse)
@@ -27,8 +28,8 @@ func (_m *Hooks) ExecuteCommand(args *model.CommandArgs) (*model.CommandResponse
}
var r1 *model.AppError
if rf, ok := ret.Get(1).(func(*model.CommandArgs) *model.AppError); ok {
r1 = rf(args)
if rf, ok := ret.Get(1).(func(*plugin.Context, *model.CommandArgs) *model.AppError); ok {
r1 = rf(c, args)
} else {
if ret.Get(1) != nil {
r1 = ret.Get(1).(*model.AppError)
@@ -61,23 +62,23 @@ func (_m *Hooks) Implemented() ([]string, error) {
return r0, r1
}
// MessageHasBeenPosted provides a mock function with given fields: post
func (_m *Hooks) MessageHasBeenPosted(post *model.Post) {
_m.Called(post)
// MessageHasBeenPosted provides a mock function with given fields: c, post
func (_m *Hooks) MessageHasBeenPosted(c *plugin.Context, post *model.Post) {
_m.Called(c, post)
}
// MessageHasBeenUpdated provides a mock function with given fields: newPost, oldPost
func (_m *Hooks) MessageHasBeenUpdated(newPost *model.Post, oldPost *model.Post) {
_m.Called(newPost, oldPost)
// MessageHasBeenUpdated provides a mock function with given fields: c, newPost, oldPost
func (_m *Hooks) MessageHasBeenUpdated(c *plugin.Context, newPost *model.Post, oldPost *model.Post) {
_m.Called(c, newPost, oldPost)
}
// MessageWillBePosted provides a mock function with given fields: post
func (_m *Hooks) MessageWillBePosted(post *model.Post) (*model.Post, string) {
ret := _m.Called(post)
// MessageWillBePosted provides a mock function with given fields: c, post
func (_m *Hooks) MessageWillBePosted(c *plugin.Context, post *model.Post) (*model.Post, string) {
ret := _m.Called(c, post)
var r0 *model.Post
if rf, ok := ret.Get(0).(func(*model.Post) *model.Post); ok {
r0 = rf(post)
if rf, ok := ret.Get(0).(func(*plugin.Context, *model.Post) *model.Post); ok {
r0 = rf(c, post)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(*model.Post)
@@ -85,8 +86,8 @@ func (_m *Hooks) MessageWillBePosted(post *model.Post) (*model.Post, string) {
}
var r1 string
if rf, ok := ret.Get(1).(func(*model.Post) string); ok {
r1 = rf(post)
if rf, ok := ret.Get(1).(func(*plugin.Context, *model.Post) string); ok {
r1 = rf(c, post)
} else {
r1 = ret.Get(1).(string)
}
@@ -94,13 +95,13 @@ func (_m *Hooks) MessageWillBePosted(post *model.Post) (*model.Post, string) {
return r0, r1
}
// MessageWillBeUpdated provides a mock function with given fields: newPost, oldPost
func (_m *Hooks) MessageWillBeUpdated(newPost *model.Post, oldPost *model.Post) (*model.Post, string) {
ret := _m.Called(newPost, oldPost)
// MessageWillBeUpdated provides a mock function with given fields: c, newPost, oldPost
func (_m *Hooks) MessageWillBeUpdated(c *plugin.Context, newPost *model.Post, oldPost *model.Post) (*model.Post, string) {
ret := _m.Called(c, newPost, oldPost)
var r0 *model.Post
if rf, ok := ret.Get(0).(func(*model.Post, *model.Post) *model.Post); ok {
r0 = rf(newPost, oldPost)
if rf, ok := ret.Get(0).(func(*plugin.Context, *model.Post, *model.Post) *model.Post); ok {
r0 = rf(c, newPost, oldPost)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(*model.Post)
@@ -108,8 +109,8 @@ func (_m *Hooks) MessageWillBeUpdated(newPost *model.Post, oldPost *model.Post)
}
var r1 string
if rf, ok := ret.Get(1).(func(*model.Post, *model.Post) string); ok {
r1 = rf(newPost, oldPost)
if rf, ok := ret.Get(1).(func(*plugin.Context, *model.Post, *model.Post) string); ok {
r1 = rf(c, newPost, oldPost)
} else {
r1 = ret.Get(1).(string)
}
@@ -159,7 +160,7 @@ func (_m *Hooks) OnDeactivate() error {
return r0
}
// ServeHTTP provides a mock function with given fields: w, r
func (_m *Hooks) ServeHTTP(w http.ResponseWriter, r *http.Request) {
_m.Called(w, r)
// ServeHTTP provides a mock function with given fields: c, w, r
func (_m *Hooks) ServeHTTP(c *plugin.Context, w http.ResponseWriter, r *http.Request) {
_m.Called(c, w, r)
}