1
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

32 lines
666 B

package metricutil
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestLabelNameSanitization(t *testing.T) {
testcases := []struct {
input string
expected string
err bool
}{
{input: "job", expected: "job"},
{input: "job._loal['", expected: "job_loal"},
{input: "", expected: "", err: true},
{input: ";;;", expected: "", err: true},
{input: "Data source", expected: "Data_source"},
}
for _, tc := range testcases {
got, err := SanitizeLabelName(tc.input)
if tc.err {
assert.Error(t, err)
} else {
require.NoError(t, err)
assert.Equal(t, tc.expected, got)
}
}
}