fix(server): TestGcCloseStalePlayEvents seeds artist with sort_name
test-go / test (push) Successful in 36s
test-go / integration (push) Failing after 14m34s

The artists table requires sort_name (NOT NULL constraint added by
0009_artist_sort.up.sql). My GC integration test was inserting only
name + relying on a separate SELECT to pull the id back, which both
(a) violated the NOT NULL constraint and (b) was unnecessarily
indirect. RETURNING the id directly is the standard pattern used
everywhere else in the test suite.

Test now matches the real-world insert pattern in api.search +
library scan (sort_name mirrors name when no MBID-driven sort hint
is available). Other GC tests in this file don't touch artists so
they were already fine.
This commit is contained in:
2026-06-02 18:47:31 -04:00
parent dbcadf0f93
commit 305d4780ac
+6 -8
View File
@@ -66,15 +66,13 @@ func TestGcCloseStalePlayEvents_ClosesOnly24hOldRows(t *testing.T) {
// Need a track + session to satisfy FKs on play_events.
var trackID pgtype.UUID
if err := pool.QueryRow(ctx, `
INSERT INTO artists (name) VALUES ('A') RETURNING id
`).Scan(new(pgtype.UUID)); err != nil {
t.Fatalf("seed artist row: %v", err)
}
// Get the just-inserted artist id.
var artistID pgtype.UUID
if err := pool.QueryRow(ctx, `SELECT id FROM artists WHERE name = 'A'`).Scan(&artistID); err != nil {
t.Fatalf("read artist: %v", err)
// `artists` has sort_name NOT NULL; mirror the title in sort_name
// like every real insert site does (see api.search / library scan).
if err := pool.QueryRow(ctx, `
INSERT INTO artists (name, sort_name) VALUES ('A', 'A') RETURNING id
`).Scan(&artistID); err != nil {
t.Fatalf("seed artist row: %v", err)
}
var albumID pgtype.UUID
if err := pool.QueryRow(ctx, `