package server import ( "net/http" "time" "github.com/go-chi/chi/v5" ) // RequestTimeout exports the handler execution budget applied by // chimw.Timeout in SetupRoutes, so tests can assert the relationship // between it and the server's WriteTimeout. const RequestTimeout time.Duration = requestTimeout // SetListenPort overrides the port Run binds. A test uses it to hand // Run an unbindable port so ListenAndServe fails immediately and Run // returns after storing its http.Server. func SetListenPort(s *Server, port int) { s.port = port } // HTTPServerOf returns the http.Server that Run built and stored, so a // test can inspect the timeouts the running server actually carries. func HTTPServerOf(s *Server) *http.Server { return s.httpServer } // EnableSentry runs the Sentry setup that the start hook runs, without // starting the HTTP server. func EnableSentry(s *Server) error { return s.enableSentry() } // RouterOf returns the router SetupRoutes built, so a test can add a // route that panics. func RouterOf(s *Server) *chi.Mux { return s.router }