diff --git a/test/support/fixtures/music_brainz/release.ex b/test/support/fixtures/music_brainz/release.ex index dccdc6bb..00019806 100644 --- a/test/support/fixtures/music_brainz/release.ex +++ b/test/support/fixtures/music_brainz/release.ex @@ -1,35 +1,43 @@ defmodule MusicBrainz.Fixtures.Release do @fixtures_folder Path.join([File.cwd!(), "test/support/fixtures/music_brainz"]) - def releases(:queen_greatest_hits) do - Path.join([@fixtures_folder, "releases - queen - greatest hits.json"]) - |> File.read!() - |> JSON.decode!() - end + # Cache JSON fixtures at compile time to avoid repeated file I/O + @releases_queen_greatest_hits Path.join([ + @fixtures_folder, + "releases - queen - greatest hits.json" + ]) + |> File.read!() + |> JSON.decode!() - def releases(:marbles) do - Path.join([@fixtures_folder, "releases - marillion - marbles.json"]) - |> File.read!() - |> JSON.decode!() - end + @releases_marbles Path.join([@fixtures_folder, "releases - marillion - marbles.json"]) + |> File.read!() + |> JSON.decode!() - def release(:mystery_of_time) do - Path.join([@fixtures_folder, "release - avantasia - the mystery of time.json"]) - |> File.read!() - |> JSON.decode!() - end + @release_mystery_of_time Path.join([ + @fixtures_folder, + "release - avantasia - the mystery of time.json" + ]) + |> File.read!() + |> JSON.decode!() - def release(:marbles) do - Path.join([@fixtures_folder, "release - marillion - marbles.json"]) - |> File.read!() - |> JSON.decode!() - end + @release_marbles Path.join([@fixtures_folder, "release - marillion - marbles.json"]) + |> File.read!() + |> JSON.decode!() - def release_with_media(:marbles) do - Path.join([@fixtures_folder, "release_with_media - marillion - marbles.json"]) - |> File.read!() - |> JSON.decode!() - end + @release_with_media_marbles Path.join([ + @fixtures_folder, + "release_with_media - marillion - marbles.json" + ]) + |> File.read!() + |> JSON.decode!() + + def releases(:queen_greatest_hits), do: @releases_queen_greatest_hits + def releases(:marbles), do: @releases_marbles + + def release(:mystery_of_time), do: @release_mystery_of_time + def release(:marbles), do: @release_marbles + + def release_with_media(:marbles), do: @release_with_media_marbles def release_id(name) do release(name) |> Map.get("id") diff --git a/test/support/fixtures/music_brainz/release_group.ex b/test/support/fixtures/music_brainz/release_group.ex index b341deb9..e287ff5d 100644 --- a/test/support/fixtures/music_brainz/release_group.ex +++ b/test/support/fixtures/music_brainz/release_group.ex @@ -1,32 +1,37 @@ defmodule MusicBrainz.Fixtures.ReleaseGroup do @fixtures_folder Path.join([File.cwd!(), "test/support/fixtures/music_brainz"]) - def release_group_search_results do - Path.join([@fixtures_folder, "release_group_search_results - marillion - marbles.json"]) - |> File.read!() - |> JSON.decode!() - end + # Cache JSON fixtures at compile time to avoid repeated file I/O + @release_group_search_results Path.join([ + @fixtures_folder, + "release_group_search_results - marillion - marbles.json" + ]) + |> File.read!() + |> JSON.decode!() - def release_group(:mystery_of_time) do - Path.join([@fixtures_folder, "release_group - avantasia - the mystery of time.json"]) - |> File.read!() - |> JSON.decode!() - end + @mystery_of_time Path.join([ + @fixtures_folder, + "release_group - avantasia - the mystery of time.json" + ]) + |> File.read!() + |> JSON.decode!() - def release_group(:marbles) do - Path.join([@fixtures_folder, "release_group - marillion - marbles.json"]) - |> File.read!() - |> JSON.decode!() - end + @marbles Path.join([@fixtures_folder, "release_group - marillion - marbles.json"]) + |> File.read!() + |> JSON.decode!() - def release_group(:lockdown_trilogy) do - Path.join([ - @fixtures_folder, - "release_group_with_includes - mariusz duda - lockdown trilogy.json" - ]) - |> File.read!() - |> JSON.decode!() - end + @lockdown_trilogy Path.join([ + @fixtures_folder, + "release_group_with_includes - mariusz duda - lockdown trilogy.json" + ]) + |> File.read!() + |> JSON.decode!() + + def release_group_search_results, do: @release_group_search_results + + def release_group(:mystery_of_time), do: @mystery_of_time + def release_group(:marbles), do: @marbles + def release_group(:lockdown_trilogy), do: @lockdown_trilogy def release_group_releases(name) do rg = release_group(name)