Better error handling for failed plugin activation (#8361)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
ff5f511dfd
Коммит
4ae1238bc1
@@ -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"))
|
||||
})
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user