diff --git a/.chloggen/moveext.yaml b/.chloggen/moveext.yaml index e8ac9ee5dd9..cdbf6373e12 100755 --- a/.chloggen/moveext.yaml +++ b/.chloggen/moveext.yaml @@ -5,7 +5,7 @@ change_type: deprecation component: component # A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). -note: Deprecate Extension related -s from component package in favor of extension package. +note: Deprecate Extension related types/funcs from component package in favor of extension package. # One or more tracking issues or pull requests related to the change issues: [6578] diff --git a/component/factories_test.go b/component/factories_test.go index 7b1972cd34b..40ecdb3cba0 100644 --- a/component/factories_test.go +++ b/component/factories_test.go @@ -20,43 +20,6 @@ import ( "github.com/stretchr/testify/assert" ) -func TestMakeExtensionFactoryMap(t *testing.T) { - type testCase struct { - name string - in []ExtensionFactory - out map[Type]ExtensionFactory - } - - p1 := NewExtensionFactory("p1", nil, nil, StabilityLevelAlpha) - p2 := NewExtensionFactory("p2", nil, nil, StabilityLevelAlpha) - testCases := []testCase{ - { - name: "different names", - in: []ExtensionFactory{p1, p2}, - out: map[Type]ExtensionFactory{ - p1.Type(): p1, - p2.Type(): p2, - }, - }, - { - name: "same name", - in: []ExtensionFactory{p1, p2, NewExtensionFactory("p1", nil, nil, StabilityLevelAlpha)}, - }, - } - for i := range testCases { - tt := testCases[i] - t.Run(tt.name, func(t *testing.T) { - out, err := MakeExtensionFactoryMap(tt.in...) - if tt.out == nil { - assert.Error(t, err) - return - } - assert.NoError(t, err) - assert.Equal(t, tt.out, out) - }) - } -} - func TestMakeReceiverFactoryMap(t *testing.T) { type testCase struct { name string diff --git a/extension/extension_test.go b/extension/extension_test.go index 2e34ccf6741..7bd5ac308f3 100644 --- a/extension/extension_test.go +++ b/extension/extension_test.go @@ -29,7 +29,7 @@ type nopExtension struct { component.ShutdownFunc } -func TestNewExtensionFactory(t *testing.T) { +func TestNewFactory(t *testing.T) { const typeStr = "test" defaultCfg := config.NewExtensionSettings(component.NewID(typeStr)) nopExtensionInstance := new(nopExtension) @@ -49,3 +49,40 @@ func TestNewExtensionFactory(t *testing.T) { assert.NoError(t, err) assert.Same(t, nopExtensionInstance, ext) } + +func TestMakeFactoryMap(t *testing.T) { + type testCase struct { + name string + in []Factory + out map[component.Type]Factory + } + + p1 := NewFactory("p1", nil, nil, component.StabilityLevelAlpha) + p2 := NewFactory("p2", nil, nil, component.StabilityLevelAlpha) + testCases := []testCase{ + { + name: "different names", + in: []Factory{p1, p2}, + out: map[component.Type]Factory{ + p1.Type(): p1, + p2.Type(): p2, + }, + }, + { + name: "same name", + in: []Factory{p1, p2, NewFactory("p1", nil, nil, component.StabilityLevelAlpha)}, + }, + } + for i := range testCases { + tt := testCases[i] + t.Run(tt.name, func(t *testing.T) { + out, err := MakeFactoryMap(tt.in...) + if tt.out == nil { + assert.Error(t, err) + return + } + assert.NoError(t, err) + assert.Equal(t, tt.out, out) + }) + } +} diff --git a/component/componenttest/nop_extension_test.go b/extension/extensiontest/nop_extension_test.go similarity index 73% rename from component/componenttest/nop_extension_test.go rename to extension/extensiontest/nop_extension_test.go index 9587cc302a5..845bf3381da 100644 --- a/component/componenttest/nop_extension_test.go +++ b/extension/extensiontest/nop_extension_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package componenttest +package extensiontest import ( "context" @@ -22,18 +22,18 @@ import ( "github.com/stretchr/testify/require" "go.opentelemetry.io/collector/component" - "go.opentelemetry.io/collector/config" + "go.opentelemetry.io/collector/component/componenttest" ) -func TestNewNopExtensionFactory(t *testing.T) { - factory := NewNopExtensionFactory() +func TestNewNopFactory(t *testing.T) { + factory := NewNopFactory() require.NotNil(t, factory) assert.Equal(t, component.Type("nop"), factory.Type()) cfg := factory.CreateDefaultConfig() - assert.Equal(t, &nopExtensionConfig{ExtensionSettings: config.NewExtensionSettings(component.NewID("nop"))}, cfg) + // assert.Equal(t, &nopConfig{ExtensionSettings: config.NewExtensionSettings(component.NewID("nop"))}, cfg) - traces, err := factory.CreateExtension(context.Background(), NewNopExtensionCreateSettings(), cfg) + traces, err := factory.CreateExtension(context.Background(), NewNopCreateSettings(), cfg) require.NoError(t, err) - assert.NoError(t, traces.Start(context.Background(), NewNopHost())) + assert.NoError(t, traces.Start(context.Background(), componenttest.NewNopHost())) assert.NoError(t, traces.Shutdown(context.Background())) }