summaryrefslogtreecommitdiffstats
path: root/plugin/plugintest
diff options
context:
space:
mode:
Diffstat (limited to 'plugin/plugintest')
-rw-r--r--plugin/plugintest/api.go396
-rw-r--r--plugin/plugintest/apioverride.go18
-rw-r--r--plugin/plugintest/hooks.go118
-rw-r--r--plugin/plugintest/key_value_store.go70
4 files changed, 439 insertions, 163 deletions
diff --git a/plugin/plugintest/api.go b/plugin/plugintest/api.go
index f1281a5ff..3ce1d0145 100644
--- a/plugin/plugintest/api.go
+++ b/plugin/plugintest/api.go
@@ -6,15 +6,14 @@ package plugintest
import mock "github.com/stretchr/testify/mock"
import model "github.com/mattermost/mattermost-server/model"
-import plugin "github.com/mattermost/mattermost-server/plugin"
-// APIMOCKINTERNAL is an autogenerated mock type for the APIMOCKINTERNAL type
-type APIMOCKINTERNAL struct {
+// API is an autogenerated mock type for the API type
+type API struct {
mock.Mock
}
// AddChannelMember provides a mock function with given fields: channelId, userId
-func (_m *APIMOCKINTERNAL) AddChannelMember(channelId string, userId string) (*model.ChannelMember, *model.AppError) {
+func (_m *API) AddChannelMember(channelId string, userId string) (*model.ChannelMember, *model.AppError) {
ret := _m.Called(channelId, userId)
var r0 *model.ChannelMember
@@ -39,7 +38,7 @@ func (_m *APIMOCKINTERNAL) AddChannelMember(channelId string, userId string) (*m
}
// CreateChannel provides a mock function with given fields: channel
-func (_m *APIMOCKINTERNAL) CreateChannel(channel *model.Channel) (*model.Channel, *model.AppError) {
+func (_m *API) CreateChannel(channel *model.Channel) (*model.Channel, *model.AppError) {
ret := _m.Called(channel)
var r0 *model.Channel
@@ -64,7 +63,7 @@ func (_m *APIMOCKINTERNAL) CreateChannel(channel *model.Channel) (*model.Channel
}
// CreatePost provides a mock function with given fields: post
-func (_m *APIMOCKINTERNAL) CreatePost(post *model.Post) (*model.Post, *model.AppError) {
+func (_m *API) CreatePost(post *model.Post) (*model.Post, *model.AppError) {
ret := _m.Called(post)
var r0 *model.Post
@@ -89,7 +88,7 @@ func (_m *APIMOCKINTERNAL) CreatePost(post *model.Post) (*model.Post, *model.App
}
// CreateTeam provides a mock function with given fields: team
-func (_m *APIMOCKINTERNAL) CreateTeam(team *model.Team) (*model.Team, *model.AppError) {
+func (_m *API) CreateTeam(team *model.Team) (*model.Team, *model.AppError) {
ret := _m.Called(team)
var r0 *model.Team
@@ -113,8 +112,58 @@ func (_m *APIMOCKINTERNAL) CreateTeam(team *model.Team) (*model.Team, *model.App
return r0, r1
}
+// CreateTeamMember provides a mock function with given fields: teamId, userId
+func (_m *API) CreateTeamMember(teamId string, userId string) (*model.TeamMember, *model.AppError) {
+ ret := _m.Called(teamId, userId)
+
+ var r0 *model.TeamMember
+ if rf, ok := ret.Get(0).(func(string, string) *model.TeamMember); ok {
+ r0 = rf(teamId, userId)
+ } else {
+ if ret.Get(0) != nil {
+ r0 = ret.Get(0).(*model.TeamMember)
+ }
+ }
+
+ var r1 *model.AppError
+ if rf, ok := ret.Get(1).(func(string, string) *model.AppError); ok {
+ r1 = rf(teamId, userId)
+ } else {
+ if ret.Get(1) != nil {
+ r1 = ret.Get(1).(*model.AppError)
+ }
+ }
+
+ return r0, r1
+}
+
+// CreateTeamMembers provides a mock function with given fields: teamId, userIds, requestorId
+func (_m *API) CreateTeamMembers(teamId string, userIds []string, requestorId string) ([]*model.TeamMember, *model.AppError) {
+ ret := _m.Called(teamId, userIds, requestorId)
+
+ var r0 []*model.TeamMember
+ if rf, ok := ret.Get(0).(func(string, []string, string) []*model.TeamMember); ok {
+ r0 = rf(teamId, userIds, requestorId)
+ } else {
+ if ret.Get(0) != nil {
+ r0 = ret.Get(0).([]*model.TeamMember)
+ }
+ }
+
+ var r1 *model.AppError
+ if rf, ok := ret.Get(1).(func(string, []string, string) *model.AppError); ok {
+ r1 = rf(teamId, userIds, requestorId)
+ } else {
+ if ret.Get(1) != nil {
+ r1 = ret.Get(1).(*model.AppError)
+ }
+ }
+
+ return r0, r1
+}
+
// CreateUser provides a mock function with given fields: user
-func (_m *APIMOCKINTERNAL) CreateUser(user *model.User) (*model.User, *model.AppError) {
+func (_m *API) CreateUser(user *model.User) (*model.User, *model.AppError) {
ret := _m.Called(user)
var r0 *model.User
@@ -139,7 +188,7 @@ func (_m *APIMOCKINTERNAL) CreateUser(user *model.User) (*model.User, *model.App
}
// DeleteChannel provides a mock function with given fields: channelId
-func (_m *APIMOCKINTERNAL) DeleteChannel(channelId string) *model.AppError {
+func (_m *API) DeleteChannel(channelId string) *model.AppError {
ret := _m.Called(channelId)
var r0 *model.AppError
@@ -155,7 +204,7 @@ func (_m *APIMOCKINTERNAL) DeleteChannel(channelId string) *model.AppError {
}
// DeleteChannelMember provides a mock function with given fields: channelId, userId
-func (_m *APIMOCKINTERNAL) DeleteChannelMember(channelId string, userId string) *model.AppError {
+func (_m *API) DeleteChannelMember(channelId string, userId string) *model.AppError {
ret := _m.Called(channelId, userId)
var r0 *model.AppError
@@ -171,7 +220,7 @@ func (_m *APIMOCKINTERNAL) DeleteChannelMember(channelId string, userId string)
}
// DeletePost provides a mock function with given fields: postId
-func (_m *APIMOCKINTERNAL) DeletePost(postId string) *model.AppError {
+func (_m *API) DeletePost(postId string) *model.AppError {
ret := _m.Called(postId)
var r0 *model.AppError
@@ -187,7 +236,7 @@ func (_m *APIMOCKINTERNAL) DeletePost(postId string) *model.AppError {
}
// DeleteTeam provides a mock function with given fields: teamId
-func (_m *APIMOCKINTERNAL) DeleteTeam(teamId string) *model.AppError {
+func (_m *API) DeleteTeam(teamId string) *model.AppError {
ret := _m.Called(teamId)
var r0 *model.AppError
@@ -202,8 +251,24 @@ func (_m *APIMOCKINTERNAL) DeleteTeam(teamId string) *model.AppError {
return r0
}
+// DeleteTeamMember provides a mock function with given fields: teamId, userId, requestorId
+func (_m *API) DeleteTeamMember(teamId string, userId string, requestorId string) *model.AppError {
+ ret := _m.Called(teamId, userId, requestorId)
+
+ var r0 *model.AppError
+ if rf, ok := ret.Get(0).(func(string, string, string) *model.AppError); ok {
+ r0 = rf(teamId, userId, requestorId)
+ } else {
+ if ret.Get(0) != nil {
+ r0 = ret.Get(0).(*model.AppError)
+ }
+ }
+
+ return r0
+}
+
// DeleteUser provides a mock function with given fields: userId
-func (_m *APIMOCKINTERNAL) DeleteUser(userId string) *model.AppError {
+func (_m *API) DeleteUser(userId string) *model.AppError {
ret := _m.Called(userId)
var r0 *model.AppError
@@ -219,7 +284,7 @@ func (_m *APIMOCKINTERNAL) DeleteUser(userId string) *model.AppError {
}
// GetChannel provides a mock function with given fields: channelId
-func (_m *APIMOCKINTERNAL) GetChannel(channelId string) (*model.Channel, *model.AppError) {
+func (_m *API) GetChannel(channelId string) (*model.Channel, *model.AppError) {
ret := _m.Called(channelId)
var r0 *model.Channel
@@ -244,7 +309,7 @@ func (_m *APIMOCKINTERNAL) GetChannel(channelId string) (*model.Channel, *model.
}
// GetChannelByName provides a mock function with given fields: name, teamId
-func (_m *APIMOCKINTERNAL) GetChannelByName(name string, teamId string) (*model.Channel, *model.AppError) {
+func (_m *API) GetChannelByName(name string, teamId string) (*model.Channel, *model.AppError) {
ret := _m.Called(name, teamId)
var r0 *model.Channel
@@ -269,7 +334,7 @@ func (_m *APIMOCKINTERNAL) GetChannelByName(name string, teamId string) (*model.
}
// GetChannelMember provides a mock function with given fields: channelId, userId
-func (_m *APIMOCKINTERNAL) GetChannelMember(channelId string, userId string) (*model.ChannelMember, *model.AppError) {
+func (_m *API) GetChannelMember(channelId string, userId string) (*model.ChannelMember, *model.AppError) {
ret := _m.Called(channelId, userId)
var r0 *model.ChannelMember
@@ -293,8 +358,24 @@ func (_m *APIMOCKINTERNAL) GetChannelMember(channelId string, userId string) (*m
return r0, r1
}
+// GetConfig provides a mock function with given fields:
+func (_m *API) GetConfig() *model.Config {
+ ret := _m.Called()
+
+ var r0 *model.Config
+ if rf, ok := ret.Get(0).(func() *model.Config); ok {
+ r0 = rf()
+ } else {
+ if ret.Get(0) != nil {
+ r0 = ret.Get(0).(*model.Config)
+ }
+ }
+
+ return r0
+}
+
// GetDirectChannel provides a mock function with given fields: userId1, userId2
-func (_m *APIMOCKINTERNAL) GetDirectChannel(userId1 string, userId2 string) (*model.Channel, *model.AppError) {
+func (_m *API) GetDirectChannel(userId1 string, userId2 string) (*model.Channel, *model.AppError) {
ret := _m.Called(userId1, userId2)
var r0 *model.Channel
@@ -319,7 +400,7 @@ func (_m *APIMOCKINTERNAL) GetDirectChannel(userId1 string, userId2 string) (*mo
}
// GetGroupChannel provides a mock function with given fields: userIds
-func (_m *APIMOCKINTERNAL) GetGroupChannel(userIds []string) (*model.Channel, *model.AppError) {
+func (_m *API) GetGroupChannel(userIds []string) (*model.Channel, *model.AppError) {
ret := _m.Called(userIds)
var r0 *model.Channel
@@ -344,7 +425,7 @@ func (_m *APIMOCKINTERNAL) GetGroupChannel(userIds []string) (*model.Channel, *m
}
// GetPost provides a mock function with given fields: postId
-func (_m *APIMOCKINTERNAL) GetPost(postId string) (*model.Post, *model.AppError) {
+func (_m *API) GetPost(postId string) (*model.Post, *model.AppError) {
ret := _m.Called(postId)
var r0 *model.Post
@@ -368,8 +449,33 @@ func (_m *APIMOCKINTERNAL) GetPost(postId string) (*model.Post, *model.AppError)
return r0, r1
}
+// GetPublicChannelsForTeam provides a mock function with given fields: teamId, offset, limit
+func (_m *API) GetPublicChannelsForTeam(teamId string, offset int, limit int) (*model.ChannelList, *model.AppError) {
+ ret := _m.Called(teamId, offset, limit)
+
+ var r0 *model.ChannelList
+ if rf, ok := ret.Get(0).(func(string, int, int) *model.ChannelList); ok {
+ r0 = rf(teamId, offset, limit)
+ } else {
+ if ret.Get(0) != nil {
+ r0 = ret.Get(0).(*model.ChannelList)
+ }
+ }
+
+ var r1 *model.AppError
+ if rf, ok := ret.Get(1).(func(string, int, int) *model.AppError); ok {
+ r1 = rf(teamId, offset, limit)
+ } else {
+ if ret.Get(1) != nil {
+ r1 = ret.Get(1).(*model.AppError)
+ }
+ }
+
+ return r0, r1
+}
+
// GetTeam provides a mock function with given fields: teamId
-func (_m *APIMOCKINTERNAL) GetTeam(teamId string) (*model.Team, *model.AppError) {
+func (_m *API) GetTeam(teamId string) (*model.Team, *model.AppError) {
ret := _m.Called(teamId)
var r0 *model.Team
@@ -394,7 +500,7 @@ func (_m *APIMOCKINTERNAL) GetTeam(teamId string) (*model.Team, *model.AppError)
}
// GetTeamByName provides a mock function with given fields: name
-func (_m *APIMOCKINTERNAL) GetTeamByName(name string) (*model.Team, *model.AppError) {
+func (_m *API) GetTeamByName(name string) (*model.Team, *model.AppError) {
ret := _m.Called(name)
var r0 *model.Team
@@ -418,8 +524,83 @@ func (_m *APIMOCKINTERNAL) GetTeamByName(name string) (*model.Team, *model.AppEr
return r0, r1
}
+// GetTeamMember provides a mock function with given fields: teamId, userId
+func (_m *API) GetTeamMember(teamId string, userId string) (*model.TeamMember, *model.AppError) {
+ ret := _m.Called(teamId, userId)
+
+ var r0 *model.TeamMember
+ if rf, ok := ret.Get(0).(func(string, string) *model.TeamMember); ok {
+ r0 = rf(teamId, userId)
+ } else {
+ if ret.Get(0) != nil {
+ r0 = ret.Get(0).(*model.TeamMember)
+ }
+ }
+
+ var r1 *model.AppError
+ if rf, ok := ret.Get(1).(func(string, string) *model.AppError); ok {
+ r1 = rf(teamId, userId)
+ } else {
+ if ret.Get(1) != nil {
+ r1 = ret.Get(1).(*model.AppError)
+ }
+ }
+
+ return r0, r1
+}
+
+// GetTeamMembers provides a mock function with given fields: teamId, offset, limit
+func (_m *API) GetTeamMembers(teamId string, offset int, limit int) ([]*model.TeamMember, *model.AppError) {
+ ret := _m.Called(teamId, offset, limit)
+
+ var r0 []*model.TeamMember
+ if rf, ok := ret.Get(0).(func(string, int, int) []*model.TeamMember); ok {
+ r0 = rf(teamId, offset, limit)
+ } else {
+ if ret.Get(0) != nil {
+ r0 = ret.Get(0).([]*model.TeamMember)
+ }
+ }
+
+ var r1 *model.AppError
+ if rf, ok := ret.Get(1).(func(string, int, int) *model.AppError); ok {
+ r1 = rf(teamId, offset, limit)
+ } else {
+ if ret.Get(1) != nil {
+ r1 = ret.Get(1).(*model.AppError)
+ }
+ }
+
+ return r0, r1
+}
+
+// GetTeams provides a mock function with given fields:
+func (_m *API) GetTeams() ([]*model.Team, *model.AppError) {
+ ret := _m.Called()
+
+ var r0 []*model.Team
+ if rf, ok := ret.Get(0).(func() []*model.Team); ok {
+ r0 = rf()
+ } else {
+ if ret.Get(0) != nil {
+ r0 = ret.Get(0).([]*model.Team)
+ }
+ }
+
+ var r1 *model.AppError
+ if rf, ok := ret.Get(1).(func() *model.AppError); ok {
+ r1 = rf()
+ } else {
+ if ret.Get(1) != nil {
+ r1 = ret.Get(1).(*model.AppError)
+ }
+ }
+
+ return r0, r1
+}
+
// GetUser provides a mock function with given fields: userId
-func (_m *APIMOCKINTERNAL) GetUser(userId string) (*model.User, *model.AppError) {
+func (_m *API) GetUser(userId string) (*model.User, *model.AppError) {
ret := _m.Called(userId)
var r0 *model.User
@@ -444,7 +625,7 @@ func (_m *APIMOCKINTERNAL) GetUser(userId string) (*model.User, *model.AppError)
}
// GetUserByEmail provides a mock function with given fields: email
-func (_m *APIMOCKINTERNAL) GetUserByEmail(email string) (*model.User, *model.AppError) {
+func (_m *API) GetUserByEmail(email string) (*model.User, *model.AppError) {
ret := _m.Called(email)
var r0 *model.User
@@ -469,7 +650,7 @@ func (_m *APIMOCKINTERNAL) GetUserByEmail(email string) (*model.User, *model.App
}
// GetUserByUsername provides a mock function with given fields: name
-func (_m *APIMOCKINTERNAL) GetUserByUsername(name string) (*model.User, *model.AppError) {
+func (_m *API) GetUserByUsername(name string) (*model.User, *model.AppError) {
ret := _m.Called(name)
var r0 *model.User
@@ -493,16 +674,57 @@ func (_m *APIMOCKINTERNAL) GetUserByUsername(name string) (*model.User, *model.A
return r0, r1
}
-// KeyValueStore provides a mock function with given fields:
-func (_m *APIMOCKINTERNAL) KeyValueStore() plugin.KeyValueStore {
- ret := _m.Called()
+// KVDelete provides a mock function with given fields: key
+func (_m *API) KVDelete(key string) *model.AppError {
+ ret := _m.Called(key)
- var r0 plugin.KeyValueStore
- if rf, ok := ret.Get(0).(func() plugin.KeyValueStore); ok {
- r0 = rf()
+ var r0 *model.AppError
+ if rf, ok := ret.Get(0).(func(string) *model.AppError); ok {
+ r0 = rf(key)
+ } else {
+ if ret.Get(0) != nil {
+ r0 = ret.Get(0).(*model.AppError)
+ }
+ }
+
+ return r0
+}
+
+// KVGet provides a mock function with given fields: key
+func (_m *API) KVGet(key string) ([]byte, *model.AppError) {
+ ret := _m.Called(key)
+
+ var r0 []byte
+ if rf, ok := ret.Get(0).(func(string) []byte); ok {
+ r0 = rf(key)
+ } else {
+ if ret.Get(0) != nil {
+ r0 = ret.Get(0).([]byte)
+ }
+ }
+
+ var r1 *model.AppError
+ if rf, ok := ret.Get(1).(func(string) *model.AppError); ok {
+ r1 = rf(key)
+ } else {
+ if ret.Get(1) != nil {
+ r1 = ret.Get(1).(*model.AppError)
+ }
+ }
+
+ return r0, r1
+}
+
+// KVSet provides a mock function with given fields: key, value
+func (_m *API) KVSet(key string, value []byte) *model.AppError {
+ ret := _m.Called(key, value)
+
+ var r0 *model.AppError
+ if rf, ok := ret.Get(0).(func(string, []byte) *model.AppError); ok {
+ r0 = rf(key, value)
} else {
if ret.Get(0) != nil {
- r0 = ret.Get(0).(plugin.KeyValueStore)
+ r0 = ret.Get(0).(*model.AppError)
}
}
@@ -510,7 +732,7 @@ func (_m *APIMOCKINTERNAL) KeyValueStore() plugin.KeyValueStore {
}
// LoadPluginConfiguration provides a mock function with given fields: dest
-func (_m *APIMOCKINTERNAL) LoadPluginConfiguration(dest interface{}) error {
+func (_m *API) LoadPluginConfiguration(dest interface{}) error {
ret := _m.Called(dest)
var r0 error
@@ -523,8 +745,45 @@ func (_m *APIMOCKINTERNAL) LoadPluginConfiguration(dest interface{}) error {
return r0
}
+// LogDebug provides a mock function with given fields: msg, keyValuePairs
+func (_m *API) LogDebug(msg string, keyValuePairs ...interface{}) {
+ var _ca []interface{}
+ _ca = append(_ca, msg)
+ _ca = append(_ca, keyValuePairs...)
+ _m.Called(_ca...)
+}
+
+// LogError provides a mock function with given fields: msg, keyValuePairs
+func (_m *API) LogError(msg string, keyValuePairs ...interface{}) {
+ var _ca []interface{}
+ _ca = append(_ca, msg)
+ _ca = append(_ca, keyValuePairs...)
+ _m.Called(_ca...)
+}
+
+// LogInfo provides a mock function with given fields: msg, keyValuePairs
+func (_m *API) LogInfo(msg string, keyValuePairs ...interface{}) {
+ var _ca []interface{}
+ _ca = append(_ca, msg)
+ _ca = append(_ca, keyValuePairs...)
+ _m.Called(_ca...)
+}
+
+// LogWarn provides a mock function with given fields: msg, keyValuePairs
+func (_m *API) LogWarn(msg string, keyValuePairs ...interface{}) {
+ var _ca []interface{}
+ _ca = append(_ca, msg)
+ _ca = append(_ca, keyValuePairs...)
+ _m.Called(_ca...)
+}
+
+// PublishWebSocketEvent provides a mock function with given fields: event, payload, broadcast
+func (_m *API) PublishWebSocketEvent(event string, payload map[string]interface{}, broadcast *model.WebsocketBroadcast) {
+ _m.Called(event, payload, broadcast)
+}
+
// RegisterCommand provides a mock function with given fields: command
-func (_m *APIMOCKINTERNAL) RegisterCommand(command *model.Command) error {
+func (_m *API) RegisterCommand(command *model.Command) error {
ret := _m.Called(command)
var r0 error
@@ -537,8 +796,40 @@ func (_m *APIMOCKINTERNAL) RegisterCommand(command *model.Command) error {
return r0
}
+// SaveConfig provides a mock function with given fields: config
+func (_m *API) SaveConfig(config *model.Config) *model.AppError {
+ ret := _m.Called(config)
+
+ var r0 *model.AppError
+ if rf, ok := ret.Get(0).(func(*model.Config) *model.AppError); ok {
+ r0 = rf(config)
+ } else {
+ if ret.Get(0) != nil {
+ r0 = ret.Get(0).(*model.AppError)
+ }
+ }
+
+ return r0
+}
+
+// SendEphemeralPost provides a mock function with given fields: userId, post
+func (_m *API) SendEphemeralPost(userId string, post *model.Post) *model.Post {
+ ret := _m.Called(userId, post)
+
+ var r0 *model.Post
+ if rf, ok := ret.Get(0).(func(string, *model.Post) *model.Post); ok {
+ r0 = rf(userId, post)
+ } else {
+ if ret.Get(0) != nil {
+ r0 = ret.Get(0).(*model.Post)
+ }
+ }
+
+ return r0
+}
+
// UnregisterCommand provides a mock function with given fields: teamId, trigger
-func (_m *APIMOCKINTERNAL) UnregisterCommand(teamId string, trigger string) error {
+func (_m *API) UnregisterCommand(teamId string, trigger string) error {
ret := _m.Called(teamId, trigger)
var r0 error
@@ -552,7 +843,7 @@ func (_m *APIMOCKINTERNAL) UnregisterCommand(teamId string, trigger string) erro
}
// UpdateChannel provides a mock function with given fields: channel
-func (_m *APIMOCKINTERNAL) UpdateChannel(channel *model.Channel) (*model.Channel, *model.AppError) {
+func (_m *API) UpdateChannel(channel *model.Channel) (*model.Channel, *model.AppError) {
ret := _m.Called(channel)
var r0 *model.Channel
@@ -577,7 +868,7 @@ func (_m *APIMOCKINTERNAL) UpdateChannel(channel *model.Channel) (*model.Channel
}
// UpdateChannelMemberNotifications provides a mock function with given fields: channelId, userId, notifications
-func (_m *APIMOCKINTERNAL) UpdateChannelMemberNotifications(channelId string, userId string, notifications map[string]string) (*model.ChannelMember, *model.AppError) {
+func (_m *API) UpdateChannelMemberNotifications(channelId string, userId string, notifications map[string]string) (*model.ChannelMember, *model.AppError) {
ret := _m.Called(channelId, userId, notifications)
var r0 *model.ChannelMember
@@ -602,7 +893,7 @@ func (_m *APIMOCKINTERNAL) UpdateChannelMemberNotifications(channelId string, us
}
// UpdateChannelMemberRoles provides a mock function with given fields: channelId, userId, newRoles
-func (_m *APIMOCKINTERNAL) UpdateChannelMemberRoles(channelId string, userId string, newRoles string) (*model.ChannelMember, *model.AppError) {
+func (_m *API) UpdateChannelMemberRoles(channelId string, userId string, newRoles string) (*model.ChannelMember, *model.AppError) {
ret := _m.Called(channelId, userId, newRoles)
var r0 *model.ChannelMember
@@ -627,7 +918,7 @@ func (_m *APIMOCKINTERNAL) UpdateChannelMemberRoles(channelId string, userId str
}
// UpdatePost provides a mock function with given fields: post
-func (_m *APIMOCKINTERNAL) UpdatePost(post *model.Post) (*model.Post, *model.AppError) {
+func (_m *API) UpdatePost(post *model.Post) (*model.Post, *model.AppError) {
ret := _m.Called(post)
var r0 *model.Post
@@ -652,7 +943,7 @@ func (_m *APIMOCKINTERNAL) UpdatePost(post *model.Post) (*model.Post, *model.App
}
// UpdateTeam provides a mock function with given fields: team
-func (_m *APIMOCKINTERNAL) UpdateTeam(team *model.Team) (*model.Team, *model.AppError) {
+func (_m *API) UpdateTeam(team *model.Team) (*model.Team, *model.AppError) {
ret := _m.Called(team)
var r0 *model.Team
@@ -676,8 +967,33 @@ func (_m *APIMOCKINTERNAL) UpdateTeam(team *model.Team) (*model.Team, *model.App
return r0, r1
}
+// UpdateTeamMemberRoles provides a mock function with given fields: teamId, userId, newRoles
+func (_m *API) UpdateTeamMemberRoles(teamId string, userId string, newRoles string) (*model.TeamMember, *model.AppError) {
+ ret := _m.Called(teamId, userId, newRoles)
+
+ var r0 *model.TeamMember
+ if rf, ok := ret.Get(0).(func(string, string, string) *model.TeamMember); ok {
+ r0 = rf(teamId, userId, newRoles)
+ } else {
+ if ret.Get(0) != nil {
+ r0 = ret.Get(0).(*model.TeamMember)
+ }
+ }
+
+ var r1 *model.AppError
+ if rf, ok := ret.Get(1).(func(string, string, string) *model.AppError); ok {
+ r1 = rf(teamId, userId, newRoles)
+ } else {
+ if ret.Get(1) != nil {
+ r1 = ret.Get(1).(*model.AppError)
+ }
+ }
+
+ return r0, r1
+}
+
// UpdateUser provides a mock function with given fields: user
-func (_m *APIMOCKINTERNAL) UpdateUser(user *model.User) (*model.User, *model.AppError) {
+func (_m *API) UpdateUser(user *model.User) (*model.User, *model.AppError) {
ret := _m.Called(user)
var r0 *model.User
diff --git a/plugin/plugintest/apioverride.go b/plugin/plugintest/apioverride.go
deleted file mode 100644
index 54cfe27bc..000000000
--- a/plugin/plugintest/apioverride.go
+++ /dev/null
@@ -1,18 +0,0 @@
-// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
-// See LICENSE.txt for license information.
-
-package plugintest
-
-import "github.com/mattermost/mattermost-server/plugin"
-
-type API struct {
- APIMOCKINTERNAL
- Store *KeyValueStore
-}
-
-var _ plugin.API = (*API)(nil)
-var _ plugin.KeyValueStore = (*KeyValueStore)(nil)
-
-func (m *API) KeyValueStore() plugin.KeyValueStore {
- return m.Store
-}
diff --git a/plugin/plugintest/hooks.go b/plugin/plugintest/hooks.go
index 3de257c76..d88792f58 100644
--- a/plugin/plugintest/hooks.go
+++ b/plugin/plugintest/hooks.go
@@ -14,13 +14,18 @@ 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)
+// ChannelHasBeenCreated provides a mock function with given fields: c, channel
+func (_m *Hooks) ChannelHasBeenCreated(c *plugin.Context, channel *model.Channel) {
+ _m.Called(c, channel)
+}
+
+// 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)
@@ -28,8 +33,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)
@@ -39,23 +44,46 @@ func (_m *Hooks) ExecuteCommand(args *model.CommandArgs) (*model.CommandResponse
return r0, r1
}
-// MessageHasBeenPosted provides a mock function with given fields: post
-func (_m *Hooks) MessageHasBeenPosted(post *model.Post) {
- _m.Called(post)
+// Implemented provides a mock function with given fields:
+func (_m *Hooks) Implemented() ([]string, error) {
+ ret := _m.Called()
+
+ var r0 []string
+ if rf, ok := ret.Get(0).(func() []string); ok {
+ r0 = rf()
+ } else {
+ if ret.Get(0) != nil {
+ r0 = ret.Get(0).([]string)
+ }
+ }
+
+ var r1 error
+ if rf, ok := ret.Get(1).(func() error); ok {
+ r1 = rf()
+ } else {
+ r1 = ret.Error(1)
+ }
+
+ return r0, r1
}
-// MessageHasBeenUpdated provides a mock function with given fields: newPost, oldPost
-func (_m *Hooks) MessageHasBeenUpdated(newPost *model.Post, oldPost *model.Post) {
- _m.Called(newPost, oldPost)
+// MessageHasBeenPosted provides a mock function with given fields: c, post
+func (_m *Hooks) MessageHasBeenPosted(c *plugin.Context, post *model.Post) {
+ _m.Called(c, post)
}
-// MessageWillBePosted provides a mock function with given fields: post
-func (_m *Hooks) MessageWillBePosted(post *model.Post) (*model.Post, string) {
- ret := _m.Called(post)
+// 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: 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)
@@ -63,8 +91,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)
}
@@ -72,13 +100,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)
@@ -86,8 +114,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)
}
@@ -95,13 +123,13 @@ func (_m *Hooks) MessageWillBeUpdated(newPost *model.Post, oldPost *model.Post)
return r0, r1
}
-// OnActivate provides a mock function with given fields: _a0
-func (_m *Hooks) OnActivate(_a0 plugin.API) error {
- ret := _m.Called(_a0)
+// OnActivate provides a mock function with given fields:
+func (_m *Hooks) OnActivate() error {
+ ret := _m.Called()
var r0 error
- if rf, ok := ret.Get(0).(func(plugin.API) error); ok {
- r0 = rf(_a0)
+ if rf, ok := ret.Get(0).(func() error); ok {
+ r0 = rf()
} else {
r0 = ret.Error(0)
}
@@ -137,7 +165,27 @@ func (_m *Hooks) OnDeactivate() error {
return r0
}
-// ServeHTTP provides a mock function with given fields: _a0, _a1
-func (_m *Hooks) ServeHTTP(_a0 http.ResponseWriter, _a1 *http.Request) {
- _m.Called(_a0, _a1)
+// 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)
+}
+
+// UserHasJoinedChannel provides a mock function with given fields: c, channelMember, actor
+func (_m *Hooks) UserHasJoinedChannel(c *plugin.Context, channelMember *model.ChannelMember, actor *model.User) {
+ _m.Called(c, channelMember, actor)
+}
+
+// UserHasJoinedTeam provides a mock function with given fields: c, teamMember, actor
+func (_m *Hooks) UserHasJoinedTeam(c *plugin.Context, teamMember *model.TeamMember, actor *model.User) {
+ _m.Called(c, teamMember, actor)
+}
+
+// UserHasLeftChannel provides a mock function with given fields: c, channelMember, actor
+func (_m *Hooks) UserHasLeftChannel(c *plugin.Context, channelMember *model.ChannelMember, actor *model.User) {
+ _m.Called(c, channelMember, actor)
+}
+
+// UserHasLeftTeam provides a mock function with given fields: c, teamMember, actor
+func (_m *Hooks) UserHasLeftTeam(c *plugin.Context, teamMember *model.TeamMember, actor *model.User) {
+ _m.Called(c, teamMember, actor)
}
diff --git a/plugin/plugintest/key_value_store.go b/plugin/plugintest/key_value_store.go
deleted file mode 100644
index 30d60d708..000000000
--- a/plugin/plugintest/key_value_store.go
+++ /dev/null
@@ -1,70 +0,0 @@
-// Code generated by mockery v1.0.0. DO NOT EDIT.
-
-// Regenerate this file using `make plugin-mocks`.
-
-package plugintest
-
-import mock "github.com/stretchr/testify/mock"
-import model "github.com/mattermost/mattermost-server/model"
-
-// KeyValueStore is an autogenerated mock type for the KeyValueStore type
-type KeyValueStore struct {
- mock.Mock
-}
-
-// Delete provides a mock function with given fields: key
-func (_m *KeyValueStore) Delete(key string) *model.AppError {
- ret := _m.Called(key)
-
- var r0 *model.AppError
- if rf, ok := ret.Get(0).(func(string) *model.AppError); ok {
- r0 = rf(key)
- } else {
- if ret.Get(0) != nil {
- r0 = ret.Get(0).(*model.AppError)
- }
- }
-
- return r0
-}
-
-// Get provides a mock function with given fields: key
-func (_m *KeyValueStore) Get(key string) ([]byte, *model.AppError) {
- ret := _m.Called(key)
-
- var r0 []byte
- if rf, ok := ret.Get(0).(func(string) []byte); ok {
- r0 = rf(key)
- } else {
- if ret.Get(0) != nil {
- r0 = ret.Get(0).([]byte)
- }
- }
-
- var r1 *model.AppError
- if rf, ok := ret.Get(1).(func(string) *model.AppError); ok {
- r1 = rf(key)
- } else {
- if ret.Get(1) != nil {
- r1 = ret.Get(1).(*model.AppError)
- }
- }
-
- return r0, r1
-}
-
-// Set provides a mock function with given fields: key, value
-func (_m *KeyValueStore) Set(key string, value []byte) *model.AppError {
- ret := _m.Called(key, value)
-
- var r0 *model.AppError
- if rf, ok := ret.Get(0).(func(string, []byte) *model.AppError); ok {
- r0 = rf(key, value)
- } else {
- if ret.Get(0) != nil {
- r0 = ret.Get(0).(*model.AppError)
- }
- }
-
- return r0
-}