-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Expand file tree
/
Copy pathnot_helper_test.go
More file actions
45 lines (38 loc) · 1.29 KB
/
not_helper_test.go
File metadata and controls
45 lines (38 loc) · 1.29 KB
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
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
package tailsamplingprocessor
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.opentelemetry.io/collector/component/componenttest"
"go.uber.org/zap"
"github.com/open-telemetry/opentelemetry-collector-contrib/processor/tailsamplingprocessor/internal/sampling"
)
func TestNotHelper(t *testing.T) {
t.Run("valid", func(t *testing.T) {
actual, err := getNewNotPolicy(componenttest.NewNopTelemetrySettings(), &NotCfg{
SubPolicy: NotSubPolicyCfg{
sharedPolicyCfg: sharedPolicyCfg{
Name: "test-not-policy-1",
Type: Latency,
LatencyCfg: LatencyCfg{ThresholdMs: 100},
},
},
}, nil)
require.NoError(t, err)
expected := sampling.NewNot(zap.NewNop(), sampling.NewLatency(componenttest.NewNopTelemetrySettings(), 100, 0))
assert.Equal(t, expected, actual)
})
t.Run("unsupported sampling policy type", func(t *testing.T) {
_, err := getNewNotPolicy(componenttest.NewNopTelemetrySettings(), &NotCfg{
SubPolicy: NotSubPolicyCfg{
sharedPolicyCfg: sharedPolicyCfg{
Name: "test-not-policy-2",
Type: Not, // nested not is not allowed
},
},
}, nil)
require.EqualError(t, err, "unknown sampling policy type not")
})
}