Files
worker/app/models/check_metric_test.go
Gleb Tv 2c7a0236da feat: publish standalone worker
Separate worker packaging and service lifecycle from the control plane.
2026-07-13 17:55:14 +03:00

43 строки
851 B
Go

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)
}
}
})
}
}