test(playlists): name a mix by its seed artist too in the rebuild-keeps-ids test (#8081)
release / go (push) Successful in 1m48s
release / web (push) Successful in 1m17s
release / govulncheck (push) Successful in 20s
release / integration (push) Successful in 4m17s
release / android (push) Successful in 4m24s
release / Build signed APK (push) Successful in 4m52s
release / Attach APK to the Release (tag releases only) (push) Skipped
release / Build + push container image (push) Successful in 24s
release / Verify release artifacts (tag releases only) (push) Skipped
release / go (push) Successful in 1m48s
release / web (push) Successful in 1m17s
release / govulncheck (push) Successful in 20s
release / integration (push) Successful in 4m17s
release / android (push) Successful in 4m24s
release / Build signed APK (push) Successful in 4m52s
release / Attach APK to the Release (tag releases only) (push) Skipped
release / Build + push container image (push) Successful in 24s
release / Verify release artifacts (tag releases only) (push) Skipped
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 <noreply@anthropic.com>
This commit is contained in:
@@ -238,20 +238,33 @@ func TestBuildSystemPlaylists_ARebuildKeepsEachMixsID(t *testing.T) {
|
|||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
dir := t.TempDir()
|
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 {
|
list := func() map[string]pgtype.UUID {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
rows, err := dbq.New(pool).ListPlaylistsByUserAndKind(ctx, dbq.ListPlaylistsByUserAndKindParams{
|
rows, err := pool.Query(ctx, `
|
||||||
UserID: u.ID, Column2: "system",
|
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 {
|
if err != nil {
|
||||||
t.Fatalf("list: %v", err)
|
t.Fatalf("list: %v", err)
|
||||||
}
|
}
|
||||||
|
defer rows.Close()
|
||||||
out := map[string]pgtype.UUID{}
|
out := map[string]pgtype.UUID{}
|
||||||
for _, r := range rows {
|
for rows.Next() {
|
||||||
if _, dup := out[r.Name]; dup {
|
var mix string
|
||||||
t.Fatalf("mix %q is held twice after a rebuild", r.Name)
|
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
|
return out
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user