Files
multica/server/internal/metrics/config_test.go
devv-eve f864a07bd5 feat: add server Prometheus metrics endpoint
Add Prometheus metrics endpoint with local-bind listener support and baseline metrics collectors.
2026-04-28 14:29:01 +08:00

28 lines
547 B
Go

package metrics
import "testing"
func TestIsLoopbackAddr(t *testing.T) {
tests := []struct {
addr string
want bool
}{
{"127.0.0.1:9090", true},
{"localhost:9090", true},
{"[::1]:9090", true},
{":9090", false},
{"0.0.0.0:9090", false},
{"10.0.0.5:9090", false},
{"metrics.example.com:9090", false},
{"", false},
}
for _, tt := range tests {
t.Run(tt.addr, func(t *testing.T) {
if got := IsLoopbackAddr(tt.addr); got != tt.want {
t.Fatalf("IsLoopbackAddr(%q) = %v, want %v", tt.addr, got, tt.want)
}
})
}
}