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
+4 -3
View File
@@ -8,6 +8,7 @@ import (
"github.com/jackc/pgx/v5/pgtype"
"github.com/jackc/pgx/v5/pgxpool"
"git.fabledsword.com/bvandeusen/minstrel/internal/dbtest"
"git.fabledsword.com/bvandeusen/minstrel/internal/playlists"
)
@@ -33,7 +34,7 @@ func countYouMightLike(t *testing.T, pool *pgxpool.Pool, userID pgtype.UUID) (al
// You-might-like rows — the build ships nothing rather than near-random
// tiles.
func TestYouMightLike_ColdStartGate(t *testing.T) {
pool := newPool(t)
pool := dbtest.Pool(t)
logger := discardLogger()
u, _ := seedActiveLibrary(t, pool, "ymlcold", 3, 3)
@@ -54,7 +55,7 @@ func TestYouMightLike_ColdStartGate(t *testing.T) {
// × 4 tracks = 32 distinct tracks, clearing both gate bars) populates the
// You-might-like tables in the daily build.
func TestYouMightLike_SufficientActivityPopulates(t *testing.T) {
pool := newPool(t)
pool := dbtest.Pool(t)
logger := discardLogger()
u, _ := seedActiveLibrary(t, pool, "ymlrich", 8, 4)
@@ -76,7 +77,7 @@ func TestYouMightLike_SufficientActivityPopulates(t *testing.T) {
// TestYouMightLike_AtomicReplace: a second build replaces rather than
// appends, so counts stay bounded by the persisted depth.
func TestYouMightLike_AtomicReplace(t *testing.T) {
pool := newPool(t)
pool := dbtest.Pool(t)
logger := discardLogger()
u, _ := seedActiveLibrary(t, pool, "ymlreplace", 8, 4)
ctx := context.Background()