From 541698a8b1ad060a249c70cf8f19f1bd88483092 Mon Sep 17 00:00:00 2001 From: Bryan Van Deusen Date: Mon, 27 Apr 2026 20:51:55 -0400 Subject: [PATCH] test(recommendation): check LoadCandidates errors in new contextual tests Code review caught four tests using `got, _` to discard load errors. A DB failure would have surfaced as a misleading "wrong score" assertion rather than a clear "load failed" message. Match the t.Fatalf pattern used by the other LoadCandidates tests in this file. Co-Authored-By: Claude Opus 4.7 --- internal/recommendation/candidates_test.go | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/internal/recommendation/candidates_test.go b/internal/recommendation/candidates_test.go index ca32bd98..0446ba3d 100644 --- a/internal/recommendation/candidates_test.go +++ b/internal/recommendation/candidates_test.go @@ -296,7 +296,10 @@ func TestLoadCandidates_MultipleMatchingLikes_TakesMax(t *testing.T) { }) current := SessionVector{Artists: []string{"a1"}, Tags: map[string]int{"rock": 1}} - got, _ := LoadCandidates(context.Background(), f.q, f.user, f.tracks[0].ID, 1, current) + got, err := LoadCandidates(context.Background(), f.q, f.user, f.tracks[0].ID, 1, current) + if err != nil { + t.Fatalf("load: %v", err) + } for _, c := range got { if c.Track.ID == target.ID && c.Inputs.ContextualMatchScore < 0.99 { t.Errorf("target = %v, want ~1.0 (max)", c.Inputs.ContextualMatchScore) @@ -315,7 +318,10 @@ func TestLoadCandidates_SoftDeletedLikes_Ignored(t *testing.T) { } current := SessionVector{Artists: []string{"a1"}, Tags: map[string]int{"rock": 1}} - got, _ := LoadCandidates(context.Background(), f.q, f.user, f.tracks[0].ID, 1, current) + got, err := LoadCandidates(context.Background(), f.q, f.user, f.tracks[0].ID, 1, current) + if err != nil { + t.Fatalf("load: %v", err) + } for _, c := range got { if c.Inputs.ContextualMatchScore != 0 { t.Errorf("soft-deleted track %s ContextualMatchScore = %v", c.Track.Title, c.Inputs.ContextualMatchScore) @@ -331,7 +337,10 @@ func TestLoadCandidates_OnlySeedLikes_ScoresZero(t *testing.T) { }) current := SessionVector{Artists: []string{"a1"}, Tags: map[string]int{"rock": 1}} - got, _ := LoadCandidates(context.Background(), f.q, f.user, f.tracks[0].ID, 1, current) + got, err := LoadCandidates(context.Background(), f.q, f.user, f.tracks[0].ID, 1, current) + if err != nil { + t.Fatalf("load: %v", err) + } for _, c := range got { if c.Inputs.ContextualMatchScore != 0 { t.Errorf("seed-only track %s ContextualMatchScore = %v", c.Track.Title, c.Inputs.ContextualMatchScore) @@ -346,7 +355,10 @@ func TestLoadCandidates_CurrentSeed_ScoresZero(t *testing.T) { helperInsertContextualLike(t, f, target.ID, likeVec) currentSeed := SessionVector{Seed: true} - got, _ := LoadCandidates(context.Background(), f.q, f.user, f.tracks[0].ID, 1, currentSeed) + got, err := LoadCandidates(context.Background(), f.q, f.user, f.tracks[0].ID, 1, currentSeed) + if err != nil { + t.Fatalf("load: %v", err) + } for _, c := range got { if c.Inputs.ContextualMatchScore != 0 { t.Errorf("seed-current track %s ContextualMatchScore = %v", c.Track.Title, c.Inputs.ContextualMatchScore)