diff --git a/receiver/apachesparkreceiver/client_test.go b/receiver/apachesparkreceiver/client_test.go index 956bccc8f4d0..6a113c9233f4 100644 --- a/receiver/apachesparkreceiver/client_test.go +++ b/receiver/apachesparkreceiver/client_test.go @@ -28,6 +28,8 @@ const ( ) func TestNewApacheSparkClient(t *testing.T) { + clientConfig := confighttp.NewDefaultClientConfig() + clientConfig.Endpoint = defaultEndpoint testCases := []struct { desc string cfg *Config @@ -39,9 +41,7 @@ func TestNewApacheSparkClient(t *testing.T) { { desc: "Valid Configuration", cfg: &Config{ - ClientConfig: confighttp.ClientConfig{ - Endpoint: defaultEndpoint, - }, + ClientConfig: clientConfig, }, host: componenttest.NewNopHost(), settings: componenttest.NewNopTelemetrySettings(), diff --git a/receiver/apachesparkreceiver/config_test.go b/receiver/apachesparkreceiver/config_test.go index ec4af2033d67..189be4826945 100644 --- a/receiver/apachesparkreceiver/config_test.go +++ b/receiver/apachesparkreceiver/config_test.go @@ -12,6 +12,8 @@ import ( ) func TestValidate(t *testing.T) { + clientConfig := confighttp.NewDefaultClientConfig() + clientConfig.Endpoint = "invalid://endpoint 12efg" testCases := []struct { desc string cfg *Config @@ -27,9 +29,7 @@ func TestValidate(t *testing.T) { { desc: "invalid endpoint", cfg: &Config{ - ClientConfig: confighttp.ClientConfig{ - Endpoint: "invalid://endpoint 12efg", - }, + ClientConfig: clientConfig, ControllerConfig: scraperhelper.NewDefaultControllerConfig(), }, expectedErr: errInvalidEndpoint, diff --git a/receiver/apachesparkreceiver/factory.go b/receiver/apachesparkreceiver/factory.go index a0e164d375b3..83959388be70 100644 --- a/receiver/apachesparkreceiver/factory.go +++ b/receiver/apachesparkreceiver/factory.go @@ -30,12 +30,11 @@ func NewFactory() receiver.Factory { func createDefaultConfig() component.Config { cfg := scraperhelper.NewDefaultControllerConfig() cfg.CollectionInterval = defaultCollectionInterval - + clientConfig := confighttp.NewDefaultClientConfig() + clientConfig.Endpoint = defaultEndpoint return &Config{ - ControllerConfig: cfg, - ClientConfig: confighttp.ClientConfig{ - Endpoint: defaultEndpoint, - }, + ControllerConfig: cfg, + ClientConfig: clientConfig, MetricsBuilderConfig: metadata.DefaultMetricsBuilderConfig(), } } diff --git a/receiver/apachesparkreceiver/factory_test.go b/receiver/apachesparkreceiver/factory_test.go index b72cf8d32125..ed628decbdd7 100644 --- a/receiver/apachesparkreceiver/factory_test.go +++ b/receiver/apachesparkreceiver/factory_test.go @@ -19,6 +19,9 @@ import ( ) func TestNewFactory(t *testing.T) { + clientConfig := confighttp.NewDefaultClientConfig() + clientConfig.Endpoint = defaultEndpoint + testCases := []struct { desc string testFunc func(*testing.T) @@ -40,9 +43,7 @@ func TestNewFactory(t *testing.T) { CollectionInterval: defaultCollectionInterval, InitialDelay: time.Second, }, - ClientConfig: confighttp.ClientConfig{ - Endpoint: defaultEndpoint, - }, + ClientConfig: clientConfig, MetricsBuilderConfig: metadata.DefaultMetricsBuilderConfig(), } diff --git a/receiver/apachesparkreceiver/scraper_test.go b/receiver/apachesparkreceiver/scraper_test.go index 90fd6190ca0b..8cdd323d692a 100644 --- a/receiver/apachesparkreceiver/scraper_test.go +++ b/receiver/apachesparkreceiver/scraper_test.go @@ -35,6 +35,8 @@ const ( ) func TestScraper(t *testing.T) { + clientConfig := confighttp.NewDefaultClientConfig() + clientConfig.Endpoint = defaultEndpoint testcases := []struct { desc string setupMockClient func(t *testing.T) client @@ -68,10 +70,8 @@ func TestScraper(t *testing.T) { config: &Config{ControllerConfig: scraperhelper.ControllerConfig{ CollectionInterval: defaultCollectionInterval, }, - ApplicationNames: []string{"local-123", "local-987"}, - ClientConfig: confighttp.ClientConfig{ - Endpoint: defaultEndpoint, - }, + ApplicationNames: []string{"local-123", "local-987"}, + ClientConfig: clientConfig, MetricsBuilderConfig: metadata.DefaultMetricsBuilderConfig(), }, expectedErr: errNoMatchingAllowedApps, @@ -215,10 +215,8 @@ func TestScraper(t *testing.T) { config: &Config{ControllerConfig: scraperhelper.ControllerConfig{ CollectionInterval: defaultCollectionInterval, }, - ApplicationNames: []string{"streaming-example"}, - ClientConfig: confighttp.ClientConfig{ - Endpoint: defaultEndpoint, - }, + ApplicationNames: []string{"streaming-example"}, + ClientConfig: clientConfig, MetricsBuilderConfig: metadata.DefaultMetricsBuilderConfig(), }, expectedErr: nil,