From 40c53c8b983e861aa225a1690619ed76b3f36377 Mon Sep 17 00:00:00 2001 From: Bryan Van Deusen Date: Fri, 27 Nov 2026 00:14:41 -0500 Subject: [PATCH] test(playlists): name a mix by its seed artist too in the rebuild-keeps-ids test (#8081) The fixtures make one artist row per track, all named alike, so two Songs like mixes with different seed artists share a display name, and the test read them as one mix held twice. It now names a mix by name and seed artist, as snapshotSystemTracks does (lesson: a snapshot keyed by display name merges same-named rows). Co-Authored-By: Claude Opus 5.5 --- internal/playlists/system_test.go | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/internal/playlists/system_test.go b/internal/playlists/system_test.go index cdcc1443..a2fef755 100644 --- a/internal/playlists/system_test.go +++ b/internal/playlists/system_test.go @@ -238,20 +238,33 @@ func TestBuildSystemPlaylists_ARebuildKeepsEachMixsID(t *testing.T) { ctx := context.Background() dir := t.TempDir() + // A mix is named by its name AND its seed artist: the fixtures make one + // artist row per track, all named alike, so two Songs like mixes can + // share a name (see snapshotSystemTracks). list := func() map[string]pgtype.UUID { t.Helper() - rows, err := dbq.New(pool).ListPlaylistsByUserAndKind(ctx, dbq.ListPlaylistsByUserAndKindParams{ - UserID: u.ID, Column2: "system", - }) + rows, err := pool.Query(ctx, ` + SELECT p.name || ' [' || COALESCE(p.seed_artist_id::text, '-') || ']', p.id + FROM playlists p + WHERE p.user_id = $1 AND p.kind = 'system'`, u.ID) if err != nil { t.Fatalf("list: %v", err) } + defer rows.Close() out := map[string]pgtype.UUID{} - for _, r := range rows { - if _, dup := out[r.Name]; dup { - t.Fatalf("mix %q is held twice after a rebuild", r.Name) + for rows.Next() { + var mix string + var id pgtype.UUID + if err := rows.Scan(&mix, &id); err != nil { + t.Fatalf("scan: %v", err) } - out[r.Name] = r.ID + if _, dup := out[mix]; dup { + t.Fatalf("mix %q is held twice", mix) + } + out[mix] = id + } + if err := rows.Err(); err != nil { + t.Fatalf("rows: %v", err) } return out }