Files
music_library/test/music_library/http_error_test.exs
T
Claudio Ortolina ec6980eea0 ML-193: add secondary parser, search, and API coverage tests
Add ~80 focused tests across 10 files covering:

- Record set search by name, description, contained record title, artist name
- Navigation events for records, artists, record sets, links, and view-all actions
- MusicBrainz.ReleaseGroup parser (artist credits, included RGs, release IDs, types)
- MusicBrainz.ReleaseSearchResult edge cases (missing RG, unknown formats)
- LastFm.Session XML edge cases (non-subscriber, missing nodes)
- MusicLibrary.HttpError default status-kind mapping
- Discogs.API.ErrorResponse fallback message and retry-delay behavior
- ArtistRefreshWikipediaData {:cancel, :no_english_wikipedia} worker path
- StatsComponents grouped on-this-day records and anniversary labels
2026-05-21 10:45:29 +01:00

42 lines
1.2 KiB
Elixir

defmodule MusicLibrary.HttpErrorTest do
use ExUnit.Case, async: true
alias MusicLibrary.HttpError
describe "default_kind/1" do
test "maps 429 to :rate_limit" do
assert HttpError.default_kind(429) == :rate_limit
end
test "maps 5xx to :server_error" do
for status <- [500, 502, 503, 504, 599] do
assert HttpError.default_kind(status) == :server_error,
"expected #{status} to be :server_error"
end
end
test "maps 401 and 403 to :auth_error" do
assert HttpError.default_kind(401) == :auth_error
assert HttpError.default_kind(403) == :auth_error
end
test "maps 404 to :not_found" do
assert HttpError.default_kind(404) == :not_found
end
test "maps other 4xx to :client_error" do
for status <- [400, 402, 405, 422, 499] do
assert HttpError.default_kind(status) == :client_error,
"expected #{status} to be :client_error"
end
end
test "maps unexpected statuses to :unknown" do
for status <- [200, 302, 600, 999] do
assert HttpError.default_kind(status) == :unknown,
"expected #{status} to be :unknown"
end
end
end
end