@@ -21,6 +21,7 @@ import (
2121 "testing"
2222
2323 "github.com/prometheus/common/route"
24+ "github.com/stretchr/testify/require"
2425)
2526
2627func TestDebugHandlersWithRoutePrefix (t * testing.T ) {
@@ -37,21 +38,15 @@ func TestDebugHandlersWithRoutePrefix(t *testing.T) {
3738 w := httptest .NewRecorder ()
3839 router .ServeHTTP (w , req )
3940
40- if w .Code != http .StatusOK {
41- t .Errorf ("Expected status %d for %s, got %d. Body: %s" , http .StatusOK , req .URL .Path , w .Code , w .Body .String ())
42- }
43- if w .Body .Len () == 0 {
44- t .Error ("Expected non-empty response body for pprof index" )
45- }
41+ require .Equal (t , http .StatusOK , w .Code )
42+ require .NotEqual (t , 0 , w .Body .Len ())
4643
4744 // Test GET request to pprof heap endpoint
4845 req = httptest .NewRequest ("GET" , routePrefix + "/debug/pprof/heap" , nil )
4946 w = httptest .NewRecorder ()
5047 router .ServeHTTP (w , req )
5148
52- if w .Code != http .StatusOK {
53- t .Errorf ("Expected status %d for %s, got %d" , http .StatusOK , req .URL .Path , w .Code )
54- }
49+ require .Equal (t , http .StatusOK , w .Code )
5550
5651 // Test without route prefix (should also work)
5752 router2 := route .New ()
@@ -61,7 +56,5 @@ func TestDebugHandlersWithRoutePrefix(t *testing.T) {
6156 w = httptest .NewRecorder ()
6257 router2 .ServeHTTP (w , req )
6358
64- if w .Code != http .StatusOK {
65- t .Errorf ("Expected status %d for %s without prefix, got %d" , http .StatusOK , req .URL .Path , w .Code )
66- }
59+ require .Equal (t , http .StatusOK , w .Code )
6760}
0 commit comments