mirror of
https://github.com/multica-ai/multica.git
synced 2026-07-25 12:05:06 +02:00
Add Prometheus metrics endpoint with local-bind listener support and baseline metrics collectors.
28 lines
547 B
Go
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)
|
|
}
|
|
})
|
|
}
|
|
}
|