Follow up to f3764b2545: Update error code used for panics in unit tests

This commit is contained in:
David Dworken 2023-09-30 22:22:31 -07:00
parent f9372dda75
commit ce883279f7
No known key found for this signature in database
2 changed files with 4 additions and 4 deletions

View File

@ -106,7 +106,7 @@ func withLogging(s *statsd.Client, out io.Writer) Middleware {
} }
} }
// withPanicGuard is the last defence from a panic. it will log them and return a 500 error // withPanicGuard is the last defence from a panic. it will log them and return a 503 error
// to the client and prevent the http server from breaking // to the client and prevent the http server from breaking
func withPanicGuard() Middleware { func withPanicGuard() Middleware {
return func(h http.Handler) http.Handler { return func(h http.Handler) http.Handler {

View File

@ -101,8 +101,8 @@ func TestPanicGuard(t *testing.T) {
if panicked { if panicked {
t.Fatalf("expected no panic") t.Fatalf("expected no panic")
} }
if w.Code != http.StatusInternalServerError { if w.Code != http.StatusServiceUnavailable {
t.Errorf("expected status %d, got %d", http.StatusInternalServerError, w.Code) t.Errorf("expected status %d, got %d", http.StatusServiceUnavailable, w.Code)
} }
} }
@ -162,7 +162,7 @@ func TestMergeMiddlewares(t *testing.T) {
{ {
name: "panics", name: "panics",
handler: panicHandler, handler: panicHandler,
expectedStatusCode: http.StatusInternalServerError, expectedStatusCode: http.StatusServiceUnavailable,
expectedPieces: []string{ expectedPieces: []string{
`oh no`, `oh no`,
`127.0.0.1 GET "/"`, `127.0.0.1 GET "/"`,