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:
@@ -11,6 +11,7 @@ import (
|
||||
"github.com/jackc/pgx/v5/pgxpool"
|
||||
|
||||
"git.fabledsword.com/bvandeusen/minstrel/internal/db/dbq"
|
||||
"git.fabledsword.com/bvandeusen/minstrel/internal/dbtest"
|
||||
"git.fabledsword.com/bvandeusen/minstrel/internal/playlists"
|
||||
)
|
||||
|
||||
@@ -39,7 +40,7 @@ func seedGenre(t *testing.T, pool *pgxpool.Pool, genre string, artists, perArtis
|
||||
// tier 2, an untouched one is tier 3, and a genre too small for a mix is not
|
||||
// offered at all.
|
||||
func TestListGenreMixCandidates_TiersAndSizeFloor(t *testing.T) {
|
||||
pool := newPool(t)
|
||||
pool := dbtest.Pool(t)
|
||||
ctx := context.Background()
|
||||
u := seedUser(t, pool, "gmixcand")
|
||||
now := time.Now().UTC()
|
||||
@@ -85,7 +86,7 @@ func TestListGenreMixCandidates_TiersAndSizeFloor(t *testing.T) {
|
||||
// also carries an excluded genre (matched case-insensitively) belongs to that
|
||||
// genre's mix and is left out of this one.
|
||||
func TestListGenreMixTracks_LeavesOutSongsOfGenresAlreadyPicked(t *testing.T) {
|
||||
pool := newPool(t)
|
||||
pool := dbtest.Pool(t)
|
||||
ctx := context.Background()
|
||||
u := seedUser(t, pool, "gmixexcl")
|
||||
|
||||
@@ -120,7 +121,7 @@ func TestListGenreMixTracks_LeavesOutSongsOfGenresAlreadyPicked(t *testing.T) {
|
||||
// often than played through is left out, while a favourite with stray skips
|
||||
// stays; tracks of other genres never appear.
|
||||
func TestListGenreMixTracks_SplitsFamiliarAndDropsRejectedTracks(t *testing.T) {
|
||||
pool := newPool(t)
|
||||
pool := dbtest.Pool(t)
|
||||
ctx := context.Background()
|
||||
u := seedUser(t, pool, "gmixtracks")
|
||||
now := time.Now().UTC()
|
||||
@@ -178,7 +179,7 @@ func TestListGenreMixTracks_SplitsFamiliarAndDropsRejectedTracks(t *testing.T) {
|
||||
// the genre they listen to, holding only that genre's tracks, with both
|
||||
// halves of the blend stamped.
|
||||
func TestBuildSystemPlaylists_GenreMixes(t *testing.T) {
|
||||
pool := newPool(t)
|
||||
pool := dbtest.Pool(t)
|
||||
ctx := context.Background()
|
||||
u := seedUser(t, pool, "gmixbuild")
|
||||
now := time.Now().UTC()
|
||||
@@ -270,7 +271,7 @@ func meanPosition(sum map[pgtype.UUID]int, tracks []dbq.Track) float64 {
|
||||
// user knows, ones played often and liked come up earlier than ones played
|
||||
// once.
|
||||
func TestListGenreMixTracks_FamiliarLeansTowardFavourites(t *testing.T) {
|
||||
pool := newPool(t)
|
||||
pool := dbtest.Pool(t)
|
||||
ctx := context.Background()
|
||||
u := seedUser(t, pool, "gmixfav")
|
||||
now := time.Now().UTC()
|
||||
@@ -301,7 +302,7 @@ func TestListGenreMixTracks_FamiliarLeansTowardFavourites(t *testing.T) {
|
||||
// have never met, and so does an artist similar to theirs. The stranger
|
||||
// still appears: the lean tilts the draw, it does not exclude.
|
||||
func TestListGenreMixTracks_UnheardLeansTowardTheUsersArtists(t *testing.T) {
|
||||
pool := newPool(t)
|
||||
pool := dbtest.Pool(t)
|
||||
ctx := context.Background()
|
||||
u := seedUser(t, pool, "gmixartist")
|
||||
now := time.Now().UTC()
|
||||
|
||||
Reference in New Issue
Block a user