diff --git a/internal/middleware/middleware_internal_test.go b/internal/middleware/middleware_internal_test.go index 5801513..404d4eb 100644 --- a/internal/middleware/middleware_internal_test.go +++ b/internal/middleware/middleware_internal_test.go @@ -226,7 +226,8 @@ func TestMetricsRecordsServedRequest(t *testing.T) { // TestMetricsLabelsRequestsByRoute checks that the metrics middleware labels // each request with the pattern of the route that answers it, never with its // path: two paths one route answers share that route's pattern, and requests -// no route answers, a 404 or a 405, share "unmatched". With a label per path, +// no route answers, a 404 or a 405, share "unmatched", among them requests for +// the path the subrouter is mounted at, /v1 and /v1/. With a label per path, // any client could add series to the registry without limit. The middleware // registers with a registry of its own here, as another test in this package // registers with Prometheus' default registry, which can be done only once. @@ -254,6 +255,8 @@ func TestMetricsLabelsRequestsByRoute(t *testing.T) { {http.MethodGet, "/v1/image/b.example.com/two.jpg/1x1.png"}, {http.MethodGet, "/no-such-route"}, {http.MethodGet, "/v1/no-such-route"}, + {http.MethodGet, "/v1"}, + {http.MethodGet, "/v1/"}, {http.MethodPost, "/v1/image/a.example.com/one.jpg/1x1.png"}, } { router.ServeHTTP(httptest.NewRecorder(), httptest.NewRequestWithContext( @@ -263,7 +266,7 @@ func TestMetricsLabelsRequestsByRoute(t *testing.T) { got := requestCountsByHandler(t, registry) t.Logf("requests counted by handler label: %v", got) - want := map[string]uint64{"/v1/image/*": 2, "unmatched": 3} + want := map[string]uint64{"/v1/image/*": 2, "unmatched": 5} if !maps.Equal(got, want) { t.Errorf("requests counted by handler label = %v, want %v", got, want) }