diff options
Diffstat (limited to 'plugin/pluginenv/environment_test.go')
-rw-r--r-- | plugin/pluginenv/environment_test.go | 26 |
1 files changed, 6 insertions, 20 deletions
diff --git a/plugin/pluginenv/environment_test.go b/plugin/pluginenv/environment_test.go index e4f63cf70..988e5b08f 100644 --- a/plugin/pluginenv/environment_test.go +++ b/plugin/pluginenv/environment_test.go @@ -44,8 +44,8 @@ type MockSupervisor struct { mock.Mock } -func (m *MockSupervisor) Start() error { - return m.Called().Error(0) +func (m *MockSupervisor) Start(api plugin.API) error { + return m.Called(api).Error(0) } func (m *MockSupervisor) Stop() error { @@ -141,12 +141,10 @@ func TestEnvironment(t *testing.T) { provider.On("API").Return(&api, nil) provider.On("Supervisor").Return(&supervisor, nil) - supervisor.On("Start").Return(nil) + supervisor.On("Start", &api).Return(nil) supervisor.On("Stop").Return(nil) supervisor.On("Hooks").Return(&hooks) - hooks.On("OnActivate", &api).Return(nil) - assert.NoError(t, env.ActivatePlugin("foo")) assert.Equal(t, env.ActivePluginIds(), []string{"foo"}) activePlugins = env.ActivePlugins() @@ -238,17 +236,7 @@ func TestEnvironment_ActivatePluginErrors(t *testing.T) { provider.On("API").Return(&api, nil) provider.On("Supervisor").Return(&supervisor, nil) - supervisor.On("Start").Return(fmt.Errorf("test error")) - }, - "HooksError": func() { - provider.On("API").Return(&api, nil) - provider.On("Supervisor").Return(&supervisor, nil) - - supervisor.On("Start").Return(nil) - supervisor.On("Stop").Return(nil) - supervisor.On("Hooks").Return(&hooks) - - hooks.On("OnActivate", &api).Return(fmt.Errorf("test error")) + supervisor.On("Start", &api).Return(fmt.Errorf("test error")) }, } { t.Run(name, func(t *testing.T) { @@ -291,11 +279,10 @@ func TestEnvironment_ShutdownError(t *testing.T) { provider.On("API").Return(&api, nil) provider.On("Supervisor").Return(&supervisor, nil) - supervisor.On("Start").Return(nil) + supervisor.On("Start", &api).Return(nil) supervisor.On("Stop").Return(fmt.Errorf("test error")) supervisor.On("Hooks").Return(&hooks) - hooks.On("OnActivate", &api).Return(nil) hooks.On("OnDeactivate").Return(fmt.Errorf("test error")) assert.NoError(t, env.ActivatePlugin("foo")) @@ -329,13 +316,12 @@ func TestEnvironment_ConcurrentHookInvocations(t *testing.T) { provider.On("API").Return(&api, nil) provider.On("Supervisor").Return(&supervisor, nil) - supervisor.On("Start").Return(nil) + supervisor.On("Start", &api).Return(nil) supervisor.On("Stop").Return(nil) supervisor.On("Hooks").Return(&hooks) ch := make(chan bool) - hooks.On("OnActivate", &api).Return(nil) hooks.On("OnDeactivate").Return(nil) hooks.On("ServeHTTP", mock.AnythingOfType("*httptest.ResponseRecorder"), mock.AnythingOfType("*http.Request")).Run(func(args mock.Arguments) { r := args.Get(1).(*http.Request) |