From 0c1c29f61075684548e462fe29a7e6c07fc88a5b Mon Sep 17 00:00:00 2001 From: Pablo Baeyens Date: Thu, 8 Feb 2024 16:33:23 +0100 Subject: [PATCH] [chore] Migrate even more component.Type tests --- processor/remotetapprocessor/factory_test.go | 4 +++- receiver/apachereceiver/factory_test.go | 4 +++- receiver/couchdbreceiver/factory_test.go | 4 +++- receiver/expvarreceiver/factory_test.go | 2 +- receiver/kubeletstatsreceiver/factory_test.go | 3 ++- receiver/memcachedreceiver/factory_test.go | 4 +++- receiver/mongodbreceiver/factory_test.go | 4 +++- receiver/mysqlreceiver/factory_test.go | 4 +++- receiver/nginxreceiver/factory_test.go | 4 +++- receiver/osqueryreceiver/factory_test.go | 4 +++- receiver/postgresqlreceiver/factory_test.go | 4 +++- receiver/purefareceiver/factory_test.go | 5 +++-- receiver/saphanareceiver/factory_test.go | 4 +++- receiver/snowflakereceiver/factory_test.go | 4 +++- receiver/splunkenterprisereceiver/factory_test.go | 2 +- receiver/webhookeventreceiver/factory_test.go | 4 +++- 16 files changed, 43 insertions(+), 17 deletions(-) diff --git a/processor/remotetapprocessor/factory_test.go b/processor/remotetapprocessor/factory_test.go index 628a0c34e7cd..047d8cc2a31e 100644 --- a/processor/remotetapprocessor/factory_test.go +++ b/processor/remotetapprocessor/factory_test.go @@ -7,11 +7,13 @@ import ( "testing" "github.com/stretchr/testify/assert" + + "github.com/open-telemetry/opentelemetry-collector-contrib/processor/remotetapprocessor/internal/metadata" ) func TestNewFactory(t *testing.T) { factory := NewFactory() - assert.EqualValues(t, "remotetap", factory.Type()) + assert.EqualValues(t, metadata.Type, factory.Type()) config := factory.CreateDefaultConfig() assert.NotNil(t, config) } diff --git a/receiver/apachereceiver/factory_test.go b/receiver/apachereceiver/factory_test.go index 98d5f13cfa98..05437004d6f4 100644 --- a/receiver/apachereceiver/factory_test.go +++ b/receiver/apachereceiver/factory_test.go @@ -13,12 +13,14 @@ import ( "go.opentelemetry.io/collector/consumer/consumertest" "go.opentelemetry.io/collector/receiver/receivertest" "go.opentelemetry.io/collector/receiver/scraperhelper" + + "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/apachereceiver/internal/metadata" ) func TestType(t *testing.T) { factory := NewFactory() ft := factory.Type() - require.EqualValues(t, "apache", ft) + require.EqualValues(t, metadata.Type, ft) } func TestValidConfig(t *testing.T) { diff --git a/receiver/couchdbreceiver/factory_test.go b/receiver/couchdbreceiver/factory_test.go index dd1dbb9f64b6..e091e7d8f27d 100644 --- a/receiver/couchdbreceiver/factory_test.go +++ b/receiver/couchdbreceiver/factory_test.go @@ -11,12 +11,14 @@ import ( "go.opentelemetry.io/collector/component" "go.opentelemetry.io/collector/consumer/consumertest" "go.opentelemetry.io/collector/receiver/receivertest" + + "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/couchdbreceiver/internal/metadata" ) func TestType(t *testing.T) { factory := NewFactory() ft := factory.Type() - require.EqualValues(t, "couchdb", ft) + require.EqualValues(t, metadata.Type, ft) } func TestValidConfig(t *testing.T) { diff --git a/receiver/expvarreceiver/factory_test.go b/receiver/expvarreceiver/factory_test.go index 0c00df0b6afe..4a12afc07b8d 100644 --- a/receiver/expvarreceiver/factory_test.go +++ b/receiver/expvarreceiver/factory_test.go @@ -21,7 +21,7 @@ import ( func TestType(t *testing.T) { factory := NewFactory() ft := factory.Type() - require.EqualValues(t, "expvar", ft) + require.EqualValues(t, metadata.Type, ft) } func TestValidConfig(t *testing.T) { diff --git a/receiver/kubeletstatsreceiver/factory_test.go b/receiver/kubeletstatsreceiver/factory_test.go index c4c2c3e5a929..1bc8b23ce4ef 100644 --- a/receiver/kubeletstatsreceiver/factory_test.go +++ b/receiver/kubeletstatsreceiver/factory_test.go @@ -26,12 +26,13 @@ import ( "github.com/open-telemetry/opentelemetry-collector-contrib/internal/k8sconfig" kube "github.com/open-telemetry/opentelemetry-collector-contrib/internal/kubelet" "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/kubeletstatsreceiver/internal/kubelet" + "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/kubeletstatsreceiver/internal/metadata" ) func TestType(t *testing.T) { factory := NewFactory() ft := factory.Type() - require.EqualValues(t, "kubeletstats", ft) + require.EqualValues(t, metadata.Type, ft) } func TestValidConfig(t *testing.T) { diff --git a/receiver/memcachedreceiver/factory_test.go b/receiver/memcachedreceiver/factory_test.go index 6cf7eee8c384..09087e04fa63 100644 --- a/receiver/memcachedreceiver/factory_test.go +++ b/receiver/memcachedreceiver/factory_test.go @@ -13,12 +13,14 @@ import ( "go.opentelemetry.io/collector/consumer/consumertest" "go.opentelemetry.io/collector/receiver/receivertest" "go.opentelemetry.io/collector/receiver/scraperhelper" + + "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/memcachedreceiver/internal/metadata" ) func TestType(t *testing.T) { factory := NewFactory() ft := factory.Type() - require.EqualValues(t, "memcached", ft) + require.EqualValues(t, metadata.Type, ft) } func TestValidConfig(t *testing.T) { diff --git a/receiver/mongodbreceiver/factory_test.go b/receiver/mongodbreceiver/factory_test.go index e59815fbbe86..6eb20f234a55 100644 --- a/receiver/mongodbreceiver/factory_test.go +++ b/receiver/mongodbreceiver/factory_test.go @@ -13,12 +13,14 @@ import ( "go.opentelemetry.io/collector/consumer/consumertest" "go.opentelemetry.io/collector/receiver/receivertest" "go.opentelemetry.io/collector/receiver/scraperhelper" + + "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/mongodbreceiver/internal/metadata" ) func TestType(t *testing.T) { factory := NewFactory() ft := factory.Type() - require.EqualValues(t, "mongodb", ft) + require.EqualValues(t, metadata.Type, ft) } func TestValidConfig(t *testing.T) { diff --git a/receiver/mysqlreceiver/factory_test.go b/receiver/mysqlreceiver/factory_test.go index 76a9a78ef4f3..0f15cc666c6b 100644 --- a/receiver/mysqlreceiver/factory_test.go +++ b/receiver/mysqlreceiver/factory_test.go @@ -14,12 +14,14 @@ import ( "go.opentelemetry.io/collector/consumer/consumertest" "go.opentelemetry.io/collector/receiver/receivertest" "go.opentelemetry.io/collector/receiver/scraperhelper" + + "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/mysqlreceiver/internal/metadata" ) func TestType(t *testing.T) { factory := NewFactory() ft := factory.Type() - require.EqualValues(t, "mysql", ft) + require.EqualValues(t, metadata.Type, ft) } func TestValidConfig(t *testing.T) { diff --git a/receiver/nginxreceiver/factory_test.go b/receiver/nginxreceiver/factory_test.go index 2159dae72563..0116dcc781b9 100644 --- a/receiver/nginxreceiver/factory_test.go +++ b/receiver/nginxreceiver/factory_test.go @@ -13,12 +13,14 @@ import ( "go.opentelemetry.io/collector/consumer/consumertest" "go.opentelemetry.io/collector/receiver/receivertest" "go.opentelemetry.io/collector/receiver/scraperhelper" + + "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/nginxreceiver/internal/metadata" ) func TestType(t *testing.T) { factory := NewFactory() ft := factory.Type() - require.EqualValues(t, "nginx", ft) + require.EqualValues(t, metadata.Type, ft) } func TestValidConfig(t *testing.T) { diff --git a/receiver/osqueryreceiver/factory_test.go b/receiver/osqueryreceiver/factory_test.go index f503210f0dd0..b65a43f7b167 100644 --- a/receiver/osqueryreceiver/factory_test.go +++ b/receiver/osqueryreceiver/factory_test.go @@ -8,11 +8,13 @@ import ( "time" "github.com/stretchr/testify/assert" + + "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/osqueryreceiver/internal/metadata" ) func TestFactory(t *testing.T) { f := NewFactory() - assert.EqualValues(t, "osquery", f.Type()) + assert.EqualValues(t, metadata.Type, f.Type()) cfg := f.CreateDefaultConfig() assert.NotNil(t, cfg) duration, _ := time.ParseDuration("30s") diff --git a/receiver/postgresqlreceiver/factory_test.go b/receiver/postgresqlreceiver/factory_test.go index 7cab26114792..49b454b145b7 100644 --- a/receiver/postgresqlreceiver/factory_test.go +++ b/receiver/postgresqlreceiver/factory_test.go @@ -13,12 +13,14 @@ import ( "go.opentelemetry.io/collector/consumer/consumertest" "go.opentelemetry.io/collector/receiver/receivertest" "go.opentelemetry.io/collector/receiver/scraperhelper" + + "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/postgresqlreceiver/internal/metadata" ) func TestType(t *testing.T) { factory := NewFactory() ft := factory.Type() - require.EqualValues(t, "postgresql", ft) + require.EqualValues(t, metadata.Type, ft) } func TestValidConfig(t *testing.T) { diff --git a/receiver/purefareceiver/factory_test.go b/receiver/purefareceiver/factory_test.go index fb591ad5961a..ba51e2ba482e 100644 --- a/receiver/purefareceiver/factory_test.go +++ b/receiver/purefareceiver/factory_test.go @@ -11,12 +11,13 @@ import ( "go.opentelemetry.io/collector/component" "go.opentelemetry.io/collector/component/componenttest" "go.opentelemetry.io/collector/receiver/receivertest" + + "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/purefareceiver/internal/metadata" ) func TestTypeStr(t *testing.T) { factory := NewFactory() - - assert.Equal(t, "purefa", factory.Type().String()) + assert.Equal(t, metadata.Type, factory.Type()) } func TestCreateDefaultConfig(t *testing.T) { diff --git a/receiver/saphanareceiver/factory_test.go b/receiver/saphanareceiver/factory_test.go index ea126a17cc1e..c76951530f5a 100644 --- a/receiver/saphanareceiver/factory_test.go +++ b/receiver/saphanareceiver/factory_test.go @@ -13,12 +13,14 @@ import ( "go.opentelemetry.io/collector/consumer/consumertest" "go.opentelemetry.io/collector/receiver/receivertest" "go.opentelemetry.io/collector/receiver/scraperhelper" + + "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/saphanareceiver/internal/metadata" ) func TestType(t *testing.T) { factory := NewFactory() ft := factory.Type() - require.EqualValues(t, "saphana", ft) + require.EqualValues(t, metadata.Type, ft) } func TestValidConfig(t *testing.T) { diff --git a/receiver/snowflakereceiver/factory_test.go b/receiver/snowflakereceiver/factory_test.go index f853cb0736b3..a95ef771ec9a 100644 --- a/receiver/snowflakereceiver/factory_test.go +++ b/receiver/snowflakereceiver/factory_test.go @@ -11,11 +11,13 @@ import ( "go.opentelemetry.io/collector/component" "go.opentelemetry.io/collector/consumer/consumertest" "go.opentelemetry.io/collector/receiver/receivertest" + + "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/snowflakereceiver/internal/metadata" ) func TestFacoryCreate(t *testing.T) { factory := NewFactory() - require.EqualValues(t, "snowflake", factory.Type()) + require.EqualValues(t, metadata.Type, factory.Type()) } func TestDefaultConfig(t *testing.T) { diff --git a/receiver/splunkenterprisereceiver/factory_test.go b/receiver/splunkenterprisereceiver/factory_test.go index c0f449f07551..17031d573961 100644 --- a/receiver/splunkenterprisereceiver/factory_test.go +++ b/receiver/splunkenterprisereceiver/factory_test.go @@ -20,7 +20,7 @@ import ( func TestFactoryCreate(t *testing.T) { factory := NewFactory() - require.EqualValues(t, "splunkenterprise", factory.Type()) + require.EqualValues(t, metadata.Type, factory.Type()) } func TestDefaultConfig(t *testing.T) { diff --git a/receiver/webhookeventreceiver/factory_test.go b/receiver/webhookeventreceiver/factory_test.go index 526556e1e6e7..b42bf564a91d 100644 --- a/receiver/webhookeventreceiver/factory_test.go +++ b/receiver/webhookeventreceiver/factory_test.go @@ -10,11 +10,13 @@ import ( "github.com/stretchr/testify/require" "go.opentelemetry.io/collector/consumer/consumertest" "go.opentelemetry.io/collector/receiver/receivertest" + + "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/webhookeventreceiver/internal/metadata" ) func TestFactoryCreate(t *testing.T) { factory := NewFactory() - require.EqualValues(t, "webhookevent", factory.Type()) + require.EqualValues(t, metadata.Type, factory.Type()) } func TestDefaultConfig(t *testing.T) {