fix(coverart/test): set MinInterval in rate-limit-serialization tests
This commit is contained in:
@@ -173,7 +173,20 @@ func TestDeezer_RateLimit_Serializes(t *testing.T) {
|
|||||||
}))
|
}))
|
||||||
defer srv.Close()
|
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()
|
start := time.Now()
|
||||||
_, _, _ = p.FetchArtistArt(context.Background(), ArtistRef{Name: "A"})
|
_, _, _ = p.FetchArtistArt(context.Background(), ArtistRef{Name: "A"})
|
||||||
|
|||||||
@@ -353,7 +353,23 @@ func TestLastfm_RateLimit_Serializes(t *testing.T) {
|
|||||||
}))
|
}))
|
||||||
defer srv.Close()
|
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()
|
start := time.Now()
|
||||||
_, _, _ = p.FetchArtistArt(context.Background(), ArtistRef{Name: "A"})
|
_, _, _ = p.FetchArtistArt(context.Background(), ArtistRef{Name: "A"})
|
||||||
|
|||||||
Reference in New Issue
Block a user