mirror of
https://github.com/mattermost/mattermost.git
synced 2026-02-22 17:30:12 -05:00
* plugin sandboxing * remove unused type * better symlink handling, better remounting, better test, whitespace fixes, and comment on the remounting * fix test compile error * big simplification for getting mount flags * mask statfs flags to the ones we're interested in
53 lines
1 KiB
Go
53 lines
1 KiB
Go
package rpcplugin
|
|
|
|
import (
|
|
"context"
|
|
"io/ioutil"
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
|
|
"github.com/mattermost/mattermost-server/plugin/plugintest"
|
|
"github.com/mattermost/mattermost-server/plugin/rpcplugin/rpcplugintest"
|
|
)
|
|
|
|
func TestMain(t *testing.T) {
|
|
dir, err := ioutil.TempDir("", "")
|
|
require.NoError(t, err)
|
|
defer os.RemoveAll(dir)
|
|
|
|
plugin := filepath.Join(dir, "plugin.exe")
|
|
rpcplugintest.CompileGo(t, `
|
|
package main
|
|
|
|
import (
|
|
"github.com/mattermost/mattermost-server/plugin/rpcplugin"
|
|
)
|
|
|
|
type MyPlugin struct {}
|
|
|
|
func main() {
|
|
rpcplugin.Main(&MyPlugin{})
|
|
}
|
|
`, plugin)
|
|
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
p, ipc, err := NewProcess(ctx, plugin)
|
|
require.NoError(t, err)
|
|
defer p.Wait()
|
|
|
|
muxer := NewMuxer(ipc, false)
|
|
defer muxer.Close()
|
|
|
|
defer cancel()
|
|
|
|
var api plugintest.API
|
|
|
|
hooks, err := ConnectMain(muxer)
|
|
require.NoError(t, err)
|
|
assert.NoError(t, hooks.OnActivate(&api))
|
|
assert.NoError(t, hooks.OnDeactivate())
|
|
}
|