diff --git a/internal/similarity/worker_integration_test.go b/internal/similarity/worker_integration_test.go index dea811b2..dfa35f96 100644 --- a/internal/similarity/worker_integration_test.go +++ b/internal/similarity/worker_integration_test.go @@ -430,13 +430,10 @@ func TestTickOnce_NoMBIDOnTrack_Skipped(t *testing.T) { } } -// TestUpsertArtistSimilar_PersistsUnmatchedToTable: M5c. Calls -// upsertArtistSimilar directly with a mix of in-library and out-of-library -// similar-artist payloads; verifies the matched path lands in -// artist_similarity (1 row), the unmatched path lands in -// artist_similarity_unmatched (3 rows), and rows with empty Name are -// skipped (we can't render a suggestion without a name). -func TestUpsertArtistSimilar_PersistsUnmatchedToTable(t *testing.T) { +// Of ListenBrainz's similar artists, only those the library holds are kept: +// the in-library one lands in artist_similarity, scored against the seed's +// best, and the artists the library doesn't have are not stored. +func TestUpsertArtistSimilar_KeepsOnlyLibraryArtists(t *testing.T) { f := newFixture(t) ctx := context.Background() @@ -457,7 +454,7 @@ func TestUpsertArtistSimilar_PersistsUnmatchedToTable(t *testing.T) { {MBID: "out-mbid-1", Name: "Outsider One", Score: 850}, {MBID: "out-mbid-2", Name: "Outsider Two", Score: 800}, {MBID: "out-mbid-3", Name: "Outsider Three", Score: 700}, - {MBID: "out-mbid-4", Name: "", Score: 600}, // empty name — skipped + {MBID: "out-mbid-4", Name: "", Score: 600}, } w.upsertArtistSimilar(ctx, f.q, f.artist.ID, similars) @@ -482,32 +479,6 @@ func TestUpsertArtistSimilar_PersistsUnmatchedToTable(t *testing.T) { if matchedScore != 1.0 { t.Errorf("matched score = %v, want 1.0 (the seed's best)", matchedScore) } - - // Unmatched path: 3 rows (out-mbid-1/2/3); the empty-name row is skipped. - var unmatchedCount int - if err := f.pool.QueryRow(ctx, - "SELECT count(*) FROM artist_similarity_unmatched WHERE seed_artist_id = $1", - f.artist.ID, - ).Scan(&unmatchedCount); err != nil { - t.Fatalf("count unmatched: %v", err) - } - if unmatchedCount != 3 { - t.Errorf("artist_similarity_unmatched rows = %d, want 3", unmatchedCount) - } - - // Verify a specific row's name + score round-tripped correctly. - var name string - var score float64 - if err := f.pool.QueryRow(ctx, - "SELECT candidate_name, score FROM artist_similarity_unmatched WHERE seed_artist_id = $1 AND candidate_mbid = $2", - f.artist.ID, "out-mbid-1", - ).Scan(&name, &score); err != nil { - t.Fatalf("fetch out-mbid-1: %v", err) - } - if name != "Outsider One" || score != 0.85 { - t.Errorf("row = (%q, %v), want (Outsider One, 0.85)", name, score) - } - } // recordFetch stamps a seed as answered by ListenBrainz at the given SQL time.