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
@@ -9,6 +9,7 @@ import (
"github.com/jackc/pgx/v5/pgtype"
"git.fabledsword.com/bvandeusen/minstrel/internal/db/dbq"
"git.fabledsword.com/bvandeusen/minstrel/internal/dbtest"
"git.fabledsword.com/bvandeusen/minstrel/internal/playlists"
)
@@ -16,7 +17,7 @@ import (
// order they first appear, at most six: a shelf of tiles picks from them so
// no two tiles show the same cover.
func TestCoverAlbums_DistinctCoveredInTrackOrderCappedAtSix(t *testing.T) {
pool := newPool(t)
pool := dbtest.Pool(t)
ctx := context.Background()
q := dbq.New(pool)
user := seedUser(t, pool, "covers")
@@ -91,7 +92,7 @@ func TestCoverAlbums_DistinctCoveredInTrackOrderCappedAtSix(t *testing.T) {
// A playlist with no covered albums lists none, rather than failing the
// List call that carries every other playlist.
func TestCoverAlbums_EmptyPlaylistHasNone(t *testing.T) {
pool := newPool(t)
pool := dbtest.Pool(t)
ctx := context.Background()
user := seedUser(t, pool, "nocovers")
svc := playlists.NewService(pool, nil, t.TempDir())