test(coverart, subsonic, server): merge repeated cases into tables (#8298)
release / web (push) Successful in 1m35s
release / go (push) Successful in 1m58s
release / govulncheck (push) Successful in 19s
release / integration (push) Successful in 3m0s
release / android (push) Successful in 4m26s
release / Attach APK to the Release (tag releases only) (push) Canceled after 0s
release / Build + push container image (push) Canceled after 0s
release / Publish the release image to GHCR (dispatch only) (push) Canceled after 0s
release / Verify release artifacts (tag releases only) (push) Canceled after 0s
release / Build signed APK (push) Canceled after 5m8s
release / web (push) Successful in 1m35s
release / go (push) Successful in 1m58s
release / govulncheck (push) Successful in 19s
release / integration (push) Successful in 3m0s
release / android (push) Successful in 4m26s
release / Attach APK to the Release (tag releases only) (push) Canceled after 0s
release / Build + push container image (push) Canceled after 0s
release / Publish the release image to GHCR (dispatch only) (push) Canceled after 0s
release / Verify release artifacts (tag releases only) (push) Canceled after 0s
release / Build signed APK (push) Canceled after 5m8s
- coverart: the four providers' identity and default tests, Last.fm's five not-found-without-asking tests, the four "which artists are asked again" database tests (now one reset over four artists), and the thumbnail-only and fanart-only tests. - subsonic: getUser's six tests and decodePassword's three, one table each. Dropped TestTokenMD5Derivation: it checked crypto/md5 against a constant and called no Minstrel code. - server: the four web-app-versus-API path tests start one server, not four. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -29,19 +29,6 @@ func newLastfmTestProvider(t *testing.T, baseURL, key string) *lastfmProvider {
|
||||
|
||||
// ── Identity / metadata ──────────────────────────────────────────────────────
|
||||
|
||||
func TestLastfm_ID(t *testing.T) {
|
||||
p := &lastfmProvider{}
|
||||
if p.ID() != "lastfm" {
|
||||
t.Errorf("ID = %q, want lastfm", p.ID())
|
||||
}
|
||||
if !p.RequiresAPIKey() {
|
||||
t.Error("RequiresAPIKey = false, want true")
|
||||
}
|
||||
if p.DefaultEnabled() {
|
||||
t.Error("DefaultEnabled = true, want false")
|
||||
}
|
||||
}
|
||||
|
||||
// ── FetchArtistArt — happy paths ─────────────────────────────────────────────
|
||||
|
||||
func TestLastfm_FetchArtistArt_ByMBID(t *testing.T) {
|
||||
@@ -131,23 +118,6 @@ func TestLastfm_FetchArtistArt_PlaceholderImage(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestLastfm_FetchArtistArt_AlbumPlaceholderImage(t *testing.T) {
|
||||
// Second known placeholder hash (album cover default).
|
||||
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
_, _ = w.Write([]byte(`{"artist":{"name":"Y","image":[
|
||||
{"#text":"https://lastfm.freetls.fastly.net/i/u/300x300/c6f59c1e5e7240a4c0d427abd71f3dbb.jpg","size":"extralarge"}
|
||||
]}}`))
|
||||
}))
|
||||
defer srv.Close()
|
||||
|
||||
p := newLastfmTestProvider(t, srv.URL+"/", "test-key")
|
||||
_, _, err := p.FetchArtistArt(context.Background(), ArtistRef{Name: "Y"})
|
||||
if !errors.Is(err, ErrNotFound) {
|
||||
t.Errorf("err = %v, want ErrNotFound for album placeholder hash", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestLastfm_FetchArtistArt_EmptyImageArray(t *testing.T) {
|
||||
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
@@ -177,42 +147,31 @@ 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: providers.NewHTTPClient(providers.HTTPOptions{Name: "lastfm", HTTPClient: &http.Client{Timeout: 5 * time.Second}, TreatAuthAsTransient: true, BaseBackoff: time.Millisecond})}
|
||||
p.enabled.Store(true)
|
||||
emptyKey := ""
|
||||
p.apiKey.Store(&emptyKey)
|
||||
|
||||
_, _, err := p.FetchArtistArt(context.Background(), ArtistRef{Name: "X"})
|
||||
if !errors.Is(err, ErrNotFound) {
|
||||
t.Errorf("err = %v, want ErrNotFound when API key is empty", err)
|
||||
// Last.fm answers "not found" without a request when it is switched off, has
|
||||
// no key, or is given nothing to look up, rather than failing on the network.
|
||||
func TestLastfm_AnswersNotFoundWithoutAsking(t *testing.T) {
|
||||
provider := func(enabled bool, key string) *lastfmProvider {
|
||||
p := &lastfmProvider{client: providers.NewHTTPClient(providers.HTTPOptions{Name: "lastfm",
|
||||
HTTPClient: &http.Client{Timeout: 5 * time.Second}, TreatAuthAsTransient: true, BaseBackoff: time.Millisecond})}
|
||||
p.enabled.Store(enabled)
|
||||
p.apiKey.Store(&key)
|
||||
return p
|
||||
}
|
||||
}
|
||||
|
||||
func TestLastfm_FetchArtistArt_Disabled(t *testing.T) {
|
||||
// Key set but disabled.
|
||||
p := &lastfmProvider{client: providers.NewHTTPClient(providers.HTTPOptions{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)
|
||||
|
||||
_, _, err := p.FetchArtistArt(context.Background(), ArtistRef{Name: "X"})
|
||||
if !errors.Is(err, ErrNotFound) {
|
||||
t.Errorf("err = %v, want ErrNotFound when disabled", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestLastfm_FetchArtistArt_EmptyRefs(t *testing.T) {
|
||||
// Neither MBID nor Name: ErrNotFound without making any HTTP call.
|
||||
p := &lastfmProvider{client: providers.NewHTTPClient(providers.HTTPOptions{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)
|
||||
|
||||
_, _, err := p.FetchArtistArt(context.Background(), ArtistRef{})
|
||||
if !errors.Is(err, ErrNotFound) {
|
||||
t.Errorf("err = %v, want ErrNotFound for empty ArtistRef", err)
|
||||
ctx := context.Background()
|
||||
album := AlbumRef{ArtistName: "X", AlbumTitle: "Y"}
|
||||
for _, tc := range []struct {
|
||||
name string
|
||||
call func() error
|
||||
}{
|
||||
{"artist art with no key", func() error { _, _, err := provider(true, "").FetchArtistArt(ctx, ArtistRef{Name: "X"}); return err }},
|
||||
{"artist art while off", func() error { _, _, err := provider(false, "k").FetchArtistArt(ctx, ArtistRef{Name: "X"}); return err }},
|
||||
{"artist art with no name or MBID", func() error { _, _, err := provider(true, "k").FetchArtistArt(ctx, ArtistRef{}); return err }},
|
||||
{"album cover with no key", func() error { _, err := provider(true, "").FetchAlbumCover(ctx, album); return err }},
|
||||
{"album cover while off", func() error { _, err := provider(false, "k").FetchAlbumCover(ctx, album); return err }},
|
||||
} {
|
||||
if err := tc.call(); !errors.Is(err, ErrNotFound) {
|
||||
t.Errorf("%s: err = %v, want ErrNotFound", tc.name, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -321,30 +280,6 @@ func TestLastfm_FetchAlbumCover_MissingFields(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestLastfm_FetchAlbumCover_EmptyAPIKey(t *testing.T) {
|
||||
p := &lastfmProvider{client: providers.NewHTTPClient(providers.HTTPOptions{Name: "lastfm", HTTPClient: &http.Client{Timeout: 5 * time.Second}, TreatAuthAsTransient: true, BaseBackoff: time.Millisecond})}
|
||||
p.enabled.Store(true)
|
||||
emptyKey := ""
|
||||
p.apiKey.Store(&emptyKey)
|
||||
|
||||
_, err := p.FetchAlbumCover(context.Background(), AlbumRef{ArtistName: "X", AlbumTitle: "Y"})
|
||||
if !errors.Is(err, ErrNotFound) {
|
||||
t.Errorf("err = %v, want ErrNotFound when API key is empty", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestLastfm_FetchAlbumCover_Disabled(t *testing.T) {
|
||||
p := &lastfmProvider{client: providers.NewHTTPClient(providers.HTTPOptions{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)
|
||||
|
||||
_, err := p.FetchAlbumCover(context.Background(), AlbumRef{ArtistName: "X", AlbumTitle: "Y"})
|
||||
if !errors.Is(err, ErrNotFound) {
|
||||
t.Errorf("err = %v, want ErrNotFound when disabled", err)
|
||||
}
|
||||
}
|
||||
|
||||
// ── Rate-limit serialization ─────────────────────────────────────────────────
|
||||
|
||||
// lastfmTestPeriod is providers.LastfmPacer's spacing.
|
||||
|
||||
Reference in New Issue
Block a user