feat: add profiling recipes
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
||||
"context"
|
||||
"io"
|
||||
"log"
|
||||
"mal/internal/config"
|
||||
"mal/internal/observability"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
@@ -35,6 +36,23 @@ func TestNewHTTPServer_TimeoutsAndAddr(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestProvideRouterRegistersPprof(t *testing.T) {
|
||||
gin.SetMode(gin.TestMode)
|
||||
|
||||
router := ProvideRouter(config.Config{GinMode: gin.TestMode}, nil, observability.NewMetrics())
|
||||
req := httptest.NewRequestWithContext(context.Background(), http.MethodGet, "/debug/pprof/", nil)
|
||||
rec := httptest.NewRecorder()
|
||||
|
||||
router.ServeHTTP(rec, req)
|
||||
|
||||
if rec.Code != http.StatusOK {
|
||||
t.Fatalf("pprof status = %d, want %d", rec.Code, http.StatusOK)
|
||||
}
|
||||
if !strings.Contains(rec.Body.String(), "Types of profiles available") {
|
||||
t.Fatalf("pprof index missing profile list: %s", rec.Body.String())
|
||||
}
|
||||
}
|
||||
|
||||
func TestRequestLoggerUsesMatchedRoute(t *testing.T) {
|
||||
gin.SetMode(gin.TestMode)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user