github.com/coincircle/mattermost-server@v4.8.1-0.20180321182714-9d701c704416+incompatible/plugin/plugintest/hooks.go (about) 1 // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. 2 // See License.txt for license information. 3 4 package plugintest 5 6 import ( 7 "net/http" 8 9 "github.com/stretchr/testify/mock" 10 11 "github.com/mattermost/mattermost-server/model" 12 "github.com/mattermost/mattermost-server/plugin" 13 ) 14 15 type Hooks struct { 16 mock.Mock 17 } 18 19 var _ plugin.Hooks = (*Hooks)(nil) 20 21 func (m *Hooks) OnActivate(api plugin.API) error { 22 ret := m.Called(api) 23 if f, ok := ret.Get(0).(func(plugin.API) error); ok { 24 return f(api) 25 } 26 return ret.Error(0) 27 } 28 29 func (m *Hooks) OnDeactivate() error { 30 return m.Called().Error(0) 31 } 32 33 func (m *Hooks) OnConfigurationChange() error { 34 return m.Called().Error(0) 35 } 36 37 func (m *Hooks) ServeHTTP(w http.ResponseWriter, r *http.Request) { 38 m.Called(w, r) 39 } 40 41 func (m *Hooks) ExecuteCommand(args *model.CommandArgs) (*model.CommandResponse, *model.AppError) { 42 ret := m.Called(args) 43 if f, ok := ret.Get(0).(func(*model.CommandArgs) (*model.CommandResponse, *model.AppError)); ok { 44 return f(args) 45 } 46 resp, _ := ret.Get(0).(*model.CommandResponse) 47 err, _ := ret.Get(1).(*model.AppError) 48 return resp, err 49 }