Move more fixtures to compile time
This commit is contained in:
@@ -1,16 +1,17 @@
|
|||||||
defmodule Discogs.Fixtures.Artist do
|
defmodule Discogs.Fixtures.Artist do
|
||||||
@fixtures_folder Path.join([File.cwd!(), "test/support/fixtures/discogs"])
|
@fixtures_folder Path.join([File.cwd!(), "test/support/fixtures/discogs"])
|
||||||
|
|
||||||
def get_artist do
|
# Cache fixtures at compile time to avoid repeated file I/O
|
||||||
Path.join([@fixtures_folder, "artist - steven wilson.json"])
|
@get_artist Path.join([@fixtures_folder, "artist - steven wilson.json"])
|
||||||
|> File.read!()
|
|> File.read!()
|
||||||
|> JSON.decode!()
|
|> JSON.decode!()
|
||||||
end
|
|
||||||
|
|
||||||
def image_data do
|
@image_data Path.join([@fixtures_folder, "steven wilson.jpeg"])
|
||||||
Path.join([@fixtures_folder, "steven wilson.jpeg"])
|
|> File.read!()
|
||||||
|> File.read!()
|
|
||||||
end
|
def get_artist, do: @get_artist
|
||||||
|
|
||||||
|
def image_data, do: @image_data
|
||||||
|
|
||||||
def image_width, do: 225
|
def image_width, do: 225
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
defmodule LastFm.Fixtures.Artist do
|
defmodule LastFm.Fixtures.Artist do
|
||||||
@fixtures_folder Path.join([File.cwd!(), "test/support/fixtures/last_fm"])
|
@fixtures_folder Path.join([File.cwd!(), "test/support/fixtures/last_fm"])
|
||||||
|
|
||||||
def get_info do
|
# Cache fixtures at compile time to avoid repeated file I/O
|
||||||
Path.join([@fixtures_folder, "artist.getinfo.json"])
|
@get_info Path.join([@fixtures_folder, "artist.getinfo.json"])
|
||||||
|> File.read!()
|
|> File.read!()
|
||||||
|> JSON.decode!()
|
|> JSON.decode!()
|
||||||
end
|
|
||||||
|
def get_info, do: @get_info
|
||||||
|
|
||||||
def get_similar_artists do
|
def get_similar_artists do
|
||||||
%{"similarartists" => %{"artist" => []}}
|
%{"similarartists" => %{"artist" => []}}
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
defmodule MusicBrainz.Fixtures.Artist do
|
defmodule MusicBrainz.Fixtures.Artist do
|
||||||
@fixtures_folder Path.join([File.cwd!(), "test/support/fixtures/music_brainz"])
|
@fixtures_folder Path.join([File.cwd!(), "test/support/fixtures/music_brainz"])
|
||||||
|
|
||||||
def get_artist do
|
# Cache fixtures at compile time to avoid repeated file I/O
|
||||||
Path.join([@fixtures_folder, "artist - steven wilson.json"])
|
@get_artist Path.join([@fixtures_folder, "artist - steven wilson.json"])
|
||||||
|> File.read!()
|
|> File.read!()
|
||||||
|> JSON.decode!()
|
|> JSON.decode!()
|
||||||
end
|
|
||||||
|
def get_artist, do: @get_artist
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,32 +1,33 @@
|
|||||||
defmodule Wikipedia.Fixtures do
|
defmodule Wikipedia.Fixtures do
|
||||||
@fixtures_folder Path.join([File.cwd!(), "test/support/fixtures/wikipedia"])
|
@fixtures_folder Path.join([File.cwd!(), "test/support/fixtures/wikipedia"])
|
||||||
|
|
||||||
def wikidata_response do
|
# Cache fixtures at compile time to avoid repeated file I/O
|
||||||
Path.join([@fixtures_folder, "wikidata_response.json"])
|
@wikidata_response Path.join([@fixtures_folder, "wikidata_response.json"])
|
||||||
|> File.read!()
|
|> File.read!()
|
||||||
|> JSON.decode!()
|
|> JSON.decode!()
|
||||||
end
|
|
||||||
|
|
||||||
def wikidata_response_no_enwiki do
|
@wikidata_response_no_enwiki Path.join([@fixtures_folder, "wikidata_response_no_enwiki.json"])
|
||||||
Path.join([@fixtures_folder, "wikidata_response_no_enwiki.json"])
|
|> File.read!()
|
||||||
|> File.read!()
|
|> JSON.decode!()
|
||||||
|> JSON.decode!()
|
|
||||||
end
|
|
||||||
|
|
||||||
def article_summary do
|
@article_summary Path.join([@fixtures_folder, "article_summary.json"])
|
||||||
Path.join([@fixtures_folder, "article_summary.json"])
|
|> File.read!()
|
||||||
|> File.read!()
|
|> JSON.decode!()
|
||||||
|> JSON.decode!()
|
|
||||||
end
|
|
||||||
|
|
||||||
def article_extract do
|
@article_extract Path.join([@fixtures_folder, "article_extract.json"])
|
||||||
Path.join([@fixtures_folder, "article_extract.json"])
|
|> File.read!()
|
||||||
|> File.read!()
|
|> JSON.decode!()
|
||||||
|> JSON.decode!()
|
|
||||||
end
|
def wikidata_response, do: @wikidata_response
|
||||||
|
|
||||||
|
def wikidata_response_no_enwiki, do: @wikidata_response_no_enwiki
|
||||||
|
|
||||||
|
def article_summary, do: @article_summary
|
||||||
|
|
||||||
|
def article_extract, do: @article_extract
|
||||||
|
|
||||||
def article_extract_html do
|
def article_extract_html do
|
||||||
article_extract()
|
@article_extract
|
||||||
|> get_in(["query", "pages"])
|
|> get_in(["query", "pages"])
|
||||||
|> Map.values()
|
|> Map.values()
|
||||||
|> List.first()
|
|> List.first()
|
||||||
|
|||||||
Reference in New Issue
Block a user