test(playlists): key the same-day snapshot by mix, not by name
release / web (push) Successful in 1m20s
release / go (push) Successful in 1m49s
release / govulncheck (push) Successful in 18s
release / integration (push) Successful in 4m8s
release / android (push) Successful in 4m48s
release / Build signed APK (push) Successful in 5m39s
release / Attach APK to the Release (tag releases only) (push) Skipped
release / Build + push container image (push) Successful in 1m20s
release / Verify release artifacts (tag releases only) (push) Skipped

The fixture makes one artist row per track, so artists share names, and
with twelve Songs like mixes two can both be "Songs like X". Keyed by
name, their tracks merged and interleaved in tie order, so the snapshot
varied though the mixes did not. Name plus seed artist identifies a mix.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-24 09:17:17 -05:00
co-authored by Claude Opus 5.5
parent e4728e003a
commit e71c132cc7
+11 -4
View File
@@ -445,16 +445,23 @@ func TestBuildSystemPlaylists_DailyNonceDeterminism(t *testing.T) {
} }
} }
// snapshotSystemTracks returns a per-playlist-name → []track_id mapping // snapshotSystemTracks returns a per-mix → []track_id mapping for the
// for the user's system playlists, in playlist_tracks position order. // user's system playlists, in playlist_tracks position order.
//
// A mix is keyed by its name AND its seed artist, because names are not
// unique: two artists can share a name (the test fixtures make one artist
// row per track, all named alike), and their Songs like mixes are then
// both called "Songs like X". Keyed by name alone, two such mixes merge
// into one list whose interleaving is whatever order Postgres returns the
// tied rows in, and the snapshot varies even when the mixes do not.
func snapshotSystemTracks(t *testing.T, pool *pgxpool.Pool, userID pgtype.UUID) map[string][]string { func snapshotSystemTracks(t *testing.T, pool *pgxpool.Pool, userID pgtype.UUID) map[string][]string {
t.Helper() t.Helper()
rows, err := pool.Query(context.Background(), ` rows, err := pool.Query(context.Background(), `
SELECT p.name, pt.track_id SELECT p.name || ' [' || COALESCE(p.seed_artist_id::text, '-') || ']', pt.track_id
FROM playlists p FROM playlists p
JOIN playlist_tracks pt ON pt.playlist_id = p.id JOIN playlist_tracks pt ON pt.playlist_id = p.id
WHERE p.user_id = $1 AND p.kind = 'system' WHERE p.user_id = $1 AND p.kind = 'system'
ORDER BY p.name, pt.position ORDER BY p.name, p.seed_artist_id, pt.position
`, userID) `, userID)
if err != nil { if err != nil {
t.Fatalf("snapshot query: %v", err) t.Fatalf("snapshot query: %v", err)