Files
minstrel/internal/recommendation/home_test.go
T
bvandeusenandClaude Opus 5.5 4ca6c6be38 fix(home): a section that panics fails the Home call instead of the server (#8124)
HomeData loads its seven sections in bare goroutines joined by a
WaitGroup. A panic in one of them was off the request's goroutine, out
of the HTTP recoverer's reach, and would stop the whole server. The
sections now run through one helper that recovers a panic into that
section's error, with the stack, so the call fails as a query error
fails it. They stay request-scoped: each uses the request's context and
the call waits for all of them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-28 11:54:54 -05:00

23 lines
652 B
Go

package recommendation
import (
"context"
"strings"
"testing"
"github.com/jackc/pgx/v5/pgtype"
)
// A section that panics fails the call with its stage named, as a query
// error does, rather than stopping the server from a goroutine nobody
// recovers. With no pool, every section's first query panics.
func TestHomeData_APanickingSectionIsAnError(t *testing.T) {
_, err := HomeData(context.Background(), nil, pgtype.UUID{Valid: true})
if err == nil {
t.Fatal("HomeData with no pool: no error, want the panic as one")
}
if !strings.Contains(err.Error(), "panicked") {
t.Errorf("err = %v, want it to say the section panicked", err)
}
}