package server import ( "log/slog" "net/http" "github.com/getsentry/sentry-go" "sneak.berlin/go/webhooker/internal/config" "sneak.berlin/go/webhooker/internal/handlers" "sneak.berlin/go/webhooker/internal/middleware" ) // MaxFormBodySizeForTest exposes the form body cap so tests can // build requests that sit exactly at, below, and above it. const MaxFormBodySizeForTest = maxFormBodySize // ScrubSentryRequestForTest exposes the BeforeSend hook that // enableSentry installs, so a test can assert on what it leaves in an // event without standing up a Sentry client. func ScrubSentryRequestForTest( event *sentry.Event, hint *sentry.EventHint, ) *sentry.Event { return scrubSentryRequest(event, hint) } // SentryClientOptionsForTest exposes the exact options enableSentry // initialises the SDK with, so a test can capture events through the // production hook wiring rather than a hand-built equivalent. func SentryClientOptionsForTest( dsn, release string, ) sentry.ClientOptions { return sentryClientOptions(dsn, release) } // NewRouterForTest builds the real route tree via SetupRoutes with // the supplied middleware and handlers, bypassing the fx lifecycle // and the HTTP listener. Tests use it so that route-group middleware // registration order is exercised exactly as it ships, rather than // against a hand-rebuilt chain that could drift from routes.go. func NewRouterForTest( log *slog.Logger, cfg *config.Config, mw *middleware.Middleware, h *handlers.Handlers, ) http.Handler { s := &Server{ log: log, mw: mw, h: h, params: ServerParams{Config: cfg}, } s.SetupRoutes() return s.router }