PLT-7407: Back-end plugin mechanism (#7177)

* begin backend plugin wip

* flesh out rpcplugin. everything done except for minor supervisor stubs

* done with basic plugin infrastructure

* simplify tests

* remove unused test lines
Этот коммит содержится в:
Chris
2017-08-16 17:23:38 -05:00
коммит произвёл GitHub
родитель 4f85ed985d
Коммит f80d50adbd
33 изменённых файлов: 2163 добавлений и 1 удалений

58
plugin/rpcplugin/main_test.go Обычный файл
Просмотреть файл

@@ -0,0 +1,58 @@
package rpcplugin
import (
"context"
"io/ioutil"
"os"
"path/filepath"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/mattermost/platform/plugin/plugintest"
)
func TestMain(t *testing.T) {
dir, err := ioutil.TempDir("", "")
require.NoError(t, err)
defer os.RemoveAll(dir)
plugin := filepath.Join(dir, "plugin")
compileGo(t, `
package main
import (
"github.com/mattermost/platform/plugin"
"github.com/mattermost/platform/plugin/rpcplugin"
)
type MyPlugin struct {}
func (p *MyPlugin) OnActivate(api plugin.API) error {
return nil
}
func (p *MyPlugin) OnDeactivate() error {
return nil
}
func main() {
rpcplugin.Main(&MyPlugin{})
}
`, plugin)
p, ipc, err := NewProcess(context.Background(), plugin)
require.NoError(t, err)
defer p.Wait()
muxer := NewMuxer(ipc, false)
defer muxer.Close()
var api plugintest.API
hooks, err := ConnectMain(muxer)
require.NoError(t, err)
assert.NoError(t, hooks.OnActivate(&api))
assert.NoError(t, hooks.OnDeactivate())
}