-
Notifications
You must be signed in to change notification settings - Fork 2.7k
/
Copy pathfactory_test.go
56 lines (47 loc) · 1.15 KB
/
factory_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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
package elasticsearchreceiver
import (
"context"
"testing"
"github.com/stretchr/testify/require"
"go.opentelemetry.io/collector/consumer/consumertest"
"go.opentelemetry.io/collector/receiver/receivertest"
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/elasticsearchreceiver/internal/metadata"
)
func TestCreateMetrics(t *testing.T) {
testCases := []struct {
desc string
run func(t *testing.T)
}{
{
desc: "Default config",
run: func(t *testing.T) {
t.Parallel()
_, err := createMetricsReceiver(
context.Background(),
receivertest.NewNopSettings(metadata.Type),
createDefaultConfig(),
consumertest.NewNop(),
)
require.NoError(t, err)
},
},
{
desc: "Nil config",
run: func(t *testing.T) {
t.Parallel()
_, err := createMetricsReceiver(
context.Background(),
receivertest.NewNopSettings(metadata.Type),
nil,
consumertest.NewNop(),
)
require.ErrorIs(t, err, errConfigNotES)
},
},
}
for _, testCase := range testCases {
t.Run(testCase.desc, testCase.run)
}
}