123456789101112131415161718192021222324252627282930313233343536 |
- // Copyright The OpenTelemetry Authors
- // SPDX-License-Identifier: Apache-2.0
- package memcachedreceiver
- import (
- "context"
- "path/filepath"
- "testing"
- "time"
- "github.com/stretchr/testify/require"
- "go.opentelemetry.io/collector/receiver/receivertest"
- "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/golden"
- "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatatest/pmetrictest"
- )
- func TestScraper(t *testing.T) {
- f := NewFactory()
- cfg := f.CreateDefaultConfig().(*Config)
- scraper := newMemcachedScraper(receivertest.NewNopCreateSettings(), cfg)
- scraper.newClient = func(endpoint string, timeout time.Duration) (client, error) {
- return &fakeClient{}, nil
- }
- actualMetrics, err := scraper.scrape(context.Background())
- require.NoError(t, err)
- expectedFile := filepath.Join("testdata", "scraper", "expected.yaml")
- expectedMetrics, err := golden.ReadMetrics(expectedFile)
- require.NoError(t, err)
- require.NoError(t, pmetrictest.CompareMetrics(expectedMetrics, actualMetrics,
- pmetrictest.IgnoreMetricDataPointsOrder(), pmetrictest.IgnoreStartTimestamp(), pmetrictest.IgnoreTimestamp()))
- }
|