123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- // Copyright The OpenTelemetry Authors
- // SPDX-License-Identifier: Apache-2.0
- package redisreceiver
- import (
- "path/filepath"
- "testing"
- "time"
- "github.com/stretchr/testify/assert"
- "github.com/stretchr/testify/require"
- "go.opentelemetry.io/collector/component"
- "go.opentelemetry.io/collector/config/confignet"
- "go.opentelemetry.io/collector/config/configtls"
- "go.opentelemetry.io/collector/confmap/confmaptest"
- "go.opentelemetry.io/collector/receiver/scraperhelper"
- "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/redisreceiver/internal/metadata"
- )
- func TestConfig(t *testing.T) {
- cm, err := confmaptest.LoadConf(filepath.Join("testdata", "config.yaml"))
- require.NoError(t, err)
- factory := NewFactory()
- cfg := factory.CreateDefaultConfig()
- sub, err := cm.Sub(component.NewIDWithName(metadata.Type, "").String())
- require.NoError(t, err)
- require.NoError(t, component.UnmarshalConfig(sub, cfg))
- assert.Equal(t,
- &Config{
- NetAddr: confignet.NetAddr{
- Endpoint: "localhost:6379",
- Transport: "tcp",
- },
- TLS: configtls.TLSClientSetting{
- Insecure: true,
- },
- Username: "test",
- Password: "test",
- ScraperControllerSettings: scraperhelper.ScraperControllerSettings{
- CollectionInterval: 10 * time.Second,
- InitialDelay: time.Second,
- },
- MetricsBuilderConfig: metadata.DefaultMetricsBuilderConfig(),
- },
- cfg,
- )
- }
|