-
Notifications
You must be signed in to change notification settings - Fork 2.5k
/
Copy pathscraper_test.go
36 lines (28 loc) · 1.09 KB
/
scraper_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// 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.NewNopSettings(), cfg)
scraper.newClient = func(string, 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()))
}