summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristopher Speller <crspeller@gmail.com>2018-07-18 16:35:12 -0700
committerGitHub <noreply@github.com>2018-07-18 16:35:12 -0700
commit5a2d46c6cbf992c8a8f155b27eb3b60807d8aed2 (patch)
tree621ce2faf53d998a783891d31bbd46ec40772338
parent309a3dda605dbda6b9f6f769ea386764671ea5d3 (diff)
downloadchat-5a2d46c6cbf992c8a8f155b27eb3b60807d8aed2.tar.gz
chat-5a2d46c6cbf992c8a8f155b27eb3b60807d8aed2.tar.bz2
chat-5a2d46c6cbf992c8a8f155b27eb3b60807d8aed2.zip
MM-11028 Adding some plugin tests. (#9103)
* Rearranging plugin mocks and moving some common test code out. * Adding tests. * Fixing tests after GoDoc cleanup changes.
-rw-r--r--Makefile1
-rw-r--r--app/plugin_api_test.go149
-rw-r--r--app/plugin_hooks_test.go304
-rw-r--r--plugin/mock_api_test.go1093
-rw-r--r--plugin/supervisor_test.go44
5 files changed, 453 insertions, 1138 deletions
diff --git a/Makefile b/Makefile
index a5e14bc5a..2782fbc9c 100644
--- a/Makefile
+++ b/Makefile
@@ -285,7 +285,6 @@ ldap-mocks: ## Creates mock files for ldap.
plugin-mocks: ## Creates mock files for plugins.
go get github.com/vektra/mockery/...
$(GOPATH)/bin/mockery -dir plugin -name API -output plugin/plugintest -outpkg plugintest -case underscore -note 'Regenerate this file using `make plugin-mocks`.'
- $(GOPATH)/bin/mockery -dir plugin -name API -inpkg -output plugin -testonly -outpkg plugin -case underscore -note 'Regenerate this file using `make plugin-mocks`.'
$(GOPATH)/bin/mockery -dir plugin -name Hooks -output plugin/plugintest -outpkg plugintest -case underscore -note 'Regenerate this file using `make plugin-mocks`.'
pluginapi: ## Generates api and hooks glue code for plugins
diff --git a/app/plugin_api_test.go b/app/plugin_api_test.go
index 56507a8f7..618805bb6 100644
--- a/app/plugin_api_test.go
+++ b/app/plugin_api_test.go
@@ -4,14 +4,38 @@
package app
import (
+ "encoding/json"
+ "io/ioutil"
+ "os"
+ "path/filepath"
"testing"
+ "github.com/mattermost/mattermost-server/model"
+ "github.com/mattermost/mattermost-server/plugin"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
-
- "github.com/mattermost/mattermost-server/model"
)
+func setupPluginApiTest(t *testing.T, pluginCode string, pluginManifest string, pluginId string, app *App) {
+ pluginDir, err := ioutil.TempDir("", "")
+ require.NoError(t, err)
+ webappPluginDir, err := ioutil.TempDir("", "")
+ require.NoError(t, err)
+ defer os.RemoveAll(pluginDir)
+ defer os.RemoveAll(webappPluginDir)
+
+ env, err := plugin.NewEnvironment(app.NewPluginAPI, pluginDir, webappPluginDir, app.Log)
+ require.NoError(t, err)
+
+ backend := filepath.Join(pluginDir, pluginId, "backend.exe")
+ compileGo(t, pluginCode, backend)
+
+ ioutil.WriteFile(filepath.Join(pluginDir, pluginId, "plugin.json"), []byte(pluginManifest), 0600)
+ env.Activate(pluginId)
+
+ app.Plugins = env
+}
+
func TestPluginAPIUpdateUserStatus(t *testing.T) {
th := Setup().InitBasic()
defer th.TearDown()
@@ -30,3 +54,124 @@ func TestPluginAPIUpdateUserStatus(t *testing.T) {
assert.NotNil(t, err)
assert.Nil(t, status)
}
+
+func TestPluginAPILoadPluginConfiguration(t *testing.T) {
+ th := Setup().InitBasic()
+ defer th.TearDown()
+
+ var pluginJson map[string]interface{}
+ if err := json.Unmarshal([]byte(`{"mystringsetting": "str", "MyIntSetting": 32, "myboolsetting": true}`), &pluginJson); err != nil {
+ t.Fatal(err)
+ }
+ th.App.UpdateConfig(func(cfg *model.Config) {
+ cfg.PluginSettings.Plugins["testloadpluginconfig"] = pluginJson
+ })
+ setupPluginApiTest(t,
+ `
+ package main
+
+ import (
+ "github.com/mattermost/mattermost-server/plugin"
+ "github.com/mattermost/mattermost-server/model"
+ "fmt"
+ )
+
+ type MyPlugin struct {
+ plugin.MattermostPlugin
+
+ MyStringSetting string
+ MyIntSetting int
+ MyBoolSetting bool
+ }
+
+ func (p *MyPlugin) MessageWillBePosted(c *plugin.Context, post *model.Post) (*model.Post, string) {
+ return nil, fmt.Sprintf("%v%v%v", p.MyStringSetting, p.MyIntSetting, p.MyBoolSetting)
+ }
+
+ func main() {
+ plugin.ClientMain(&MyPlugin{})
+ }
+ `,
+ `{"id": "testloadpluginconfig", "backend": {"executable": "backend.exe"}, "settings_schema": {
+ "settings": [
+ {
+ "key": "MyStringSetting",
+ "type": "text"
+ },
+ {
+ "key": "MyIntSetting",
+ "type": "text"
+ },
+ {
+ "key": "MyBoolSetting",
+ "type": "bool"
+ }
+ ]
+ }}`, "testloadpluginconfig", th.App)
+ hooks, err := th.App.Plugins.HooksForPlugin("testloadpluginconfig")
+ assert.NoError(t, err)
+ _, ret := hooks.MessageWillBePosted(nil, nil)
+ assert.Equal(t, "str32true", ret)
+}
+
+func TestPluginAPILoadPluginConfigurationDefaults(t *testing.T) {
+ th := Setup().InitBasic()
+ defer th.TearDown()
+
+ var pluginJson map[string]interface{}
+ if err := json.Unmarshal([]byte(`{"mystringsetting": "override"}`), &pluginJson); err != nil {
+ t.Fatal(err)
+ }
+ th.App.UpdateConfig(func(cfg *model.Config) {
+ cfg.PluginSettings.Plugins["testloadpluginconfig"] = pluginJson
+ })
+ setupPluginApiTest(t,
+ `
+ package main
+
+ import (
+ "github.com/mattermost/mattermost-server/plugin"
+ "github.com/mattermost/mattermost-server/model"
+ "fmt"
+ )
+
+ type MyPlugin struct {
+ plugin.MattermostPlugin
+
+ MyStringSetting string
+ MyIntSetting int
+ MyBoolSetting bool
+ }
+
+ func (p *MyPlugin) MessageWillBePosted(c *plugin.Context, post *model.Post) (*model.Post, string) {
+ return nil, fmt.Sprintf("%v%v%v", p.MyStringSetting, p.MyIntSetting, p.MyBoolSetting)
+ }
+
+ func main() {
+ plugin.ClientMain(&MyPlugin{})
+ }
+ `,
+ `{"id": "testloadpluginconfig", "backend": {"executable": "backend.exe"}, "settings_schema": {
+ "settings": [
+ {
+ "key": "MyStringSetting",
+ "type": "text",
+ "default": "notthis"
+ },
+ {
+ "key": "MyIntSetting",
+ "type": "text",
+ "default": 35
+ },
+ {
+ "key": "MyBoolSetting",
+ "type": "bool",
+ "default": true
+ }
+ ]
+ }}`, "testloadpluginconfig", th.App)
+ hooks, err := th.App.Plugins.HooksForPlugin("testloadpluginconfig")
+ assert.NoError(t, err)
+ _, ret := hooks.MessageWillBePosted(nil, nil)
+ assert.Equal(t, "override35true", ret)
+}
diff --git a/app/plugin_hooks_test.go b/app/plugin_hooks_test.go
new file mode 100644
index 000000000..4b4e657ef
--- /dev/null
+++ b/app/plugin_hooks_test.go
@@ -0,0 +1,304 @@
+// Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved.
+// See License.txt for license information.
+
+package app
+
+import (
+ "io/ioutil"
+ "os"
+ "os/exec"
+ "path/filepath"
+ "testing"
+
+ "github.com/mattermost/mattermost-server/model"
+ "github.com/mattermost/mattermost-server/plugin"
+ "github.com/mattermost/mattermost-server/plugin/plugintest"
+ "github.com/mattermost/mattermost-server/plugin/plugintest/mock"
+ "github.com/stretchr/testify/assert"
+ "github.com/stretchr/testify/require"
+)
+
+func compileGo(t *testing.T, sourceCode, outputPath string) {
+ dir, err := ioutil.TempDir(".", "")
+ require.NoError(t, err)
+ defer os.RemoveAll(dir)
+ require.NoError(t, ioutil.WriteFile(filepath.Join(dir, "main.go"), []byte(sourceCode), 0600))
+ cmd := exec.Command("go", "build", "-o", outputPath, "main.go")
+ cmd.Dir = dir
+ cmd.Stdout = os.Stdout
+ cmd.Stderr = os.Stderr
+ require.NoError(t, cmd.Run())
+}
+
+func SetAppEnvironmentWithPlugins(t *testing.T, pluginCode []string, app *App, apiFunc func(*model.Manifest) plugin.API) {
+ pluginDir, err := ioutil.TempDir("", "")
+ require.NoError(t, err)
+ webappPluginDir, err := ioutil.TempDir("", "")
+ require.NoError(t, err)
+ defer os.RemoveAll(pluginDir)
+ defer os.RemoveAll(webappPluginDir)
+
+ env, err := plugin.NewEnvironment(apiFunc, pluginDir, webappPluginDir, app.Log)
+ require.NoError(t, err)
+
+ for _, code := range pluginCode {
+ pluginId := model.NewId()
+ backend := filepath.Join(pluginDir, pluginId, "backend.exe")
+ compileGo(t, code, backend)
+
+ ioutil.WriteFile(filepath.Join(pluginDir, pluginId, "plugin.json"), []byte(`{"id": "`+pluginId+`", "backend": {"executable": "backend.exe"}}`), 0600)
+ env.Activate(pluginId)
+ }
+
+ app.Plugins = env
+}
+
+func TestHookMessageWillBePosted(t *testing.T) {
+ th := Setup().InitBasic()
+ defer th.TearDown()
+
+ SetAppEnvironmentWithPlugins(t,
+ []string{
+ `
+ package main
+
+ import (
+ "github.com/mattermost/mattermost-server/plugin"
+ "github.com/mattermost/mattermost-server/model"
+ )
+
+ type MyPlugin struct {
+ plugin.MattermostPlugin
+ }
+
+ func (p *MyPlugin) MessageWillBePosted(c *plugin.Context, post *model.Post) (*model.Post, string) {
+ post.Message = post.Message + "fromplugin"
+ return post, ""
+ }
+
+ func main() {
+ plugin.ClientMain(&MyPlugin{})
+ }
+ `}, th.App, th.App.NewPluginAPI)
+
+ post := &model.Post{
+ UserId: th.BasicUser.Id,
+ ChannelId: th.BasicChannel.Id,
+ Message: "message_",
+ CreateAt: model.GetMillis() - 10000,
+ }
+ post, err := th.App.CreatePost(post, th.BasicChannel, false)
+ if err != nil {
+ t.Fatal(err)
+ }
+ assert.Equal(t, "message_fromplugin", post.Message)
+ if result := <-th.App.Srv.Store.Post().GetSingle(post.Id); result.Err != nil {
+ t.Fatal(err)
+ } else {
+ assert.Equal(t, "message_fromplugin", result.Data.(*model.Post).Message)
+ }
+}
+
+func TestHookMessageWillBePostedMultiple(t *testing.T) {
+ th := Setup().InitBasic()
+ defer th.TearDown()
+
+ SetAppEnvironmentWithPlugins(t,
+ []string{
+ `
+ package main
+
+ import (
+ "github.com/mattermost/mattermost-server/plugin"
+ "github.com/mattermost/mattermost-server/model"
+ )
+
+ type MyPlugin struct {
+ plugin.MattermostPlugin
+ }
+
+ func (p *MyPlugin) MessageWillBePosted(c *plugin.Context, post *model.Post) (*model.Post, string) {
+
+ post.Message = "prefix_" + post.Message
+ return post, ""
+ }
+
+ func main() {
+ plugin.ClientMain(&MyPlugin{})
+ }
+ `,
+ `
+ package main
+
+ import (
+ "github.com/mattermost/mattermost-server/plugin"
+ "github.com/mattermost/mattermost-server/model"
+ )
+
+ type MyPlugin struct {
+ plugin.MattermostPlugin
+ }
+
+ func (p *MyPlugin) MessageWillBePosted(c *plugin.Context, post *model.Post) (*model.Post, string) {
+ post.Message = post.Message + "_suffix"
+ return post, ""
+ }
+
+ func main() {
+ plugin.ClientMain(&MyPlugin{})
+ }
+ `,
+ }, th.App, th.App.NewPluginAPI)
+
+ post := &model.Post{
+ UserId: th.BasicUser.Id,
+ ChannelId: th.BasicChannel.Id,
+ Message: "message",
+ CreateAt: model.GetMillis() - 10000,
+ }
+ post, err := th.App.CreatePost(post, th.BasicChannel, false)
+ if err != nil {
+ t.Fatal(err)
+ }
+ assert.Equal(t, "prefix_message_suffix", post.Message)
+}
+
+func TestHookMessageHasBeenPosted(t *testing.T) {
+ th := Setup().InitBasic()
+ defer th.TearDown()
+
+ var mockAPI plugintest.API
+ mockAPI.On("LoadPluginConfiguration", mock.Anything).Return(nil)
+ mockAPI.On("DeleteUser", "message").Return(nil)
+
+ SetAppEnvironmentWithPlugins(t,
+ []string{
+ `
+ package main
+
+ import (
+ "github.com/mattermost/mattermost-server/plugin"
+ "github.com/mattermost/mattermost-server/model"
+ )
+
+ type MyPlugin struct {
+ plugin.MattermostPlugin
+ }
+
+ func (p *MyPlugin) MessageHasBeenPosted(c *plugin.Context, post *model.Post) {
+ p.API.DeleteUser(post.Message)
+ }
+
+ func main() {
+ plugin.ClientMain(&MyPlugin{})
+ }
+ `}, th.App, func(*model.Manifest) plugin.API { return &mockAPI })
+
+ post := &model.Post{
+ UserId: th.BasicUser.Id,
+ ChannelId: th.BasicChannel.Id,
+ Message: "message",
+ CreateAt: model.GetMillis() - 10000,
+ }
+ post, err := th.App.CreatePost(post, th.BasicChannel, false)
+ if err != nil {
+ t.Fatal(err)
+ }
+}
+
+func TestHookMessageWillBeUpdated(t *testing.T) {
+ th := Setup().InitBasic()
+ defer th.TearDown()
+
+ SetAppEnvironmentWithPlugins(t,
+ []string{
+ `
+ package main
+
+ import (
+ "github.com/mattermost/mattermost-server/plugin"
+ "github.com/mattermost/mattermost-server/model"
+ )
+
+ type MyPlugin struct {
+ plugin.MattermostPlugin
+ }
+
+ func (p *MyPlugin) MessageWillBeUpdated(c *plugin.Context, newPost, oldPost *model.Post) (*model.Post, string) {
+ newPost.Message = newPost.Message + "fromplugin"
+ return newPost, ""
+ }
+
+ func main() {
+ plugin.ClientMain(&MyPlugin{})
+ }
+ `}, th.App, th.App.NewPluginAPI)
+
+ post := &model.Post{
+ UserId: th.BasicUser.Id,
+ ChannelId: th.BasicChannel.Id,
+ Message: "message_",
+ CreateAt: model.GetMillis() - 10000,
+ }
+ post, err := th.App.CreatePost(post, th.BasicChannel, false)
+ if err != nil {
+ t.Fatal(err)
+ }
+ assert.Equal(t, "message_", post.Message)
+ post.Message = post.Message + "edited_"
+ post, err = th.App.UpdatePost(post, true)
+ if err != nil {
+ t.Fatal(err)
+ }
+ assert.Equal(t, "message_edited_fromplugin", post.Message)
+}
+
+func TestHookMessageHasBeenUpdated(t *testing.T) {
+ th := Setup().InitBasic()
+ defer th.TearDown()
+
+ var mockAPI plugintest.API
+ mockAPI.On("LoadPluginConfiguration", mock.Anything).Return(nil)
+ mockAPI.On("DeleteUser", "message_edited").Return(nil)
+ mockAPI.On("DeleteTeam", "message_").Return(nil)
+ SetAppEnvironmentWithPlugins(t,
+ []string{
+ `
+ package main
+
+ import (
+ "github.com/mattermost/mattermost-server/plugin"
+ "github.com/mattermost/mattermost-server/model"
+ )
+
+ type MyPlugin struct {
+ plugin.MattermostPlugin
+ }
+
+ func (p *MyPlugin) MessageHasBeenUpdated(c *plugin.Context, newPost, oldPost *model.Post) {
+ p.API.DeleteUser(newPost.Message)
+ p.API.DeleteTeam(oldPost.Message)
+ }
+
+ func main() {
+ plugin.ClientMain(&MyPlugin{})
+ }
+ `}, th.App, func(*model.Manifest) plugin.API { return &mockAPI })
+
+ post := &model.Post{
+ UserId: th.BasicUser.Id,
+ ChannelId: th.BasicChannel.Id,
+ Message: "message_",
+ CreateAt: model.GetMillis() - 10000,
+ }
+ post, err := th.App.CreatePost(post, th.BasicChannel, false)
+ if err != nil {
+ t.Fatal(err)
+ }
+ assert.Equal(t, "message_", post.Message)
+ post.Message = post.Message + "edited"
+ post, err = th.App.UpdatePost(post, true)
+ if err != nil {
+ t.Fatal(err)
+ }
+}
diff --git a/plugin/mock_api_test.go b/plugin/mock_api_test.go
deleted file mode 100644
index 07b1c1277..000000000
--- a/plugin/mock_api_test.go
+++ /dev/null
@@ -1,1093 +0,0 @@
-// Code generated by mockery v1.0.0
-
-// Regenerate this file using `make plugin-mocks`.
-
-package plugin
-
-import mock "github.com/stretchr/testify/mock"
-import model "github.com/mattermost/mattermost-server/model"
-
-// MockAPI is an autogenerated mock type for the API type
-type MockAPI struct {
- mock.Mock
-}
-
-// AddChannelMember provides a mock function with given fields: channelId, userId
-func (_m *MockAPI) AddChannelMember(channelId string, userId string) (*model.ChannelMember, *model.AppError) {
- ret := _m.Called(channelId, userId)
-
- var r0 *model.ChannelMember
- if rf, ok := ret.Get(0).(func(string, string) *model.ChannelMember); ok {
- r0 = rf(channelId, userId)
- } else {
- if ret.Get(0) != nil {
- r0 = ret.Get(0).(*model.ChannelMember)
- }
- }
-
- var r1 *model.AppError
- if rf, ok := ret.Get(1).(func(string, string) *model.AppError); ok {
- r1 = rf(channelId, userId)
- } else {
- if ret.Get(1) != nil {
- r1 = ret.Get(1).(*model.AppError)
- }
- }
-
- return r0, r1
-}
-
-// CreateChannel provides a mock function with given fields: channel
-func (_m *MockAPI) CreateChannel(channel *model.Channel) (*model.Channel, *model.AppError) {
- ret := _m.Called(channel)
-
- var r0 *model.Channel
- if rf, ok := ret.Get(0).(func(*model.Channel) *model.Channel); ok {
- r0 = rf(channel)
- } else {
- if ret.Get(0) != nil {
- r0 = ret.Get(0).(*model.Channel)
- }
- }
-
- var r1 *model.AppError
- if rf, ok := ret.Get(1).(func(*model.Channel) *model.AppError); ok {
- r1 = rf(channel)
- } else {
- if ret.Get(1) != nil {
- r1 = ret.Get(1).(*model.AppError)
- }
- }
-
- return r0, r1
-}
-
-// CreatePost provides a mock function with given fields: post
-func (_m *MockAPI) CreatePost(post *model.Post) (*model.Post, *model.AppError) {
- ret := _m.Called(post)
-
- var r0 *model.Post
- if rf, ok := ret.Get(0).(func(*model.Post) *model.Post); ok {
- r0 = rf(post)
- } else {
- if ret.Get(0) != nil {
- r0 = ret.Get(0).(*model.Post)
- }
- }
-
- var r1 *model.AppError
- if rf, ok := ret.Get(1).(func(*model.Post) *model.AppError); ok {
- r1 = rf(post)
- } else {
- if ret.Get(1) != nil {
- r1 = ret.Get(1).(*model.AppError)
- }
- }
-
- return r0, r1
-}
-
-// CreateTeam provides a mock function with given fields: team
-func (_m *MockAPI) CreateTeam(team *model.Team) (*model.Team, *model.AppError) {
- ret := _m.Called(team)
-
- var r0 *model.Team
- if rf, ok := ret.Get(0).(func(*model.Team) *model.Team); ok {
- r0 = rf(team)
- } else {
- if ret.Get(0) != nil {
- r0 = ret.Get(0).(*model.Team)
- }
- }
-
- var r1 *model.AppError
- if rf, ok := ret.Get(1).(func(*model.Team) *model.AppError); ok {
- r1 = rf(team)
- } else {
- if ret.Get(1) != nil {
- r1 = ret.Get(1).(*model.AppError)
- }
- }
-
- return r0, r1
-}
-
-// CreateTeamMember provides a mock function with given fields: teamId, userId
-func (_m *MockAPI) 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 *MockAPI) 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 *MockAPI) CreateUser(user *model.User) (*model.User, *model.AppError) {
- ret := _m.Called(user)
-
- var r0 *model.User
- if rf, ok := ret.Get(0).(func(*model.User) *model.User); ok {
- r0 = rf(user)
- } else {
- if ret.Get(0) != nil {
- r0 = ret.Get(0).(*model.User)
- }
- }
-
- var r1 *model.AppError
- if rf, ok := ret.Get(1).(func(*model.User) *model.AppError); ok {
- r1 = rf(user)
- } else {
- if ret.Get(1) != nil {
- r1 = ret.Get(1).(*model.AppError)
- }
- }
-
- return r0, r1
-}
-
-// DeleteChannel provides a mock function with given fields: channelId
-func (_m *MockAPI) DeleteChannel(channelId string) *model.AppError {
- ret := _m.Called(channelId)
-
- var r0 *model.AppError
- if rf, ok := ret.Get(0).(func(string) *model.AppError); ok {
- r0 = rf(channelId)
- } else {
- if ret.Get(0) != nil {
- r0 = ret.Get(0).(*model.AppError)
- }
- }
-
- return r0
-}
-
-// DeleteChannelMember provides a mock function with given fields: channelId, userId
-func (_m *MockAPI) DeleteChannelMember(channelId string, userId string) *model.AppError {
- ret := _m.Called(channelId, userId)
-
- var r0 *model.AppError
- if rf, ok := ret.Get(0).(func(string, string) *model.AppError); ok {
- r0 = rf(channelId, userId)
- } else {
- if ret.Get(0) != nil {
- r0 = ret.Get(0).(*model.AppError)
- }
- }
-
- return r0
-}
-
-// DeletePost provides a mock function with given fields: postId
-func (_m *MockAPI) DeletePost(postId string) *model.AppError {
- ret := _m.Called(postId)
-
- var r0 *model.AppError
- if rf, ok := ret.Get(0).(func(string) *model.AppError); ok {
- r0 = rf(postId)
- } else {
- if ret.Get(0) != nil {
- r0 = ret.Get(0).(*model.AppError)
- }
- }
-
- return r0
-}
-
-// DeleteTeam provides a mock function with given fields: teamId
-func (_m *MockAPI) DeleteTeam(teamId string) *model.AppError {
- ret := _m.Called(teamId)
-
- var r0 *model.AppError
- if rf, ok := ret.Get(0).(func(string) *model.AppError); ok {
- r0 = rf(teamId)
- } else {
- if ret.Get(0) != nil {
- r0 = ret.Get(0).(*model.AppError)
- }
- }
-
- return r0
-}
-
-// DeleteTeamMember provides a mock function with given fields: teamId, userId, requestorId
-func (_m *MockAPI) 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 *MockAPI) DeleteUser(userId string) *model.AppError {
- ret := _m.Called(userId)
-
- var r0 *model.AppError
- if rf, ok := ret.Get(0).(func(string) *model.AppError); ok {
- r0 = rf(userId)
- } else {
- if ret.Get(0) != nil {
- r0 = ret.Get(0).(*model.AppError)
- }
- }
-
- return r0
-}
-
-// GetChannel provides a mock function with given fields: channelId
-func (_m *MockAPI) GetChannel(channelId string) (*model.Channel, *model.AppError) {
- ret := _m.Called(channelId)
-
- var r0 *model.Channel
- if rf, ok := ret.Get(0).(func(string) *model.Channel); ok {
- r0 = rf(channelId)
- } else {
- if ret.Get(0) != nil {
- r0 = ret.Get(0).(*model.Channel)
- }
- }
-
- var r1 *model.AppError
- if rf, ok := ret.Get(1).(func(string) *model.AppError); ok {
- r1 = rf(channelId)
- } else {
- if ret.Get(1) != nil {
- r1 = ret.Get(1).(*model.AppError)
- }
- }
-
- return r0, r1
-}
-
-// GetChannelByName provides a mock function with given fields: name, teamId
-func (_m *MockAPI) GetChannelByName(name string, teamId string) (*model.Channel, *model.AppError) {
- ret := _m.Called(name, teamId)
-
- var r0 *model.Channel
- if rf, ok := ret.Get(0).(func(string, string) *model.Channel); ok {
- r0 = rf(name, teamId)
- } else {
- if ret.Get(0) != nil {
- r0 = ret.Get(0).(*model.Channel)
- }
- }
-
- var r1 *model.AppError
- if rf, ok := ret.Get(1).(func(string, string) *model.AppError); ok {
- r1 = rf(name, teamId)
- } else {
- if ret.Get(1) != nil {
- r1 = ret.Get(1).(*model.AppError)
- }
- }
-
- return r0, r1
-}
-
-// GetChannelMember provides a mock function with given fields: channelId, userId
-func (_m *MockAPI) GetChannelMember(channelId string, userId string) (*model.ChannelMember, *model.AppError) {
- ret := _m.Called(channelId, userId)
-
- var r0 *model.ChannelMember
- if rf, ok := ret.Get(0).(func(string, string) *model.ChannelMember); ok {
- r0 = rf(channelId, userId)
- } else {
- if ret.Get(0) != nil {
- r0 = ret.Get(0).(*model.ChannelMember)
- }
- }
-
- var r1 *model.AppError
- if rf, ok := ret.Get(1).(func(string, string) *model.AppError); ok {
- r1 = rf(channelId, userId)
- } else {
- if ret.Get(1) != nil {
- r1 = ret.Get(1).(*model.AppError)
- }
- }
-
- return r0, r1
-}
-
-// GetConfig provides a mock function with given fields:
-func (_m *MockAPI) 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 *MockAPI) GetDirectChannel(userId1 string, userId2 string) (*model.Channel, *model.AppError) {
- ret := _m.Called(userId1, userId2)
-
- var r0 *model.Channel
- if rf, ok := ret.Get(0).(func(string, string) *model.Channel); ok {
- r0 = rf(userId1, userId2)
- } else {
- if ret.Get(0) != nil {
- r0 = ret.Get(0).(*model.Channel)
- }
- }
-
- var r1 *model.AppError
- if rf, ok := ret.Get(1).(func(string, string) *model.AppError); ok {
- r1 = rf(userId1, userId2)
- } else {
- if ret.Get(1) != nil {
- r1 = ret.Get(1).(*model.AppError)
- }
- }
-
- return r0, r1
-}
-
-// GetGroupChannel provides a mock function with given fields: userIds
-func (_m *MockAPI) GetGroupChannel(userIds []string) (*model.Channel, *model.AppError) {
- ret := _m.Called(userIds)
-
- var r0 *model.Channel
- if rf, ok := ret.Get(0).(func([]string) *model.Channel); ok {
- r0 = rf(userIds)
- } else {
- if ret.Get(0) != nil {
- r0 = ret.Get(0).(*model.Channel)
- }
- }
-
- var r1 *model.AppError
- if rf, ok := ret.Get(1).(func([]string) *model.AppError); ok {
- r1 = rf(userIds)
- } else {
- if ret.Get(1) != nil {
- r1 = ret.Get(1).(*model.AppError)
- }
- }
-
- return r0, r1
-}
-
-// GetPost provides a mock function with given fields: postId
-func (_m *MockAPI) GetPost(postId string) (*model.Post, *model.AppError) {
- ret := _m.Called(postId)
-
- var r0 *model.Post
- if rf, ok := ret.Get(0).(func(string) *model.Post); ok {
- r0 = rf(postId)
- } else {
- if ret.Get(0) != nil {
- r0 = ret.Get(0).(*model.Post)
- }
- }
-
- var r1 *model.AppError
- if rf, ok := ret.Get(1).(func(string) *model.AppError); ok {
- r1 = rf(postId)
- } else {
- if ret.Get(1) != nil {
- r1 = ret.Get(1).(*model.AppError)
- }
- }
-
- return r0, r1
-}
-
-// GetPublicChannelsForTeam provides a mock function with given fields: teamId, offset, limit
-func (_m *MockAPI) 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 *MockAPI) GetTeam(teamId string) (*model.Team, *model.AppError) {
- ret := _m.Called(teamId)
-
- var r0 *model.Team
- if rf, ok := ret.Get(0).(func(string) *model.Team); ok {
- r0 = rf(teamId)
- } else {
- if ret.Get(0) != nil {
- r0 = ret.Get(0).(*model.Team)
- }
- }
-
- var r1 *model.AppError
- if rf, ok := ret.Get(1).(func(string) *model.AppError); ok {
- r1 = rf(teamId)
- } else {
- if ret.Get(1) != nil {
- r1 = ret.Get(1).(*model.AppError)
- }
- }
-
- return r0, r1
-}
-
-// GetTeamByName provides a mock function with given fields: name
-func (_m *MockAPI) GetTeamByName(name string) (*model.Team, *model.AppError) {
- ret := _m.Called(name)
-
- var r0 *model.Team
- if rf, ok := ret.Get(0).(func(string) *model.Team); ok {
- r0 = rf(name)
- } else {
- if ret.Get(0) != nil {
- r0 = ret.Get(0).(*model.Team)
- }
- }
-
- var r1 *model.AppError
- if rf, ok := ret.Get(1).(func(string) *model.AppError); ok {
- r1 = rf(name)
- } else {
- if ret.Get(1) != nil {
- r1 = ret.Get(1).(*model.AppError)
- }
- }
-
- return r0, r1
-}
-
-// GetTeamMember provides a mock function with given fields: teamId, userId
-func (_m *MockAPI) 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 *MockAPI) 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 *MockAPI) 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 *MockAPI) GetUser(userId string) (*model.User, *model.AppError) {
- ret := _m.Called(userId)
-
- var r0 *model.User
- if rf, ok := ret.Get(0).(func(string) *model.User); ok {
- r0 = rf(userId)
- } else {
- if ret.Get(0) != nil {
- r0 = ret.Get(0).(*model.User)
- }
- }
-
- var r1 *model.AppError
- if rf, ok := ret.Get(1).(func(string) *model.AppError); ok {
- r1 = rf(userId)
- } else {
- if ret.Get(1) != nil {
- r1 = ret.Get(1).(*model.AppError)
- }
- }
-
- return r0, r1
-}
-
-// GetUserByEmail provides a mock function with given fields: email
-func (_m *MockAPI) GetUserByEmail(email string) (*model.User, *model.AppError) {
- ret := _m.Called(email)
-
- var r0 *model.User
- if rf, ok := ret.Get(0).(func(string) *model.User); ok {
- r0 = rf(email)
- } else {
- if ret.Get(0) != nil {
- r0 = ret.Get(0).(*model.User)
- }
- }
-
- var r1 *model.AppError
- if rf, ok := ret.Get(1).(func(string) *model.AppError); ok {
- r1 = rf(email)
- } else {
- if ret.Get(1) != nil {
- r1 = ret.Get(1).(*model.AppError)
- }
- }
-
- return r0, r1
-}
-
-// GetUserByUsername provides a mock function with given fields: name
-func (_m *MockAPI) GetUserByUsername(name string) (*model.User, *model.AppError) {
- ret := _m.Called(name)
-
- var r0 *model.User
- if rf, ok := ret.Get(0).(func(string) *model.User); ok {
- r0 = rf(name)
- } else {
- if ret.Get(0) != nil {
- r0 = ret.Get(0).(*model.User)
- }
- }
-
- var r1 *model.AppError
- if rf, ok := ret.Get(1).(func(string) *model.AppError); ok {
- r1 = rf(name)
- } else {
- if ret.Get(1) != nil {
- r1 = ret.Get(1).(*model.AppError)
- }
- }
-
- return r0, r1
-}
-
-// GetUserStatus provides a mock function with given fields: userId
-func (_m *MockAPI) GetUserStatus(userId string) (*model.Status, *model.AppError) {
- ret := _m.Called(userId)
-
- var r0 *model.Status
- if rf, ok := ret.Get(0).(func(string) *model.Status); ok {
- r0 = rf(userId)
- } else {
- if ret.Get(0) != nil {
- r0 = ret.Get(0).(*model.Status)
- }
- }
-
- var r1 *model.AppError
- if rf, ok := ret.Get(1).(func(string) *model.AppError); ok {
- r1 = rf(userId)
- } else {
- if ret.Get(1) != nil {
- r1 = ret.Get(1).(*model.AppError)
- }
- }
-
- return r0, r1
-}
-
-// GetUserStatusesByIds provides a mock function with given fields: userIds
-func (_m *MockAPI) GetUserStatusesByIds(userIds []string) ([]*model.Status, *model.AppError) {
- ret := _m.Called(userIds)
-
- var r0 []*model.Status
- if rf, ok := ret.Get(0).(func([]string) []*model.Status); ok {
- r0 = rf(userIds)
- } else {
- if ret.Get(0) != nil {
- r0 = ret.Get(0).([]*model.Status)
- }
- }
-
- var r1 *model.AppError
- if rf, ok := ret.Get(1).(func([]string) *model.AppError); ok {
- r1 = rf(userIds)
- } else {
- if ret.Get(1) != nil {
- r1 = ret.Get(1).(*model.AppError)
- }
- }
-
- return r0, r1
-}
-
-// KVDelete provides a mock function with given fields: key
-func (_m *MockAPI) KVDelete(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
-}
-
-// KVGet provides a mock function with given fields: key
-func (_m *MockAPI) 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 *MockAPI) 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).(*model.AppError)
- }
- }
-
- return r0
-}
-
-// LoadPluginConfiguration provides a mock function with given fields: dest
-func (_m *MockAPI) LoadPluginConfiguration(dest interface{}) error {
- ret := _m.Called(dest)
-
- var r0 error
- if rf, ok := ret.Get(0).(func(interface{}) error); ok {
- r0 = rf(dest)
- } else {
- r0 = ret.Error(0)
- }
-
- return r0
-}
-
-// LogDebug provides a mock function with given fields: msg, keyValuePairs
-func (_m *MockAPI) 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 *MockAPI) 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 *MockAPI) 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 *MockAPI) 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 *MockAPI) 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 *MockAPI) RegisterCommand(command *model.Command) error {
- ret := _m.Called(command)
-
- var r0 error
- if rf, ok := ret.Get(0).(func(*model.Command) error); ok {
- r0 = rf(command)
- } else {
- r0 = ret.Error(0)
- }
-
- return r0
-}
-
-// SaveConfig provides a mock function with given fields: config
-func (_m *MockAPI) 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 *MockAPI) 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 *MockAPI) UnregisterCommand(teamId string, trigger string) error {
- ret := _m.Called(teamId, trigger)
-
- var r0 error
- if rf, ok := ret.Get(0).(func(string, string) error); ok {
- r0 = rf(teamId, trigger)
- } else {
- r0 = ret.Error(0)
- }
-
- return r0
-}
-
-// UpdateChannel provides a mock function with given fields: channel
-func (_m *MockAPI) UpdateChannel(channel *model.Channel) (*model.Channel, *model.AppError) {
- ret := _m.Called(channel)
-
- var r0 *model.Channel
- if rf, ok := ret.Get(0).(func(*model.Channel) *model.Channel); ok {
- r0 = rf(channel)
- } else {
- if ret.Get(0) != nil {
- r0 = ret.Get(0).(*model.Channel)
- }
- }
-
- var r1 *model.AppError
- if rf, ok := ret.Get(1).(func(*model.Channel) *model.AppError); ok {
- r1 = rf(channel)
- } else {
- if ret.Get(1) != nil {
- r1 = ret.Get(1).(*model.AppError)
- }
- }
-
- return r0, r1
-}
-
-// UpdateChannelMemberNotifications provides a mock function with given fields: channelId, userId, notifications
-func (_m *MockAPI) UpdateChannelMemberNotifications(channelId string, userId string, notifications map[string]string) (*model.ChannelMember, *model.AppError) {
- ret := _m.Called(channelId, userId, notifications)
-
- var r0 *model.ChannelMember
- if rf, ok := ret.Get(0).(func(string, string, map[string]string) *model.ChannelMember); ok {
- r0 = rf(channelId, userId, notifications)
- } else {
- if ret.Get(0) != nil {
- r0 = ret.Get(0).(*model.ChannelMember)
- }
- }
-
- var r1 *model.AppError
- if rf, ok := ret.Get(1).(func(string, string, map[string]string) *model.AppError); ok {
- r1 = rf(channelId, userId, notifications)
- } else {
- if ret.Get(1) != nil {
- r1 = ret.Get(1).(*model.AppError)
- }
- }
-
- return r0, r1
-}
-
-// UpdateChannelMemberRoles provides a mock function with given fields: channelId, userId, newRoles
-func (_m *MockAPI) UpdateChannelMemberRoles(channelId string, userId string, newRoles string) (*model.ChannelMember, *model.AppError) {
- ret := _m.Called(channelId, userId, newRoles)
-
- var r0 *model.ChannelMember
- if rf, ok := ret.Get(0).(func(string, string, string) *model.ChannelMember); ok {
- r0 = rf(channelId, userId, newRoles)
- } else {
- if ret.Get(0) != nil {
- r0 = ret.Get(0).(*model.ChannelMember)
- }
- }
-
- var r1 *model.AppError
- if rf, ok := ret.Get(1).(func(string, string, string) *model.AppError); ok {
- r1 = rf(channelId, userId, newRoles)
- } else {
- if ret.Get(1) != nil {
- r1 = ret.Get(1).(*model.AppError)
- }
- }
-
- return r0, r1
-}
-
-// UpdatePost provides a mock function with given fields: post
-func (_m *MockAPI) UpdatePost(post *model.Post) (*model.Post, *model.AppError) {
- ret := _m.Called(post)
-
- var r0 *model.Post
- if rf, ok := ret.Get(0).(func(*model.Post) *model.Post); ok {
- r0 = rf(post)
- } else {
- if ret.Get(0) != nil {
- r0 = ret.Get(0).(*model.Post)
- }
- }
-
- var r1 *model.AppError
- if rf, ok := ret.Get(1).(func(*model.Post) *model.AppError); ok {
- r1 = rf(post)
- } else {
- if ret.Get(1) != nil {
- r1 = ret.Get(1).(*model.AppError)
- }
- }
-
- return r0, r1
-}
-
-// UpdateTeam provides a mock function with given fields: team
-func (_m *MockAPI) UpdateTeam(team *model.Team) (*model.Team, *model.AppError) {
- ret := _m.Called(team)
-
- var r0 *model.Team
- if rf, ok := ret.Get(0).(func(*model.Team) *model.Team); ok {
- r0 = rf(team)
- } else {
- if ret.Get(0) != nil {
- r0 = ret.Get(0).(*model.Team)
- }
- }
-
- var r1 *model.AppError
- if rf, ok := ret.Get(1).(func(*model.Team) *model.AppError); ok {
- r1 = rf(team)
- } else {
- if ret.Get(1) != nil {
- r1 = ret.Get(1).(*model.AppError)
- }
- }
-
- return r0, r1
-}
-
-// UpdateTeamMemberRoles provides a mock function with given fields: teamId, userId, newRoles
-func (_m *MockAPI) 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 *MockAPI) UpdateUser(user *model.User) (*model.User, *model.AppError) {
- ret := _m.Called(user)
-
- var r0 *model.User
- if rf, ok := ret.Get(0).(func(*model.User) *model.User); ok {
- r0 = rf(user)
- } else {
- if ret.Get(0) != nil {
- r0 = ret.Get(0).(*model.User)
- }
- }
-
- var r1 *model.AppError
- if rf, ok := ret.Get(1).(func(*model.User) *model.AppError); ok {
- r1 = rf(user)
- } else {
- if ret.Get(1) != nil {
- r1 = ret.Get(1).(*model.AppError)
- }
- }
-
- return r0, r1
-}
-
-// UpdateUserStatus provides a mock function with given fields: status, userId
-func (_m *MockAPI) UpdateUserStatus(status string, userId string) (*model.Status, *model.AppError) {
- ret := _m.Called(status, userId)
-
- var r0 *model.Status
- if rf, ok := ret.Get(0).(func(string, string) *model.Status); ok {
- r0 = rf(status, userId)
- } else {
- if ret.Get(0) != nil {
- r0 = ret.Get(0).(*model.Status)
- }
- }
-
- var r1 *model.AppError
- if rf, ok := ret.Get(1).(func(string, string) *model.AppError); ok {
- r1 = rf(status, userId)
- } else {
- if ret.Get(1) != nil {
- r1 = ret.Get(1).(*model.AppError)
- }
- }
-
- return r0, r1
-}
diff --git a/plugin/supervisor_test.go b/plugin/supervisor_test.go
index 19d0499e5..4c5275c43 100644
--- a/plugin/supervisor_test.go
+++ b/plugin/supervisor_test.go
@@ -13,13 +13,11 @@ import (
"github.com/mattermost/mattermost-server/mlog"
"github.com/mattermost/mattermost-server/model"
"github.com/stretchr/testify/assert"
- "github.com/stretchr/testify/mock"
"github.com/stretchr/testify/require"
)
func TestSupervisor(t *testing.T) {
for name, f := range map[string]func(*testing.T){
- "Supervisor": testSupervisor,
"Supervisor_InvalidExecutablePath": testSupervisor_InvalidExecutablePath,
"Supervisor_NonExistentExecutablePath": testSupervisor_NonExistentExecutablePath,
"Supervisor_StartTimeout": testSupervisor_StartTimeout,
@@ -28,7 +26,7 @@ func TestSupervisor(t *testing.T) {
}
}
-func CompileGo(t *testing.T, sourceCode, outputPath string) {
+func compileGo(t *testing.T, sourceCode, outputPath string) {
dir, err := ioutil.TempDir(".", "")
require.NoError(t, err)
defer os.RemoveAll(dir)
@@ -40,44 +38,6 @@ func CompileGo(t *testing.T, sourceCode, outputPath string) {
require.NoError(t, cmd.Run())
}
-func testSupervisor(t *testing.T) {
- dir, err := ioutil.TempDir("", "")
- require.NoError(t, err)
- defer os.RemoveAll(dir)
-
- backend := filepath.Join(dir, "backend.exe")
- CompileGo(t, `
- package main
-
- import (
- "github.com/mattermost/mattermost-server/plugin"
- )
-
- type MyPlugin struct {
- plugin.MattermostPlugin
- }
-
- func main() {
- plugin.ClientMain(&MyPlugin{})
- }
- `, backend)
-
- ioutil.WriteFile(filepath.Join(dir, "plugin.json"), []byte(`{"id": "foo", "backend": {"executable": "backend.exe"}}`), 0600)
-
- bundle := model.BundleInfoForPath(dir)
- var api MockAPI
- api.On("LoadPluginConfiguration", mock.Anything).Return(nil)
- log := mlog.NewLogger(&mlog.LoggerConfiguration{
- EnableConsole: true,
- ConsoleJson: true,
- ConsoleLevel: "error",
- EnableFile: false,
- })
- supervisor, err := newSupervisor(bundle, log, &api)
- require.NoError(t, err)
- supervisor.Shutdown()
-}
-
func testSupervisor_InvalidExecutablePath(t *testing.T) {
dir, err := ioutil.TempDir("", "")
require.NoError(t, err)
@@ -123,7 +83,7 @@ func testSupervisor_StartTimeout(t *testing.T) {
defer os.RemoveAll(dir)
backend := filepath.Join(dir, "backend.exe")
- CompileGo(t, `
+ compileGo(t, `
package main
func main() {