-
Notifications
You must be signed in to change notification settings - Fork 2.4k
/
normalize_label_test.go
35 lines (25 loc) · 1.12 KB
/
normalize_label_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
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
package prometheus // import "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/translator/prometheus"
import (
"testing"
"github.com/stretchr/testify/require"
"github.com/open-telemetry/opentelemetry-collector-contrib/internal/common/testutil"
)
func TestSanitize(t *testing.T) {
defer testutil.SetFeatureGateForTest(t, dropSanitizationGate, false)()
require.Equal(t, "", NormalizeLabel(""), "")
require.Equal(t, "key_test", NormalizeLabel("_test"))
require.Equal(t, "key_0test", NormalizeLabel("0test"))
require.Equal(t, "test", NormalizeLabel("test"))
require.Equal(t, "test__", NormalizeLabel("test_/"))
require.Equal(t, "__test", NormalizeLabel("__test"))
}
func TestSanitizeDropSanitization(t *testing.T) {
defer testutil.SetFeatureGateForTest(t, dropSanitizationGate, true)()
require.Equal(t, "", NormalizeLabel(""))
require.Equal(t, "_test", NormalizeLabel("_test"))
require.Equal(t, "key_0test", NormalizeLabel("0test"))
require.Equal(t, "test", NormalizeLabel("test"))
require.Equal(t, "__test", NormalizeLabel("__test"))
}