config_test.go 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. // Copyright The OpenTelemetry Authors
  2. // SPDX-License-Identifier: Apache-2.0
  3. package azureblobreceiver // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/azureblobreceiver"
  4. import (
  5. "path/filepath"
  6. "testing"
  7. "github.com/stretchr/testify/assert"
  8. "github.com/stretchr/testify/require"
  9. "go.opentelemetry.io/collector/component"
  10. "go.opentelemetry.io/collector/component/componenttest"
  11. "go.opentelemetry.io/collector/otelcol/otelcoltest"
  12. "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/azureblobreceiver/internal/metadata"
  13. )
  14. func TestLoadConfig(t *testing.T) {
  15. factories, err := otelcoltest.NopFactories()
  16. assert.NoError(t, err)
  17. factory := NewFactory()
  18. factories.Receivers[metadata.Type] = factory
  19. cfg, err := otelcoltest.LoadConfigAndValidate(filepath.Join("testdata", "config.yaml"), factories)
  20. require.NoError(t, err)
  21. require.NotNil(t, cfg)
  22. assert.Equal(t, len(cfg.Receivers), 2)
  23. receiver := cfg.Receivers[component.NewID(metadata.Type)]
  24. assert.Equal(t, factory.CreateDefaultConfig(), receiver)
  25. receiver = cfg.Receivers[component.NewIDWithName(metadata.Type, "2")].(*Config)
  26. assert.NoError(t, componenttest.CheckConfigStruct(receiver))
  27. assert.Equal(
  28. t,
  29. &Config{
  30. ConnectionString: goodConnectionString,
  31. Logs: LogsConfig{ContainerName: logsContainerName},
  32. Traces: TracesConfig{ContainerName: tracesContainerName},
  33. },
  34. receiver)
  35. }