(t *testing.T)
| 295 | } |
| 296 | |
| 297 | func 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 | |
| 336 | func TestPluginStartWithoutInit(t *testing.T) { |
| 337 | log.SetupZapLogger(log.GetDefaultLogOpts()) |
nothing calls this directly
no test coverage detected