improve rpcplugin tests (#7837)
Этот коммит содержится в:
@@ -62,3 +62,10 @@ func TestProcess(t *testing.T) {
|
||||
assert.Equal(t, "ping", string(b[:4]))
|
||||
require.NoError(t, p.Wait())
|
||||
}
|
||||
|
||||
func TestInvalidProcess(t *testing.T) {
|
||||
p, ipc, err := NewProcess(context.Background(), "thisfileshouldnotexist")
|
||||
require.Nil(t, p)
|
||||
require.Nil(t, ipc)
|
||||
require.Error(t, err)
|
||||
}
|
||||
|
||||
@@ -56,6 +56,21 @@ func TestSupervisor_InvalidExecutablePath(t *testing.T) {
|
||||
assert.Error(t, err)
|
||||
}
|
||||
|
||||
func TestSupervisor_NonExistentExecutablePath(t *testing.T) {
|
||||
dir, err := ioutil.TempDir("", "")
|
||||
require.NoError(t, err)
|
||||
defer os.RemoveAll(dir)
|
||||
|
||||
ioutil.WriteFile(filepath.Join(dir, "plugin.json"), []byte(`{"id": "foo", "backend": {"executable": "thisfileshouldnotexist"}}`), 0600)
|
||||
|
||||
bundle := model.BundleInfoForPath(dir)
|
||||
supervisor, err := SupervisorProvider(bundle)
|
||||
require.NotNil(t, supervisor)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Error(t, supervisor.Start())
|
||||
}
|
||||
|
||||
// If plugin development goes really wrong, let's make sure plugin activation won't block forever.
|
||||
func TestSupervisor_StartTimeout(t *testing.T) {
|
||||
dir, err := ioutil.TempDir("", "")
|
||||
@@ -104,6 +119,10 @@ func TestSupervisor_PluginCrash(t *testing.T) {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *MyPlugin) OnDeactivate() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func main() {
|
||||
rpcplugin.Main(&MyPlugin{})
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user