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:
@@ -9,6 +9,7 @@ import (
|
||||
|
||||
"github.com/jackc/pgx/v5/pgtype"
|
||||
|
||||
"git.fabledsword.com/bvandeusen/minstrel/internal/dbtest"
|
||||
"git.fabledsword.com/bvandeusen/minstrel/internal/eventbus"
|
||||
"git.fabledsword.com/bvandeusen/minstrel/internal/playlists"
|
||||
)
|
||||
@@ -40,7 +41,7 @@ func TestOrderByTracks_ArrangesNamedEntriesInTheirOwnPlaces(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCreateWithID_ASecondSendFindsTheSameList(t *testing.T) {
|
||||
pool := newPool(t)
|
||||
pool := dbtest.Pool(t)
|
||||
alice := seedUser(t, pool, "alice")
|
||||
bob := seedUser(t, pool, "bob")
|
||||
svc := playlists.NewService(pool, nil, t.TempDir())
|
||||
@@ -71,7 +72,7 @@ func TestCreateWithID_ASecondSendFindsTheSameList(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestRemoveTrack_ASecondSendRemovesNothingMore(t *testing.T) {
|
||||
pool := newPool(t)
|
||||
pool := dbtest.Pool(t)
|
||||
user := seedUser(t, pool, "alice")
|
||||
a := seedTrack(t, pool, "A", "Artist")
|
||||
b := seedTrack(t, pool, "B", "Artist")
|
||||
@@ -95,7 +96,7 @@ func TestRemoveTrack_ASecondSendRemovesNothingMore(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestReorderTracks_ASecondSendChangesNothing(t *testing.T) {
|
||||
pool := newPool(t)
|
||||
pool := dbtest.Pool(t)
|
||||
user := seedUser(t, pool, "alice")
|
||||
a := seedTrack(t, pool, "A", "Artist")
|
||||
b := seedTrack(t, pool, "B", "Artist")
|
||||
@@ -118,7 +119,7 @@ func TestReorderTracks_ASecondSendChangesNothing(t *testing.T) {
|
||||
|
||||
// Every change tells the owner's clients, whichever client made it.
|
||||
func TestChanges_TellTheOwnersClients(t *testing.T) {
|
||||
pool := newPool(t)
|
||||
pool := dbtest.Pool(t)
|
||||
user := seedUser(t, pool, "alice")
|
||||
a := seedTrack(t, pool, "A", "Artist")
|
||||
bus := eventbus.New()
|
||||
|
||||
Reference in New Issue
Block a user