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:
@@ -4,6 +4,8 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
"testing"
|
||||
|
||||
"git.fabledsword.com/bvandeusen/minstrel/internal/dbtest"
|
||||
)
|
||||
|
||||
// fakeArtistProvider opts into ArtistArtProvider for capability tests.
|
||||
@@ -27,7 +29,7 @@ func (f *fakeTestableAlbumProvider) TestConnection(_ context.Context) error {
|
||||
}
|
||||
|
||||
func TestSettingsService_BootInsertsDefaultRows(t *testing.T) {
|
||||
pool := newPool(t)
|
||||
pool := dbtest.Pool(t)
|
||||
resetRegistryForTests()
|
||||
defer resetRegistryForTests()
|
||||
|
||||
@@ -60,7 +62,7 @@ func TestSettingsService_BootInsertsDefaultRows(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSettingsService_UpdateProvider_FlippingEnabledBumpsVersion(t *testing.T) {
|
||||
pool := newPool(t)
|
||||
pool := dbtest.Pool(t)
|
||||
resetRegistryForTests()
|
||||
defer resetRegistryForTests()
|
||||
|
||||
@@ -92,7 +94,7 @@ func TestSettingsService_UpdateProvider_FlippingEnabledBumpsVersion(t *testing.T
|
||||
}
|
||||
|
||||
func TestSettingsService_UpdateProvider_KeyOnlyDoesNotBumpVersion(t *testing.T) {
|
||||
pool := newPool(t)
|
||||
pool := dbtest.Pool(t)
|
||||
resetRegistryForTests()
|
||||
defer resetRegistryForTests()
|
||||
|
||||
@@ -131,7 +133,7 @@ func TestSettingsService_UpdateProvider_KeyOnlyDoesNotBumpVersion(t *testing.T)
|
||||
}
|
||||
|
||||
func TestSettingsService_UpdateProvider_ClearKey(t *testing.T) {
|
||||
pool := newPool(t)
|
||||
pool := dbtest.Pool(t)
|
||||
resetRegistryForTests()
|
||||
defer resetRegistryForTests()
|
||||
|
||||
@@ -161,7 +163,7 @@ func TestSettingsService_UpdateProvider_ClearKey(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSettingsService_TestProvider_Routing(t *testing.T) {
|
||||
pool := newPool(t)
|
||||
pool := dbtest.Pool(t)
|
||||
resetRegistryForTests()
|
||||
defer resetRegistryForTests()
|
||||
|
||||
@@ -195,7 +197,7 @@ func TestSettingsService_TestProvider_Routing(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSettingsService_ListProviderInfo_Capabilities(t *testing.T) {
|
||||
pool := newPool(t)
|
||||
pool := dbtest.Pool(t)
|
||||
resetRegistryForTests()
|
||||
defer resetRegistryForTests()
|
||||
|
||||
@@ -235,7 +237,7 @@ func TestSettingsService_ListProviderInfo_Capabilities(t *testing.T) {
|
||||
// TestSettingsService_BumpVersionIfProvidersChanged_FirstBoot: stored
|
||||
// hash is empty (column default ""), so a real provider set produces a bump.
|
||||
func TestSettingsService_BumpVersionIfProvidersChanged_FirstBoot(t *testing.T) {
|
||||
pool := newPool(t)
|
||||
pool := dbtest.Pool(t)
|
||||
resetRegistryForTests()
|
||||
defer resetRegistryForTests()
|
||||
|
||||
@@ -266,7 +268,7 @@ func TestSettingsService_BumpVersionIfProvidersChanged_FirstBoot(t *testing.T) {
|
||||
// call back-to-back returns bumped=false because the stored hash now
|
||||
// matches the registered set.
|
||||
func TestSettingsService_BumpVersionIfProvidersChanged_NoChange(t *testing.T) {
|
||||
pool := newPool(t)
|
||||
pool := dbtest.Pool(t)
|
||||
resetRegistryForTests()
|
||||
defer resetRegistryForTests()
|
||||
|
||||
@@ -299,7 +301,7 @@ func TestSettingsService_BumpVersionIfProvidersChanged_NoChange(t *testing.T) {
|
||||
// path. Distinct from BumpVersionIfProvidersChanged, this always writes
|
||||
// regardless of the stored provider-set hash.
|
||||
func TestSettingsService_BumpVersion_Increments(t *testing.T) {
|
||||
pool := newPool(t)
|
||||
pool := dbtest.Pool(t)
|
||||
resetRegistryForTests()
|
||||
defer resetRegistryForTests()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user