diff --git a/service/internal/configunmarshaler/exporters_test.go b/service/internal/configunmarshaler/exporters_test.go index b5adc7a36bb..e1f171636d1 100644 --- a/service/internal/configunmarshaler/exporters_test.go +++ b/service/internal/configunmarshaler/exporters_test.go @@ -26,20 +26,20 @@ import ( ) func TestExportersUnmarshal(t *testing.T) { - factories, err := componenttest.NopFactories() + factories, err := component.MakeExporterFactoryMap(componenttest.NewNopExporterFactory()) require.NoError(t, err) - exps := NewExporters(factories.Exporters) + exps := NewExporters(factories) conf := confmap.NewFromStringMap(map[string]interface{}{ "nop": nil, "nop/myexporter": nil, }) require.NoError(t, exps.Unmarshal(conf)) - cfgWithName := factories.Exporters["nop"].CreateDefaultConfig() + cfgWithName := factories["nop"].CreateDefaultConfig() cfgWithName.SetIDName("myexporter") //nolint:staticcheck assert.Equal(t, map[component.ID]component.Config{ - component.NewID("nop"): factories.Exporters["nop"].CreateDefaultConfig(), + component.NewID("nop"): factories["nop"].CreateDefaultConfig(), component.NewIDWithName("nop", "myexporter"): cfgWithName, }, exps.GetExporters()) } @@ -100,12 +100,12 @@ func TestExportersUnmarshalError(t *testing.T) { }, } - factories, err := componenttest.NopFactories() + factories, err := component.MakeExporterFactoryMap(componenttest.NewNopExporterFactory()) assert.NoError(t, err) for _, tt := range testCases { t.Run(tt.name, func(t *testing.T) { - exps := NewExporters(factories.Exporters) + exps := NewExporters(factories) err = exps.Unmarshal(tt.conf) require.Error(t, err) assert.Contains(t, err.Error(), tt.expectedError) diff --git a/service/internal/configunmarshaler/extensions_test.go b/service/internal/configunmarshaler/extensions_test.go index a2d8d39bef4..0610dbeb2c3 100644 --- a/service/internal/configunmarshaler/extensions_test.go +++ b/service/internal/configunmarshaler/extensions_test.go @@ -21,25 +21,26 @@ import ( "github.com/stretchr/testify/require" "go.opentelemetry.io/collector/component" - "go.opentelemetry.io/collector/component/componenttest" "go.opentelemetry.io/collector/confmap" + "go.opentelemetry.io/collector/extension" + "go.opentelemetry.io/collector/extension/extensiontest" ) func TestExtensionsUnmarshal(t *testing.T) { - factories, err := componenttest.NopFactories() + factories, err := extension.MakeFactoryMap(extensiontest.NewNopFactory()) require.NoError(t, err) - exts := NewExtensions(factories.Extensions) + exts := NewExtensions(factories) conf := confmap.NewFromStringMap(map[string]interface{}{ "nop": nil, "nop/myextension": nil, }) require.NoError(t, exts.Unmarshal(conf)) - cfgWithName := factories.Extensions["nop"].CreateDefaultConfig() + cfgWithName := factories["nop"].CreateDefaultConfig() cfgWithName.SetIDName("myextension") //nolint:staticcheck assert.Equal(t, map[component.ID]component.Config{ - component.NewID("nop"): factories.Extensions["nop"].CreateDefaultConfig(), + component.NewID("nop"): factories["nop"].CreateDefaultConfig(), component.NewIDWithName("nop", "myextension"): cfgWithName, }, exts.GetExtensions()) } @@ -100,12 +101,12 @@ func TestExtensionsUnmarshalError(t *testing.T) { }, } - factories, err := componenttest.NopFactories() + factories, err := extension.MakeFactoryMap(extensiontest.NewNopFactory()) assert.NoError(t, err) for _, tt := range testCases { t.Run(tt.name, func(t *testing.T) { - exts := NewExtensions(factories.Extensions) + exts := NewExtensions(factories) err = exts.Unmarshal(tt.conf) require.Error(t, err) assert.Contains(t, err.Error(), tt.expectedError) diff --git a/service/internal/configunmarshaler/processors_test.go b/service/internal/configunmarshaler/processors_test.go index cc2682fa04a..9e7748e1d19 100644 --- a/service/internal/configunmarshaler/processors_test.go +++ b/service/internal/configunmarshaler/processors_test.go @@ -26,20 +26,20 @@ import ( ) func TestProcessorsUnmarshal(t *testing.T) { - factories, err := componenttest.NopFactories() + factories, err := component.MakeProcessorFactoryMap(componenttest.NewNopProcessorFactory()) require.NoError(t, err) - procs := NewProcessors(factories.Processors) + procs := NewProcessors(factories) conf := confmap.NewFromStringMap(map[string]interface{}{ "nop": nil, "nop/myprocessor": nil, }) require.NoError(t, procs.Unmarshal(conf)) - cfgWithName := factories.Processors["nop"].CreateDefaultConfig() + cfgWithName := factories["nop"].CreateDefaultConfig() cfgWithName.SetIDName("myprocessor") //nolint:staticcheck assert.Equal(t, map[component.ID]component.Config{ - component.NewID("nop"): factories.Processors["nop"].CreateDefaultConfig(), + component.NewID("nop"): factories["nop"].CreateDefaultConfig(), component.NewIDWithName("nop", "myprocessor"): cfgWithName, }, procs.procs) } @@ -100,12 +100,12 @@ func TestProcessorsUnmarshalError(t *testing.T) { }, } - factories, err := componenttest.NopFactories() + factories, err := component.MakeProcessorFactoryMap(componenttest.NewNopProcessorFactory()) assert.NoError(t, err) for _, tt := range testCases { t.Run(tt.name, func(t *testing.T) { - procs := NewProcessors(factories.Processors) + procs := NewProcessors(factories) err = procs.Unmarshal(tt.conf) require.Error(t, err) assert.Contains(t, err.Error(), tt.expectedError) diff --git a/service/internal/configunmarshaler/receivers_test.go b/service/internal/configunmarshaler/receivers_test.go index f0508c8a775..293a27f2b75 100644 --- a/service/internal/configunmarshaler/receivers_test.go +++ b/service/internal/configunmarshaler/receivers_test.go @@ -26,20 +26,20 @@ import ( ) func TestReceiversUnmarshal(t *testing.T) { - factories, err := componenttest.NopFactories() + factories, err := component.MakeReceiverFactoryMap(componenttest.NewNopReceiverFactory()) require.NoError(t, err) - recvs := NewReceivers(factories.Receivers) + recvs := NewReceivers(factories) conf := confmap.NewFromStringMap(map[string]interface{}{ "nop": nil, "nop/myreceiver": nil, }) require.NoError(t, recvs.Unmarshal(conf)) - cfgWithName := factories.Receivers["nop"].CreateDefaultConfig() + cfgWithName := factories["nop"].CreateDefaultConfig() cfgWithName.SetIDName("myreceiver") //nolint:staticcheck assert.Equal(t, map[component.ID]component.Config{ - component.NewID("nop"): factories.Receivers["nop"].CreateDefaultConfig(), + component.NewID("nop"): factories["nop"].CreateDefaultConfig(), component.NewIDWithName("nop", "myreceiver"): cfgWithName, }, recvs.GetReceivers()) } @@ -100,12 +100,12 @@ func TestReceiversUnmarshalError(t *testing.T) { }, } - factories, err := componenttest.NopFactories() + factories, err := component.MakeReceiverFactoryMap(componenttest.NewNopReceiverFactory()) assert.NoError(t, err) for _, tt := range testCases { t.Run(tt.name, func(t *testing.T) { - recvs := NewReceivers(factories.Receivers) + recvs := NewReceivers(factories) err = recvs.Unmarshal(tt.conf) require.Error(t, err) assert.Contains(t, err.Error(), tt.expectedError)