From ea7b5b646aec56434f67b486e012e3a206c8e385 Mon Sep 17 00:00:00 2001 From: Claudio Ortolina Date: Mon, 17 Feb 2025 16:03:23 +0000 Subject: [PATCH] Namespace MusicBrainz fixtures --- test/music_library/records/record_test.exs | 2 +- test/music_library/records_test.exs | 2 +- .../live/collection_live/index_test.exs | 2 +- .../live/stats_live/index_test.exs | 3 ++- ...ase - avantasia - the mystery of time.json | 0 .../release - marillion - marbles.json | 0 test/support/fixtures/music_brainz/release.ex | 16 +++++++++++++++ ...oup - avantasia - the mystery of time.json | 0 .../release_group - marillion - marbles.json | 0 ...des - mariusz duda - lockdown trilogy.json | 0 .../release_groups_fixtures.ex | 20 ++----------------- test/support/fixtures/records_fixtures.ex | 4 ++-- 12 files changed, 25 insertions(+), 24 deletions(-) rename test/support/fixtures/{ => music_brainz}/release - avantasia - the mystery of time.json (100%) rename test/support/fixtures/{ => music_brainz}/release - marillion - marbles.json (100%) rename test/support/fixtures/{ => music_brainz}/release_group - avantasia - the mystery of time.json (100%) rename test/support/fixtures/{ => music_brainz}/release_group - marillion - marbles.json (100%) rename test/support/fixtures/{ => music_brainz}/release_group_with_includes - mariusz duda - lockdown trilogy.json (100%) rename test/support/fixtures/{ => music_brainz}/release_groups_fixtures.ex (73%) diff --git a/test/music_library/records/record_test.exs b/test/music_library/records/record_test.exs index 5cd500d9..2fb718f3 100644 --- a/test/music_library/records/record_test.exs +++ b/test/music_library/records/record_test.exs @@ -1,7 +1,7 @@ defmodule MusicLibrary.Records.RecordTest do use ExUnit.Case, async: true - import MusicLibrary.ReleaseGroupsFixtures + import MusicLibrary.Fixtures.ReleaseGroup alias MusicLibrary.Records.Record doctest Record diff --git a/test/music_library/records_test.exs b/test/music_library/records_test.exs index 091e1468..fa6dd724 100644 --- a/test/music_library/records_test.exs +++ b/test/music_library/records_test.exs @@ -5,7 +5,7 @@ defmodule MusicLibrary.RecordsTest do alias MusicLibrary.Records.SearchIndex alias MusicBrainz.APIBehaviourMock import MusicLibrary.RecordsFixtures - import MusicLibrary.ReleaseGroupsFixtures + import MusicLibrary.Fixtures.ReleaseGroup import MusicBrainz.Fixtures.Release import Mox diff --git a/test/music_library_web/live/collection_live/index_test.exs b/test/music_library_web/live/collection_live/index_test.exs index 5c2a5f2b..643444fb 100644 --- a/test/music_library_web/live/collection_live/index_test.exs +++ b/test/music_library_web/live/collection_live/index_test.exs @@ -2,7 +2,7 @@ defmodule MusicLibraryWeb.CollectionLive.IndexTest do use MusicLibraryWeb.ConnCase import MusicLibrary.RecordsFixtures - import MusicLibrary.ReleaseGroupsFixtures + import MusicLibrary.Fixtures.ReleaseGroup import MusicLibraryWeb.RecordComponents, only: [format_label: 1, type_label: 1] import Mox alias MusicLibrary.Records.{Cover, Record} diff --git a/test/music_library_web/live/stats_live/index_test.exs b/test/music_library_web/live/stats_live/index_test.exs index 195287e8..89d34dfa 100644 --- a/test/music_library_web/live/stats_live/index_test.exs +++ b/test/music_library_web/live/stats_live/index_test.exs @@ -5,7 +5,8 @@ defmodule MusicLibraryWeb.StatsLive.IndexTest do alias MusicBrainz.APIBehaviourMock import MusicLibraryWeb.RecordComponents, only: [format_label: 1, type_label: 1] import MusicLibrary.RecordsFixtures - import MusicLibrary.ReleaseGroupsFixtures + import MusicLibrary.Fixtures.ReleaseGroup + import MusicBrainz.Fixtures.Release import Mox setup :verify_on_exit! diff --git a/test/support/fixtures/release - avantasia - the mystery of time.json b/test/support/fixtures/music_brainz/release - avantasia - the mystery of time.json similarity index 100% rename from test/support/fixtures/release - avantasia - the mystery of time.json rename to test/support/fixtures/music_brainz/release - avantasia - the mystery of time.json diff --git a/test/support/fixtures/release - marillion - marbles.json b/test/support/fixtures/music_brainz/release - marillion - marbles.json similarity index 100% rename from test/support/fixtures/release - marillion - marbles.json rename to test/support/fixtures/music_brainz/release - marillion - marbles.json diff --git a/test/support/fixtures/music_brainz/release.ex b/test/support/fixtures/music_brainz/release.ex index e3e88764..55a2b05b 100644 --- a/test/support/fixtures/music_brainz/release.ex +++ b/test/support/fixtures/music_brainz/release.ex @@ -7,4 +7,20 @@ defmodule MusicBrainz.Fixtures.Release do |> Jason.decode!() |> Map.get("releases") end + + def release(:mystery_of_time) do + Path.join([@fixtures_folder, "release - avantasia - the mystery of time.json"]) + |> File.read!() + |> JSON.decode!() + end + + def release(:marbles) do + Path.join([@fixtures_folder, "release - marillion - marbles.json"]) + |> File.read!() + |> JSON.decode!() + end + + def release_id(name) do + release(name) |> Map.get("id") + end end diff --git a/test/support/fixtures/release_group - avantasia - the mystery of time.json b/test/support/fixtures/music_brainz/release_group - avantasia - the mystery of time.json similarity index 100% rename from test/support/fixtures/release_group - avantasia - the mystery of time.json rename to test/support/fixtures/music_brainz/release_group - avantasia - the mystery of time.json diff --git a/test/support/fixtures/release_group - marillion - marbles.json b/test/support/fixtures/music_brainz/release_group - marillion - marbles.json similarity index 100% rename from test/support/fixtures/release_group - marillion - marbles.json rename to test/support/fixtures/music_brainz/release_group - marillion - marbles.json diff --git a/test/support/fixtures/release_group_with_includes - mariusz duda - lockdown trilogy.json b/test/support/fixtures/music_brainz/release_group_with_includes - mariusz duda - lockdown trilogy.json similarity index 100% rename from test/support/fixtures/release_group_with_includes - mariusz duda - lockdown trilogy.json rename to test/support/fixtures/music_brainz/release_group_with_includes - mariusz duda - lockdown trilogy.json diff --git a/test/support/fixtures/release_groups_fixtures.ex b/test/support/fixtures/music_brainz/release_groups_fixtures.ex similarity index 73% rename from test/support/fixtures/release_groups_fixtures.ex rename to test/support/fixtures/music_brainz/release_groups_fixtures.ex index eca9089d..ce5ab484 100644 --- a/test/support/fixtures/release_groups_fixtures.ex +++ b/test/support/fixtures/music_brainz/release_groups_fixtures.ex @@ -1,5 +1,5 @@ -defmodule MusicLibrary.ReleaseGroupsFixtures do - @fixtures_folder Path.join([File.cwd!(), "test/support/fixtures"]) +defmodule MusicLibrary.Fixtures.ReleaseGroup do + @fixtures_folder Path.join([File.cwd!(), "test/support/fixtures/music_brainz"]) alias MusicBrainz.ReleaseGroupSearchResult @@ -43,23 +43,7 @@ defmodule MusicLibrary.ReleaseGroupsFixtures do |> JSON.decode!() end - def release(:mystery_of_time) do - Path.join([@fixtures_folder, "release - avantasia - the mystery of time.json"]) - |> File.read!() - |> JSON.decode!() - end - - def release(:marbles) do - Path.join([@fixtures_folder, "release - marillion - marbles.json"]) - |> File.read!() - |> JSON.decode!() - end - def release_group_id(name) do release_group(name) |> Map.get("id") end - - def release_id(name) do - release(name) |> Map.get("id") - end end diff --git a/test/support/fixtures/records_fixtures.ex b/test/support/fixtures/records_fixtures.ex index 594a25c0..cbeab006 100644 --- a/test/support/fixtures/records_fixtures.ex +++ b/test/support/fixtures/records_fixtures.ex @@ -5,7 +5,7 @@ defmodule MusicLibrary.RecordsFixtures do """ alias MusicLibrary.Records.Record - alias MusicLibrary.ReleaseGroupsFixtures + alias MusicLibrary.Fixtures.ReleaseGroup @genres [ "progressive rock", @@ -62,7 +62,7 @@ defmodule MusicLibrary.RecordsFixtures do cover_url: "https://coverartarchive.org/release-group/#{record_musicbrainz_id}/front", cover_data: File.read!(@marbles_cover_data_path), musicbrainz_id: record_musicbrainz_id, - musicbrainz_data: ReleaseGroupsFixtures.release_group(:marbles), + musicbrainz_data: ReleaseGroup.release_group(:marbles), title: Enum.random(@titles), type: :album, format: Record.formats() |> Enum.random(),