package models import ( "testing" "unicode" "github.com/stretchr/testify/assert" ) func TestCheckMetricName(t *testing.T) { tests := []struct { kind string want string }{ {"http", "chttp"}, {"ssl", "cssl"}, {"bssl", "cbssl"}, {"ssh", "cssh"}, {"ftp", "cftp"}, {"dns", "cdns"}, {"whois", "cwhois"}, {"rkn", "crkn"}, {"llm", "cllm"}, {"llm-http", "cllm_http"}, {"weird-kind", "cweird_kind"}, } for _, tt := range tests { t.Run(tt.kind, func(t *testing.T) { c := &Check{Kind: tt.kind, ID: 1} got := c.MetricName() assert.Equal(t, tt.want, got, "MetricName() for kind %q", tt.kind) metric := got for _, ch := range metric { if !unicode.IsLetter(ch) && !unicode.IsDigit(ch) && ch != '_' && ch != ':' { t.Errorf("metric name %q contains invalid character %q", metric, ch) } } }) } }