From 1ad966b7f3e6ab907e70ab4ce58149e959936be1 Mon Sep 17 00:00:00 2001 From: Bryan Van Deusen Date: Fri, 8 May 2026 07:58:00 -0400 Subject: [PATCH] fix(coverart/test): use newHTTPClient in provider test fixtures --- internal/coverart/provider_deezer_test.go | 8 ++++---- internal/coverart/provider_lastfm_test.go | 14 +++++++------- internal/coverart/provider_theaudiodb_test.go | 4 ++-- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/internal/coverart/provider_deezer_test.go b/internal/coverart/provider_deezer_test.go index 31708562..9717e262 100644 --- a/internal/coverart/provider_deezer_test.go +++ b/internal/coverart/provider_deezer_test.go @@ -18,7 +18,7 @@ func newDeezerTestProvider(t *testing.T, baseURL string) *deezerProvider { deezerBaseURL = baseURL t.Cleanup(func() { deezerBaseURL = old }) - p := &deezerProvider{client: &http.Client{Timeout: 5 * time.Second}} + p := &deezerProvider{client: newHTTPClient(httpClientOptions{Name: "deezer", HTTPClient: &http.Client{Timeout: 5 * time.Second}, BaseBackoff: time.Millisecond})} p.enabled.Store(true) return p } @@ -93,7 +93,7 @@ func TestDeezer_FetchArtistArt_NameMismatch(t *testing.T) { } func TestDeezer_FetchArtistArt_EmptyName(t *testing.T) { - p := &deezerProvider{client: &http.Client{Timeout: 5 * time.Second}} + p := &deezerProvider{client: newHTTPClient(httpClientOptions{Name: "deezer", HTTPClient: &http.Client{Timeout: 5 * time.Second}, BaseBackoff: time.Millisecond})} p.enabled.Store(true) _, _, err := p.FetchArtistArt(context.Background(), ArtistRef{}) if !errors.Is(err, ErrNotFound) { @@ -102,7 +102,7 @@ func TestDeezer_FetchArtistArt_EmptyName(t *testing.T) { } func TestDeezer_FetchArtistArt_Disabled(t *testing.T) { - p := &deezerProvider{client: &http.Client{Timeout: 5 * time.Second}} + p := &deezerProvider{client: newHTTPClient(httpClientOptions{Name: "deezer", HTTPClient: &http.Client{Timeout: 5 * time.Second}, BaseBackoff: time.Millisecond})} // enabled defaults to false _, _, err := p.FetchArtistArt(context.Background(), ArtistRef{Name: "X"}) if !errors.Is(err, ErrNotFound) { @@ -150,7 +150,7 @@ func TestDeezer_FetchAlbumCover_TitleMismatch(t *testing.T) { } func TestDeezer_FetchAlbumCover_MissingFields(t *testing.T) { - p := &deezerProvider{client: &http.Client{Timeout: 5 * time.Second}} + p := &deezerProvider{client: newHTTPClient(httpClientOptions{Name: "deezer", HTTPClient: &http.Client{Timeout: 5 * time.Second}, BaseBackoff: time.Millisecond})} p.enabled.Store(true) cases := []AlbumRef{ diff --git a/internal/coverart/provider_lastfm_test.go b/internal/coverart/provider_lastfm_test.go index 192138c6..55783152 100644 --- a/internal/coverart/provider_lastfm_test.go +++ b/internal/coverart/provider_lastfm_test.go @@ -19,7 +19,7 @@ func newLastfmTestProvider(t *testing.T, baseURL, key string) *lastfmProvider { lastfmBaseURL = baseURL t.Cleanup(func() { lastfmBaseURL = prevBase }) - p := &lastfmProvider{client: &http.Client{Timeout: 5 * time.Second}} + p := &lastfmProvider{client: newHTTPClient(httpClientOptions{Name: "lastfm", HTTPClient: &http.Client{Timeout: 5 * time.Second}, TreatAuthAsTransient: true, BaseBackoff: time.Millisecond})} p.enabled.Store(true) p.apiKey.Store(&key) return p @@ -177,7 +177,7 @@ func TestLastfm_FetchArtistArt_ErrorResponse(t *testing.T) { func TestLastfm_FetchArtistArt_EmptyAPIKey(t *testing.T) { // Enabled but no key: every call must return ErrNotFound, not a network error. - p := &lastfmProvider{client: &http.Client{Timeout: 5 * time.Second}} + p := &lastfmProvider{client: newHTTPClient(httpClientOptions{Name: "lastfm", HTTPClient: &http.Client{Timeout: 5 * time.Second}, TreatAuthAsTransient: true, BaseBackoff: time.Millisecond})} p.enabled.Store(true) emptyKey := "" p.apiKey.Store(&emptyKey) @@ -190,7 +190,7 @@ func TestLastfm_FetchArtistArt_EmptyAPIKey(t *testing.T) { func TestLastfm_FetchArtistArt_Disabled(t *testing.T) { // Key set but disabled. - p := &lastfmProvider{client: &http.Client{Timeout: 5 * time.Second}} + p := &lastfmProvider{client: newHTTPClient(httpClientOptions{Name: "lastfm", HTTPClient: &http.Client{Timeout: 5 * time.Second}, TreatAuthAsTransient: true, BaseBackoff: time.Millisecond})} // enabled defaults to false key := "some-key" p.apiKey.Store(&key) @@ -203,7 +203,7 @@ func TestLastfm_FetchArtistArt_Disabled(t *testing.T) { func TestLastfm_FetchArtistArt_EmptyRefs(t *testing.T) { // Neither MBID nor Name: ErrNotFound without making any HTTP call. - p := &lastfmProvider{client: &http.Client{Timeout: 5 * time.Second}} + p := &lastfmProvider{client: newHTTPClient(httpClientOptions{Name: "lastfm", HTTPClient: &http.Client{Timeout: 5 * time.Second}, TreatAuthAsTransient: true, BaseBackoff: time.Millisecond})} p.enabled.Store(true) key := "test-key" p.apiKey.Store(&key) @@ -301,7 +301,7 @@ func TestLastfm_FetchAlbumCover_WithMBIDHint(t *testing.T) { // ── FetchAlbumCover — missing fields ───────────────────────────────────────── func TestLastfm_FetchAlbumCover_MissingFields(t *testing.T) { - p := &lastfmProvider{client: &http.Client{Timeout: 5 * time.Second}} + p := &lastfmProvider{client: newHTTPClient(httpClientOptions{Name: "lastfm", HTTPClient: &http.Client{Timeout: 5 * time.Second}, TreatAuthAsTransient: true, BaseBackoff: time.Millisecond})} p.enabled.Store(true) key := "test-key" p.apiKey.Store(&key) @@ -320,7 +320,7 @@ func TestLastfm_FetchAlbumCover_MissingFields(t *testing.T) { } func TestLastfm_FetchAlbumCover_EmptyAPIKey(t *testing.T) { - p := &lastfmProvider{client: &http.Client{Timeout: 5 * time.Second}} + p := &lastfmProvider{client: newHTTPClient(httpClientOptions{Name: "lastfm", HTTPClient: &http.Client{Timeout: 5 * time.Second}, TreatAuthAsTransient: true, BaseBackoff: time.Millisecond})} p.enabled.Store(true) emptyKey := "" p.apiKey.Store(&emptyKey) @@ -332,7 +332,7 @@ func TestLastfm_FetchAlbumCover_EmptyAPIKey(t *testing.T) { } func TestLastfm_FetchAlbumCover_Disabled(t *testing.T) { - p := &lastfmProvider{client: &http.Client{Timeout: 5 * time.Second}} + p := &lastfmProvider{client: newHTTPClient(httpClientOptions{Name: "lastfm", HTTPClient: &http.Client{Timeout: 5 * time.Second}, TreatAuthAsTransient: true, BaseBackoff: time.Millisecond})} // enabled defaults to false key := "some-key" p.apiKey.Store(&key) diff --git a/internal/coverart/provider_theaudiodb_test.go b/internal/coverart/provider_theaudiodb_test.go index 3bdda489..471688a9 100644 --- a/internal/coverart/provider_theaudiodb_test.go +++ b/internal/coverart/provider_theaudiodb_test.go @@ -28,7 +28,7 @@ func newTheAudioDBProviderForTest(t *testing.T, mockURL string) *theAudioDBProvi withTheAudioDBBaseURL(t, mockURL) p := &theAudioDBProvider{ - client: &http.Client{Timeout: 5 * time.Second}, + client: newHTTPClient(httpClientOptions{Name: "theaudiodb", HTTPClient: &http.Client{Timeout: 5 * time.Second}, TreatAuthAsTransient: true, BaseBackoff: time.Millisecond}), } Register(p) p.enabled.Store(true) @@ -234,7 +234,7 @@ func TestTheAudioDB_DefaultsToTestKeyOnEmpty(t *testing.T) { defer resetRegistryForTests() withTheAudioDBBaseURL(t, srv.URL) - p := &theAudioDBProvider{client: &http.Client{Timeout: 5 * time.Second}} + p := &theAudioDBProvider{client: newHTTPClient(httpClientOptions{Name: "theaudiodb", HTTPClient: &http.Client{Timeout: 5 * time.Second}, TreatAuthAsTransient: true, BaseBackoff: time.Millisecond})} Register(p) // Configure with empty key — should fall back to test key. if err := p.Configure(ProviderSettings{Enabled: true, APIKey: ""}); err != nil {