summaryrefslogtreecommitdiffstats
path: root/cmd/mattermost/commands/plugin_test.go
diff options
context:
space:
mode:
authorSantos Solorzano <santosjavier22@gmail.com>2018-07-11 09:17:19 -0700
committerJoram Wilander <jwawilander@gmail.com>2018-07-11 12:17:19 -0400
commitf57d279dc0101611e2bd977aef93e32802ff2370 (patch)
tree2c6ea10b8fecd96f3d72fe4a018e2fa56a2356cf /cmd/mattermost/commands/plugin_test.go
parente135cc99e1b93f41f67dbdfac214198a55f387a6 (diff)
downloadchat-f57d279dc0101611e2bd977aef93e32802ff2370.tar.gz
chat-f57d279dc0101611e2bd977aef93e32802ff2370.tar.bz2
chat-f57d279dc0101611e2bd977aef93e32802ff2370.zip
[MM-10117] Add support to add/delete and enable/disable plugins via CLI (#8745)
* Testing caching for emojis * MM-10117 Add support to add/delete and activate/deactivate plugins via CLI * Removing old work * MM-10117 Moved files and addedd plugin test * MM-10117 Renamed commands to enable/disable and updated add test * MM-10117 Finished plugin test and improved error message for plugin commands * MM-10117 Fixing plugin directories for test * MM-10117 Renamed commands and updated commands to support multiple plugins * MM-10117 Updating removed to deleted textclear * MM-10117 Fixing nil pointer error for listing plugins * MM-10117 Removing fileReader close * MM-10117 Declaring error for GetPlugins * MM-10117 Removing unnecessary nil check
Diffstat (limited to 'cmd/mattermost/commands/plugin_test.go')
-rw-r--r--cmd/mattermost/commands/plugin_test.go42
1 files changed, 42 insertions, 0 deletions
diff --git a/cmd/mattermost/commands/plugin_test.go b/cmd/mattermost/commands/plugin_test.go
new file mode 100644
index 000000000..043823583
--- /dev/null
+++ b/cmd/mattermost/commands/plugin_test.go
@@ -0,0 +1,42 @@
+package commands
+
+import (
+ "os"
+ "path/filepath"
+ "testing"
+
+ "github.com/mattermost/mattermost-server/api4"
+ "github.com/mattermost/mattermost-server/utils"
+ "github.com/stretchr/testify/assert"
+ "github.com/stretchr/testify/require"
+)
+
+func TestPlugin(t *testing.T) {
+ os.MkdirAll("./test-plugins", os.ModePerm)
+ os.MkdirAll("./test-client-plugins", os.ModePerm)
+
+ th := api4.Setup().InitBasic().InitSystemAdmin()
+ defer th.TearDown()
+
+ path, _ := utils.FindDir("tests")
+
+ os.Chdir(filepath.Join("..", "..", ".."))
+
+ CheckCommand(t, "--config", filepath.Join(path, "test-config.json"), "plugin", "add", filepath.Join(path, "testplugin.tar.gz"))
+
+ CheckCommand(t, "--config", filepath.Join(path, "test-config.json"), "plugin", "enable", "testplugin")
+ cfg, _, _, err := utils.LoadConfig(filepath.Join(path, "test-config.json"))
+ require.Nil(t, err)
+ assert.Equal(t, cfg.PluginSettings.PluginStates["testplugin"].Enable, true)
+
+ CheckCommand(t, "--config", filepath.Join(path, "test-config.json"), "plugin", "disable", "testplugin")
+ cfg, _, _, err = utils.LoadConfig(filepath.Join(path, "test-config.json"))
+ require.Nil(t, err)
+ assert.Equal(t, cfg.PluginSettings.PluginStates["testplugin"].Enable, false)
+
+ CheckCommand(t, "--config", filepath.Join(path, "test-config.json"), "plugin", "list")
+
+ CheckCommand(t, "--config", filepath.Join(path, "test-config.json"), "plugin", "delete", "testplugin")
+
+ os.Chdir(filepath.Join("cmd", "mattermost", "commands"))
+}