mirror of
https://github.com/ferdzo/fs.git
synced 2026-04-04 20:56:25 +00:00
31 lines
751 B
Go
31 lines
751 B
Go
package logging
|
|
|
|
import (
|
|
"net/http/httptest"
|
|
"testing"
|
|
)
|
|
|
|
func TestMetricRouteLabelFallbacks(t *testing.T) {
|
|
testCases := []struct {
|
|
name string
|
|
path string
|
|
want string
|
|
}{
|
|
{name: "root", path: "/", want: "/"},
|
|
{name: "health", path: "/healthz", want: "/healthz"},
|
|
{name: "metrics", path: "/metrics", want: "/metrics"},
|
|
{name: "bucket", path: "/some-bucket", want: "/{bucket}"},
|
|
{name: "object", path: "/some-bucket/private/path/file.jpg", want: "/{bucket}/*"},
|
|
}
|
|
|
|
for _, tc := range testCases {
|
|
t.Run(tc.name, func(t *testing.T) {
|
|
req := httptest.NewRequest("GET", tc.path, nil)
|
|
got := metricRouteLabel(req)
|
|
if got != tc.want {
|
|
t.Fatalf("metricRouteLabel(%q) = %q, want %q", tc.path, got, tc.want)
|
|
}
|
|
})
|
|
}
|
|
}
|