fix(lidarr): wrap MBID-lookup decode errors with ErrInvalidPayload + fill test gaps
- Decode errors in LookupArtist/AlbumByMBID now wrap ErrInvalidPayload so callers can errors.Is the same way they do against the M5a methods. - Tighten TestLookupAlbumByMBID_BadJSON to assert on ErrInvalidPayload. - Add empty-mbid rejection tests for both methods. - Add TestLookupArtistByMBID_EmptyArrayReturnsErrNotFound (only the album variant had the test before — symmetric coverage now). - Normalize the network-error test's api key to key123 for consistency with the rest of delete_test.go.
This commit is contained in:
@@ -22,7 +22,7 @@ func (c *Client) LookupArtistByMBID(ctx context.Context, mbid string) (LidarrArt
|
||||
|
||||
var rows []LidarrArtist
|
||||
if err := json.NewDecoder(resp.Body).Decode(&rows); err != nil {
|
||||
return LidarrArtist{}, fmt.Errorf("lidarr: decode artist: %w", err)
|
||||
return LidarrArtist{}, fmt.Errorf("%w: decode artist: %v", ErrInvalidPayload, err)
|
||||
}
|
||||
if len(rows) == 0 {
|
||||
return LidarrArtist{}, ErrNotFound
|
||||
@@ -45,7 +45,7 @@ func (c *Client) LookupAlbumByMBID(ctx context.Context, mbid string) (LidarrAlbu
|
||||
|
||||
var rows []LidarrAlbum
|
||||
if err := json.NewDecoder(resp.Body).Decode(&rows); err != nil {
|
||||
return LidarrAlbum{}, fmt.Errorf("lidarr: decode album: %w", err)
|
||||
return LidarrAlbum{}, fmt.Errorf("%w: decode album: %v", ErrInvalidPayload, err)
|
||||
}
|
||||
if len(rows) == 0 {
|
||||
return LidarrAlbum{}, ErrNotFound
|
||||
|
||||
Reference in New Issue
Block a user