test: one test-database opener, dbtest.Pool, in place of 39 copies (#8002)

Every package carried its own testPool/newPool/newTestPool: skip under
-short or without MINSTREL_TEST_DATABASE_URL, migrate, connect,
register the close, and usually ResetDB. dbtest.Open does the first
four (migrating once per test binary) and dbtest.Pool adds the reset.
The per-package wrappers that did nothing else are gone; fixture
helpers that seed rows keep their own signatures.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-26 12:49:02 -05:00
co-authored by Claude Opus 5.5
parent 47e749225e
commit 39fa740bff
69 changed files with 329 additions and 975 deletions
+3 -2
View File
@@ -8,6 +8,7 @@ import (
"github.com/jackc/pgx/v5/pgxpool"
"git.fabledsword.com/bvandeusen/minstrel/internal/db/dbq"
"git.fabledsword.com/bvandeusen/minstrel/internal/dbtest"
)
func likeTrack(t *testing.T, pool *pgxpool.Pool, userID, trackID pgtype.UUID) {
@@ -30,7 +31,7 @@ func markMissing(t *testing.T, pool *pgxpool.Pool, trackID pgtype.UUID) {
// TestPickTopPlayedTracksForUser_LikedTierSkipsMissing: with no plays, For
// You seeds from likes. A liked track whose file is gone is not a seed.
func TestPickTopPlayedTracksForUser_LikedTierSkipsMissing(t *testing.T) {
pool := newPool(t)
pool := dbtest.Pool(t)
u := seedUser(t, pool, "seedmissing")
present := seedTrack(t, pool, "Present", "Seed Artist A")
gone := seedTrack(t, pool, "Gone", "Seed Artist B")
@@ -51,7 +52,7 @@ func TestPickTopPlayedTracksForUser_LikedTierSkipsMissing(t *testing.T) {
// Songs-like seeds from the artist's newest album. When that album's track is
// missing, the seed comes from the next album rather than the missing file.
func TestPickTopPlayedTrackForArtistByUser_FallbackSkipsMissing(t *testing.T) {
pool := newPool(t)
pool := dbtest.Pool(t)
ctx := context.Background()
u := seedUser(t, pool, "songslikemissing")
older := seedTrack(t, pool, "Older", "Songs Like Artist")