diff --git a/cmd/adapter/main_test.go b/cmd/adapter/main_test.go index 1ba1667..e8b6658 100644 --- a/cmd/adapter/main_test.go +++ b/cmd/adapter/main_test.go @@ -101,51 +101,26 @@ func TestMainFunction(t *testing.T) { } func TestRunSuccess(t *testing.T) { - tests := []struct { - name string - configPath string - mockMgr func() (*plugin.Manager, func(), error) - mockLogger func(cfg *Config) error - mockServer func(ctx context.Context, mgr handler.PluginManager, cfg *Config) (http.Handler, error) - }{ - { - name: "Valid Config", - configPath: "../test/validConfig.yaml", - mockMgr: func() (*plugin.Manager, func(), error) { - return &plugin.Manager{}, func() {}, nil - }, - mockLogger: func(cfg *Config) error { - return nil - }, - mockServer: func(ctx context.Context, mgr handler.PluginManager, cfg *Config) (http.Handler, error) { - return http.NewServeMux(), nil - }, - }, + ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second) + defer cancel() + + configPath := "../test/validConfig.yaml" + + // Mock dependencies + originalNewManager := newManagerFunc + newManagerFunc = func(ctx context.Context, cfg *plugin.ManagerConfig) (*plugin.Manager, func(), error) { + return &plugin.Manager{}, func() {}, nil } + defer func() { newManagerFunc = originalNewManager }() - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second) - defer cancel() + originalNewServer := newServerFunc + newServerFunc = func(ctx context.Context, mgr handler.PluginManager, cfg *Config) (http.Handler, error) { + return http.NewServeMux(), nil + } + defer func() { newServerFunc = originalNewServer }() - // Mock dependencies - originalNewManager := newManagerFunc - newManagerFunc = func(ctx context.Context, cfg *plugin.ManagerConfig) (*plugin.Manager, func(), error) { - return tt.mockMgr() - } - defer func() { newManagerFunc = originalNewManager }() - - originalNewServer := newServerFunc - newServerFunc = func(ctx context.Context, mgr handler.PluginManager, cfg *Config) (http.Handler, error) { - return tt.mockServer(ctx, mgr, cfg) - } - defer func() { newServerFunc = originalNewServer }() - - // Run the app using static config file - if err := run(ctx, filepath.Clean(tt.configPath)); err != nil { - t.Errorf("Expected no error, but got: %v", err) - } - }) + if err := run(ctx, filepath.Clean(configPath)); err != nil { + t.Errorf("Expected no error, but got: %v", err) } } diff --git a/cmd/test/validConfig.yaml b/cmd/test/validConfig.yaml index 450e09f..5497753 100644 --- a/cmd/test/validConfig.yaml +++ b/cmd/test/validConfig.yaml @@ -1,5 +1,4 @@ appName: "testAdapter" - log: level: debug destinations: @@ -7,21 +6,18 @@ log: context_keys: - transaction_id - message_id - http: port: 8080 timeout: read: 30 write: 30 idle: 30 - plugin: root: "/mock/plugins" pluginZipPath: "/mock/plugins/plugins_bundle.zip" plugins: - testPlugin1 - testPlugin2 - modules: - name: testModule type: transaction