diff options
Diffstat (limited to 'plugin/plugintest/api.go')
-rw-r--r-- | plugin/plugintest/api.go | 396 |
1 files changed, 356 insertions, 40 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 |