check / check (push) Waiting to run
The HTTP server ran ListenAndServe in a goroutine, so a failed bind was only logged and neoircd kept running without its HTTP API. The start hook now binds the listen address and returns the bind error, so neoircd exits 1 with an error naming the address. If serving the bound listener later ends with anything other than a normal shutdown, the server stops the app through fx.Shutdowner with exit code 1; the handler tests now pass it that Shutdowner. Tests check that a taken port fails startup, that a serve failure stops the app with exit code 1, and that a normal stop does not. The server tests no longer run in parallel: building the app writes the global viper instance. Model: opus-5-5
23 lines
478 B
Go
23 lines
478 B
Go
package server
|
|
|
|
import (
|
|
"net"
|
|
|
|
"github.com/go-chi/chi/v5"
|
|
)
|
|
|
|
// NewTestSPAServer creates a Server whose router serves only
|
|
// the embedded web client.
|
|
func NewTestSPAServer() *Server {
|
|
srv := &Server{router: chi.NewRouter()}
|
|
srv.setupSPA()
|
|
|
|
return srv
|
|
}
|
|
|
|
// ServeUntilShutdown runs serveUntilShutdown, which serves the
|
|
// HTTP server on listener, and returns when it does.
|
|
func (srv *Server) ServeUntilShutdown(listener net.Listener) {
|
|
srv.serveUntilShutdown(listener)
|
|
}
|