The first public release of Fabled Minstrel #158

Merged
bvandeusen merged 256 commits from dev into main 2026-12-03 21:41:58 -05:00
Showing only changes of commit 0eae7a247a - Show all commits
+5 -34
View File
@@ -430,13 +430,10 @@ func TestTickOnce_NoMBIDOnTrack_Skipped(t *testing.T) {
} }
} }
// TestUpsertArtistSimilar_PersistsUnmatchedToTable: M5c. Calls // Of ListenBrainz's similar artists, only those the library holds are kept:
// upsertArtistSimilar directly with a mix of in-library and out-of-library // the in-library one lands in artist_similarity, scored against the seed's
// similar-artist payloads; verifies the matched path lands in // best, and the artists the library doesn't have are not stored.
// artist_similarity (1 row), the unmatched path lands in func TestUpsertArtistSimilar_KeepsOnlyLibraryArtists(t *testing.T) {
// 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) {
f := newFixture(t) f := newFixture(t)
ctx := context.Background() 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-1", Name: "Outsider One", Score: 850},
{MBID: "out-mbid-2", Name: "Outsider Two", Score: 800}, {MBID: "out-mbid-2", Name: "Outsider Two", Score: 800},
{MBID: "out-mbid-3", Name: "Outsider Three", Score: 700}, {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) w.upsertArtistSimilar(ctx, f.q, f.artist.ID, similars)
@@ -482,32 +479,6 @@ func TestUpsertArtistSimilar_PersistsUnmatchedToTable(t *testing.T) {
if matchedScore != 1.0 { if matchedScore != 1.0 {
t.Errorf("matched score = %v, want 1.0 (the seed's best)", matchedScore) 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. // recordFetch stamps a seed as answered by ListenBrainz at the given SQL time.