MCPcopy
hub / github.com/microsoft/retina / TestPluginInit

Function TestPluginInit

pkg/managers/pluginmanager/pluginmanager_test.go:297–334  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

295}
296
297func TestPluginInit(t *testing.T) {
298 log.SetupZapLogger(log.GetDefaultLogOpts())
299 tel := telemetry.NewNoopTelemetry()
300 tests := []struct {
301 name string
302 cfg kcfg.Config
303 pluginName string
304 wantErr bool
305 }{
306 {
307 name: "Plugin init successes Pod Level Disabled",
308 cfg: cfgPodLevelDisabled,
309 pluginName: "mockplugin",
310 wantErr: false,
311 },
312 {
313 name: "Plugin init successes Pod Level Enabled",
314 cfg: cfgPodLevelEnabled,
315 pluginName: "mockplugin",
316 wantErr: false,
317 },
318 }
319 for _, tt := range tests {
320 tt.cfg.EnabledPlugin = append(tt.cfg.EnabledPlugin, tt.pluginName)
321 mgr, err := NewPluginManager(&tt.cfg, tel, slog.Default())
322 require.Nil(t, err, "Expected nil but got error:%w", err)
323 for _, plugin := range mgr.plugins {
324 if tt.wantErr {
325 err := plugin.Init()
326 require.NotNil(t, err, "Expected Init err but got nil")
327 require.ErrorContains(t, err, "event channel is nil", "Expected event channel nil but got:%w", err)
328 } else {
329 err := plugin.Init()
330 require.Nil(t, err, "Expected nil but got init error:%w", err)
331 }
332 }
333 }
334}
335
336func TestPluginStartWithoutInit(t *testing.T) {
337 log.SetupZapLogger(log.GetDefaultLogOpts())

Callers

nothing calls this directly

Calls 5

SetupZapLoggerFunction · 0.92
GetDefaultLogOptsFunction · 0.92
NewNoopTelemetryFunction · 0.92
NewPluginManagerFunction · 0.85
InitMethod · 0.65

Tested by

no test coverage detected