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 -4
View File
@@ -19,7 +19,7 @@ import (
// A removed file's track stays, missing, with its likes and plays and the
// reason it waits, and the good copy that lands later takes its history over.
func TestRemoveFile_KeepsTheTrackUntilAGoodCopyLands(t *testing.T) {
pool := newPool(t)
pool := dbtest.Pool(t)
ctx := context.Background()
q := dbq.New(pool)
admin, err := q.CreateUser(ctx, dbq.CreateUserParams{
@@ -86,7 +86,7 @@ func TestRemoveFile_KeepsTheTrackUntilAGoodCopyLands(t *testing.T) {
// ForgetMBID drops the recording MBID that came from a file that was not the
// track's song.
func TestRemoveFile_ForgetsADoubtedMBID(t *testing.T) {
pool := newPool(t)
pool := dbtest.Pool(t)
ctx := context.Background()
path := filepath.Join(t.TempDir(), "rip.mp3")
if err := os.WriteFile(path, []byte("x"), 0o644); err != nil {
@@ -112,7 +112,7 @@ func TestRemoveFile_ForgetsADoubtedMBID(t *testing.T) {
// A file that cannot be removed leaves the track as it was.
func TestRemoveFile_FailedRemovalMarksNothing(t *testing.T) {
pool := newPool(t)
pool := dbtest.Pool(t)
ctx := context.Background()
path := filepath.Join(t.TempDir(), "stuck.mp3")
if err := os.WriteFile(path, []byte("x"), 0o644); err != nil {
@@ -139,7 +139,7 @@ func TestRemoveFile_FailedRemovalMarksNothing(t *testing.T) {
// The reason describes one missing spell: a file back at its path clears it
// with the missing mark.
func TestRemoveFile_ReasonGoesWhenTheFileIsBack(t *testing.T) {
pool := newPool(t)
pool := dbtest.Pool(t)
ctx := context.Background()
path := filepath.Join(t.TempDir(), "back.mp3")
if err := os.WriteFile(path, []byte("x"), 0o644); err != nil {