github.com/argoproj/argo-cd/v3@v3.2.1/util/metrics/metrics_test.go (about) 1 package metrics 2 3 import ( 4 "testing" 5 6 "github.com/stretchr/testify/assert" 7 ) 8 9 func TestNormalizeLabels(t *testing.T) { 10 inputLabels := []string{ 11 "already_normalized", 12 "replace-dash", 13 "replace$unallowed_char", 14 "app.kubernetes.instance/test", 15 "", 16 "-starts-with_dash", 17 } 18 19 expectedNormalizedLabels := []string{ 20 "prefix_already_normalized", 21 "prefix_replace_dash", 22 "prefix_replace_unallowed_char", 23 "prefix_app_kubernetes_instance_test", 24 "prefix_", 25 "prefix__starts_with_dash", 26 } 27 28 output := NormalizeLabels("prefix", inputLabels) 29 assert.Equal(t, expectedNormalizedLabels, output) 30 }