fix(coverart/test): set MinInterval in rate-limit-serialization tests

This commit is contained in:
2026-05-08 13:21:45 -04:00
parent b5a138bb27
commit 4f669c26e9
2 changed files with 31 additions and 2 deletions
+14 -1
View File
@@ -173,7 +173,20 @@ func TestDeezer_RateLimit_Serializes(t *testing.T) {
}))
defer srv.Close()
p := newDeezerTestProvider(t, srv.URL)
old := deezerBaseURL
deezerBaseURL = srv.URL
t.Cleanup(func() { deezerBaseURL = old })
// Build a provider WITH the production MinInterval so this test can
// verify the rate-limit actually serializes. Other tests use
// newDeezerTestProvider which leaves MinInterval=0 for speed.
p := &deezerProvider{client: newHTTPClient(httpClientOptions{
Name: "deezer",
HTTPClient: &http.Client{Timeout: 5 * time.Second},
MinInterval: deezerMinPeriod,
BaseBackoff: time.Millisecond,
})}
p.enabled.Store(true)
start := time.Now()
_, _, _ = p.FetchArtistArt(context.Background(), ArtistRef{Name: "A"})
+17 -1
View File
@@ -353,7 +353,23 @@ func TestLastfm_RateLimit_Serializes(t *testing.T) {
}))
defer srv.Close()
p := newLastfmTestProvider(t, srv.URL+"/", "test-key")
prevBase := lastfmBaseURL
lastfmBaseURL = srv.URL + "/"
t.Cleanup(func() { lastfmBaseURL = prevBase })
// Build a provider WITH the production MinInterval so this test can
// verify the rate-limit actually serializes. Other tests use
// newLastfmTestProvider which leaves MinInterval=0 for speed.
p := &lastfmProvider{client: newHTTPClient(httpClientOptions{
Name: "lastfm",
HTTPClient: &http.Client{Timeout: 5 * time.Second},
MinInterval: lastfmMinPeriod,
TreatAuthAsTransient: true,
BaseBackoff: time.Millisecond,
})}
p.enabled.Store(true)
key := "test-key"
p.apiKey.Store(&key)
start := time.Now()
_, _, _ = p.FetchArtistArt(context.Background(), ArtistRef{Name: "A"})