summaryrefslogtreecommitdiffstats
path: root/app/plugin_test.go
diff options
context:
space:
mode:
authorJoram Wilander <jwawilander@gmail.com>2018-03-13 10:32:24 -0400
committerGitHub <noreply@github.com>2018-03-13 10:32:24 -0400
commit4ae1238bc12537632289960f58e52d3c625d37e3 (patch)
treefa211d08df1e5f50d54d6d3ca6dbd88ce129800a /app/plugin_test.go
parentff5f511dfd7e6b2019d1a56922dfa72181307b46 (diff)
downloadchat-4ae1238bc12537632289960f58e52d3c625d37e3.tar.gz
chat-4ae1238bc12537632289960f58e52d3c625d37e3.tar.bz2
chat-4ae1238bc12537632289960f58e52d3c625d37e3.zip
Better error handling for failed plugin activation (#8361)
Diffstat (limited to 'app/plugin_test.go')
-rw-r--r--app/plugin_test.go25
1 files changed, 25 insertions, 0 deletions
diff --git a/app/plugin_test.go b/app/plugin_test.go
index 4794d2704..9ad5dc1fa 100644
--- a/app/plugin_test.go
+++ b/app/plugin_test.go
@@ -4,8 +4,10 @@
package app
import (
+ "errors"
"net/http"
"net/http/httptest"
+ "strings"
"testing"
"github.com/gorilla/mux"
@@ -195,3 +197,26 @@ func TestPluginCommands(t *testing.T) {
require.NotNil(t, err)
assert.Equal(t, http.StatusNotFound, err.StatusCode)
}
+
+type pluginBadActivation struct {
+ testPlugin
+}
+
+func (p *pluginBadActivation) OnActivate(api plugin.API) error {
+ return errors.New("won't activate for some reason")
+}
+
+func TestPluginBadActivation(t *testing.T) {
+ th := Setup().InitBasic()
+ defer th.TearDown()
+
+ th.InstallPlugin(&model.Manifest{
+ Id: "foo",
+ }, &pluginBadActivation{})
+
+ t.Run("EnablePlugin bad activation", func(t *testing.T) {
+ err := th.App.EnablePlugin("foo")
+ assert.NotNil(t, err)
+ assert.True(t, strings.Contains(err.DetailedError, "won't activate for some reason"))
+ })
+}