From 4ae1238bc12537632289960f58e52d3c625d37e3 Mon Sep 17 00:00:00 2001 From: Joram Wilander Date: Tue, 13 Mar 2018 10:32:24 -0400 Subject: Better error handling for failed plugin activation (#8361) --- app/plugin_test.go | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'app/plugin_test.go') 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")) + }) +} -- cgit v1.2.3-1-g7c22