Update dependencies
ex_slop 0.4.1 => 0.4.2 Introduces a new check around misusing the `length/1` function which require widespread fixes.
This commit is contained in:
@@ -69,17 +69,15 @@ if Code.ensure_loaded?(Credo) do
|
||||
defp traverse_put_toast_call({:defmodule, _meta, _args}, issues, _issue_meta),
|
||||
do: {nil, issues}
|
||||
|
||||
defp traverse_put_toast_call({:put_toast, meta, args} = ast, issues, issue_meta)
|
||||
when is_list(args) and length(args) == 3 do
|
||||
defp traverse_put_toast_call({:put_toast, meta, [_a, _b, _c]} = ast, issues, issue_meta) do
|
||||
{ast, issues ++ [issue_for(meta, issue_meta)]}
|
||||
end
|
||||
|
||||
defp traverse_put_toast_call(
|
||||
{{:., dot_meta, [_target, :put_toast]}, call_meta, args} = ast,
|
||||
{{:., dot_meta, [_target, :put_toast]}, call_meta, [_a, _b, _c]} = ast,
|
||||
issues,
|
||||
issue_meta
|
||||
)
|
||||
when is_list(args) and length(args) == 3 do
|
||||
) do
|
||||
{ast, issues ++ [issue_for(call_meta, dot_meta, issue_meta)]}
|
||||
end
|
||||
|
||||
@@ -111,11 +109,10 @@ if Code.ensure_loaded?(Credo) do
|
||||
|
||||
defp traverse_put_toast_call(ast, issues, _issue_meta), do: {ast, issues}
|
||||
|
||||
defp piped_put_toast_meta({:put_toast, meta, args}) when is_list(args) and length(args) == 2,
|
||||
defp piped_put_toast_meta({:put_toast, meta, [_a, _b]}),
|
||||
do: meta
|
||||
|
||||
defp piped_put_toast_meta({{:., dot_meta, [_target, :put_toast]}, call_meta, args})
|
||||
when is_list(args) and length(args) == 2 do
|
||||
defp piped_put_toast_meta({{:., dot_meta, [_target, :put_toast]}, call_meta, [_a, _b]}) do
|
||||
merge_meta(call_meta, dot_meta)
|
||||
end
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
"error_tracker": {:hex, :error_tracker, "0.9.0", "fef10b1230be1b051452930ba4db9f809cdab9705fe87891c25f5e551cead372", [:mix], [{:ecto, "~> 3.13", [hex: :ecto, repo: "hexpm", optional: false]}, {:ecto_sql, "~> 3.13", [hex: :ecto_sql, repo: "hexpm", optional: false]}, {:ecto_sqlite3, ">= 0.0.0", [hex: :ecto_sqlite3, repo: "hexpm", optional: true]}, {:igniter, "~> 0.5", [hex: :igniter, repo: "hexpm", optional: true]}, {:jason, "~> 1.1", [hex: :jason, repo: "hexpm", optional: true]}, {:myxql, ">= 0.0.0", [hex: :myxql, repo: "hexpm", optional: true]}, {:phoenix_ecto, "~> 4.6", [hex: :phoenix_ecto, repo: "hexpm", optional: false]}, {:phoenix_live_view, "~> 1.0", [hex: :phoenix_live_view, repo: "hexpm", optional: false]}, {:plug, "~> 1.10", [hex: :plug, repo: "hexpm", optional: false]}, {:postgrex, ">= 0.0.0", [hex: :postgrex, repo: "hexpm", optional: true]}], "hexpm", "1de7d89ec9034c3b7282b6bd2d0584ca98cddc51e87bf0979ba71f6182803ac4"},
|
||||
"esbuild": {:hex, :esbuild, "0.10.0", "b0aa3388a1c23e727c5a3e7427c932d89ee791746b0081bbe56103e9ef3d291f", [:mix], [{:jason, "~> 1.4", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "468489cda427b974a7cc9f03ace55368a83e1a7be12fba7e30969af78e5f8c70"},
|
||||
"ex_ast": {:hex, :ex_ast, "0.12.0", "052ad63711da41b7efbfb3490dbf3d757bb67caec17d02f6deb0db4a0363e5f6", [:mix], [{:jason, "~> 1.4", [hex: :jason, repo: "hexpm", optional: false]}, {:sourceror, "~> 1.7", [hex: :sourceror, repo: "hexpm", optional: false]}], "hexpm", "66b4797f157d32f0a63c6da227515f78816c0ac8f621f6d7a2b22108e7b4dd85"},
|
||||
"ex_slop": {:hex, :ex_slop, "0.4.1", "6d69e4a884607d076bfa7e00515a83fdaccedb1eaa521825c6d308273ce0a50c", [:mix], [{:credo, "~> 1.7", [hex: :credo, repo: "hexpm", optional: false]}], "hexpm", "9fde18ec9e36ed5254ddcc59fed2433b49a3825e9f1349f29325b0d51470bdd1"},
|
||||
"ex_slop": {:hex, :ex_slop, "0.4.2", "142aba9a82eddfb258e39c45d59392ab3cdb6b5a3ad401b09b362b7134fc54eb", [:mix], [{:credo, "~> 1.7", [hex: :credo, repo: "hexpm", optional: false]}], "hexpm", "c7f5316f755f83566e7a0a049f6fedfcd5ff916fce83c6ebfdf806be62fd7a69"},
|
||||
"expo": {:hex, :expo, "1.1.1", "4202e1d2ca6e2b3b63e02f69cfe0a404f77702b041d02b58597c00992b601db5", [:mix], [], "hexpm", "5fb308b9cb359ae200b7e23d37c76978673aa1b06e2b3075d814ce12c5811640"},
|
||||
"exqlite": {:hex, :exqlite, "0.36.0", "07b4f95d61cb82b8d52946d0639497fa7d32117e09b2c8d25e24a38723c295cb", [:make, :mix], [{:cc_precompiler, "~> 0.1", [hex: :cc_precompiler, repo: "hexpm", optional: false]}, {:db_connection, "~> 2.1", [hex: :db_connection, repo: "hexpm", optional: false]}, {:elixir_make, "~> 0.8", [hex: :elixir_make, repo: "hexpm", optional: false]}, {:table, "~> 0.1.0", [hex: :table, repo: "hexpm", optional: true]}], "hexpm", "cbeca3ce781f9ff07cfa9a87486f3ebd512a143ad6a14ed5c9fca21fe0bf3ae7"},
|
||||
"file_system": {:hex, :file_system, "1.1.1", "31864f4685b0148f25bd3fbef2b1228457c0c89024ad67f7a81a3ffbc0bbad3a", [:mix], [], "hexpm", "7a15ff97dfe526aeefb090a7a9d3d03aa907e100e262a0f8f7746b78f8f87a5d"},
|
||||
|
||||
@@ -20,14 +20,14 @@ defmodule MusicBrainz.ExternalLinkTest do
|
||||
test "returns URLs matching the pattern", %{artist_data: artist_data} do
|
||||
results = ExternalLink.external_links(artist_data, "spotify")
|
||||
|
||||
assert length(results) == 1
|
||||
assert Enum.count_until(results, 2) == 1
|
||||
assert "https://open.spotify.com/artist/4X42BfuhWCAZ2swiVze9O0" in results
|
||||
end
|
||||
|
||||
test "returns all URLs matching the pattern when multiple exist", %{artist_data: artist_data} do
|
||||
results = ExternalLink.external_links(artist_data, "youtube")
|
||||
|
||||
assert length(results) == 2
|
||||
assert Enum.count_until(results, 3) == 2
|
||||
assert "https://www.youtube.com/user/StevenWilsonHQ" in results
|
||||
assert "https://music.youtube.com/channel/UCN_yfO7km9qK5n9JlLJRdrg" in results
|
||||
end
|
||||
@@ -36,7 +36,7 @@ defmodule MusicBrainz.ExternalLinkTest do
|
||||
results = ExternalLink.external_links(artist_data, nil)
|
||||
|
||||
# The fixture has 59 relations with URLs
|
||||
assert length(results) == 59
|
||||
assert Enum.count_until(results, 60) == 59
|
||||
end
|
||||
|
||||
test "pattern matching is case-sensitive", %{artist_data: artist_data} do
|
||||
@@ -47,7 +47,7 @@ defmodule MusicBrainz.ExternalLinkTest do
|
||||
test "pattern matches substring of URL", %{artist_data: artist_data} do
|
||||
results = ExternalLink.external_links(artist_data, "discogs")
|
||||
|
||||
assert length(results) == 1
|
||||
assert Enum.count_until(results, 2) == 1
|
||||
assert "https://www.discogs.com/artist/227943" in results
|
||||
end
|
||||
end
|
||||
@@ -70,7 +70,7 @@ defmodule MusicBrainz.ExternalLinkTest do
|
||||
|
||||
results = ExternalLink.external_links(artist_data, patterns)
|
||||
|
||||
assert length(results) == 2
|
||||
assert Enum.count_until(results, 3) == 2
|
||||
|
||||
spotify_link = Enum.find(results, fn link -> link.name == :spotify end)
|
||||
assert spotify_link.url == "https://open.spotify.com/artist/4X42BfuhWCAZ2swiVze9O0"
|
||||
@@ -88,7 +88,7 @@ defmodule MusicBrainz.ExternalLinkTest do
|
||||
|
||||
results = ExternalLink.external_links(artist_data, patterns)
|
||||
|
||||
assert length(results) == 1
|
||||
assert Enum.count_until(results, 2) == 1
|
||||
assert [youtube_link] = results
|
||||
assert youtube_link.name == :youtube
|
||||
|
||||
@@ -109,7 +109,7 @@ defmodule MusicBrainz.ExternalLinkTest do
|
||||
results = ExternalLink.external_links(artist_data, patterns)
|
||||
|
||||
# Only spotify and discogs should match
|
||||
assert length(results) == 2
|
||||
assert Enum.count_until(results, 3) == 2
|
||||
|
||||
names = Enum.map(results, & &1.name)
|
||||
assert :spotify in names
|
||||
|
||||
@@ -95,7 +95,7 @@ defmodule MusicBrainz.ReleaseGroupTest do
|
||||
}
|
||||
|
||||
result = ReleaseGroup.included_release_groups(release_group)
|
||||
assert length(result) == 1
|
||||
assert Enum.count_until(result, 2) == 1
|
||||
assert hd(result).id == "rg-included-1"
|
||||
assert hd(result).type == :ep
|
||||
end
|
||||
|
||||
@@ -89,7 +89,7 @@ defmodule MusicBrainzTest do
|
||||
end)
|
||||
|
||||
assert {:ok, releases} = MusicBrainz.get_all_releases(@release_group_id)
|
||||
assert length(releases) == 142
|
||||
assert Enum.count_until(releases, 143) == 142
|
||||
assert releases == full_page["releases"] ++ tail_page["releases"]
|
||||
assert Agent.get(agent, & &1) == ["0", "100"]
|
||||
end
|
||||
@@ -108,7 +108,7 @@ defmodule MusicBrainzTest do
|
||||
end)
|
||||
|
||||
assert {:ok, releases} = MusicBrainz.get_all_releases(@release_group_id)
|
||||
assert length(releases) == 100
|
||||
assert Enum.count_until(releases, 101) == 100
|
||||
assert releases == full_page["releases"]
|
||||
end
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ defmodule MusicLibrary.ArtistsTest do
|
||||
|
||||
results = Artists.search_by_name("Marillion", 10)
|
||||
|
||||
assert length(results) == 1
|
||||
assert Enum.count_until(results, 2) == 1
|
||||
assert hd(results).artist.name == "Marillion"
|
||||
end
|
||||
|
||||
@@ -57,7 +57,7 @@ defmodule MusicLibrary.ArtistsTest do
|
||||
|
||||
results = Artists.search_by_name("i", 1)
|
||||
|
||||
assert length(results) == 1
|
||||
assert Enum.count_until(results, 2) == 1
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -256,7 +256,7 @@ defmodule MusicLibrary.BarcodeScanTest do
|
||||
errors =
|
||||
BarcodeScan.import_results([collected_result, not_found_result], DateTime.utc_now())
|
||||
|
||||
assert length(errors) == 2
|
||||
assert Enum.count_until(errors, 3) == 2
|
||||
assert {"1111111111", :already_collected} in errors
|
||||
assert {"2222222222", :not_found} in errors
|
||||
end
|
||||
|
||||
@@ -27,7 +27,7 @@ defmodule MusicLibrary.BatchTest do
|
||||
{:error, :test_failure}
|
||||
end)
|
||||
|
||||
assert length(failed_ids) == 2
|
||||
assert Enum.count_until(failed_ids, 3) == 2
|
||||
assert r1.id in failed_ids
|
||||
assert r2.id in failed_ids
|
||||
end
|
||||
|
||||
@@ -124,7 +124,7 @@ defmodule MusicLibrary.CollectionTest do
|
||||
|
||||
assert [{:group, %{representative: rep, records: records}}] = result
|
||||
assert rep.id == cd.id
|
||||
assert length(records) == 2
|
||||
assert Enum.count_until(records, 3) == 2
|
||||
# Sorted by purchased_at ascending
|
||||
assert Enum.map(records, & &1.id) == [cd.id, vinyl.id]
|
||||
end
|
||||
@@ -396,7 +396,7 @@ defmodule MusicLibrary.CollectionTest do
|
||||
lines = String.split(catalog, "\n")
|
||||
|
||||
assert record_count == 2
|
||||
assert length(lines) == 2
|
||||
assert Enum.count_until(lines, 3) == 2
|
||||
|
||||
# Stats section
|
||||
assert stats =~ "# Stats: 2 releases"
|
||||
@@ -446,7 +446,7 @@ defmodule MusicLibrary.CollectionTest do
|
||||
lines = String.split(catalog, "\n")
|
||||
|
||||
assert record_count == 1
|
||||
assert length(lines) == 1
|
||||
assert Enum.count_until(lines, 2) == 1
|
||||
|
||||
line = hd(lines)
|
||||
assert line =~ "cd"
|
||||
|
||||
@@ -10,13 +10,13 @@ defmodule MusicLibrary.Colors.KMeansExtractorTest do
|
||||
describe "extract_dominant_colors/1" do
|
||||
test "extracts 5 colors by default" do
|
||||
assert {:ok, colors} = KMeansExtractor.extract_dominant_colors(@image_data)
|
||||
assert length(colors) == 5
|
||||
assert Enum.count_until(colors, 6) == 5
|
||||
assert Enum.all?(colors, &color_hex?/1)
|
||||
end
|
||||
|
||||
test "extracts custom number of colors" do
|
||||
assert {:ok, colors} = KMeansExtractor.extract_dominant_colors(@image_data, 3)
|
||||
assert length(colors) == 3
|
||||
assert Enum.count_until(colors, 4) == 3
|
||||
assert Enum.all?(colors, &color_hex?/1)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -31,7 +31,7 @@ defmodule MusicLibrary.ErrorsTest do
|
||||
result = Errors.list_errors()
|
||||
|
||||
assert result.total == 2
|
||||
assert length(result.errors) == 2
|
||||
assert Enum.count_until(result.errors, 3) == 2
|
||||
ids = Enum.map(result.errors, & &1.id)
|
||||
assert e1.id in ids
|
||||
assert e2.id in ids
|
||||
@@ -44,7 +44,7 @@ defmodule MusicLibrary.ErrorsTest do
|
||||
result = Errors.list_errors(status: :resolved)
|
||||
|
||||
assert result.total == 1
|
||||
assert length(result.errors) == 1
|
||||
assert Enum.count_until(result.errors, 2) == 1
|
||||
assert hd(result.errors).id == e2.id
|
||||
assert hd(result.errors).status == :resolved
|
||||
end
|
||||
@@ -56,7 +56,7 @@ defmodule MusicLibrary.ErrorsTest do
|
||||
result = Errors.list_errors(muted: true)
|
||||
|
||||
assert result.total == 1
|
||||
assert length(result.errors) == 1
|
||||
assert Enum.count_until(result.errors, 2) == 1
|
||||
assert hd(result.errors).id == e2.id
|
||||
assert hd(result.errors).muted == true
|
||||
end
|
||||
@@ -68,7 +68,7 @@ defmodule MusicLibrary.ErrorsTest do
|
||||
result = Errors.list_errors(search: "specific text")
|
||||
|
||||
assert result.total == 1
|
||||
assert length(result.errors) == 1
|
||||
assert Enum.count_until(result.errors, 2) == 1
|
||||
assert hd(result.errors).id == e2.id
|
||||
assert hd(result.errors).reason == "Second error with specific text"
|
||||
end
|
||||
@@ -82,7 +82,7 @@ defmodule MusicLibrary.ErrorsTest do
|
||||
result = Errors.list_errors(search: "100%")
|
||||
|
||||
assert result.total == 1
|
||||
assert length(result.errors) == 1
|
||||
assert Enum.count_until(result.errors, 2) == 1
|
||||
assert hd(result.errors).id == e1.id
|
||||
end
|
||||
|
||||
@@ -94,7 +94,7 @@ defmodule MusicLibrary.ErrorsTest do
|
||||
result = Errors.list_errors(limit: 2)
|
||||
|
||||
assert result.total == 3
|
||||
assert length(result.errors) == 2
|
||||
assert Enum.count_until(result.errors, 3) == 2
|
||||
end
|
||||
|
||||
test "respects offset" do
|
||||
@@ -105,7 +105,7 @@ defmodule MusicLibrary.ErrorsTest do
|
||||
result = Errors.list_errors(offset: 1, limit: 10)
|
||||
|
||||
assert result.total == 3
|
||||
assert length(result.errors) == 2
|
||||
assert Enum.count_until(result.errors, 3) == 2
|
||||
end
|
||||
|
||||
test "returns empty list when no errors match filters" do
|
||||
@@ -137,7 +137,7 @@ defmodule MusicLibrary.ErrorsTest do
|
||||
assert result.reason == "Something went wrong"
|
||||
assert result.occurrence_count == 2
|
||||
refute is_nil(result.first_occurrence_at)
|
||||
assert length(result.occurrences) == 2
|
||||
assert Enum.count_until(result.occurrences, 3) == 2
|
||||
|
||||
# Occurrences sorted desc by inserted_at (most recent first)
|
||||
[occ1, occ2] = result.occurrences
|
||||
|
||||
@@ -77,7 +77,7 @@ defmodule MusicLibrary.ListeningStatsTest do
|
||||
|
||||
tracks = list_tracks()
|
||||
|
||||
assert length(tracks) == 2
|
||||
assert Enum.count_until(tracks, 3) == 2
|
||||
track_titles = Enum.map(tracks, & &1.title)
|
||||
assert "First Track" in track_titles
|
||||
assert "Second Track" in track_titles
|
||||
@@ -139,7 +139,7 @@ defmodule MusicLibrary.ListeningStatsTest do
|
||||
|
||||
tracks = list_tracks(%{query: "Special"})
|
||||
|
||||
assert length(tracks) == 1
|
||||
assert Enum.count_until(tracks, 2) == 1
|
||||
assert List.first(tracks).title == "Special Track"
|
||||
end
|
||||
|
||||
@@ -149,7 +149,7 @@ defmodule MusicLibrary.ListeningStatsTest do
|
||||
|
||||
tracks = list_tracks(%{query: "Special Artist"})
|
||||
|
||||
assert length(tracks) == 1
|
||||
assert Enum.count_until(tracks, 2) == 1
|
||||
assert List.first(tracks).artist.name == "Special Artist"
|
||||
end
|
||||
|
||||
@@ -159,7 +159,7 @@ defmodule MusicLibrary.ListeningStatsTest do
|
||||
|
||||
tracks = list_tracks(%{query: "Special Album"})
|
||||
|
||||
assert length(tracks) == 1
|
||||
assert Enum.count_until(tracks, 2) == 1
|
||||
assert List.first(tracks).album.title == "Special Album"
|
||||
end
|
||||
|
||||
@@ -168,11 +168,11 @@ defmodule MusicLibrary.ListeningStatsTest do
|
||||
|
||||
# Get first 2 tracks
|
||||
tracks_page_1 = list_tracks(%{page: 1, page_size: 2})
|
||||
assert length(tracks_page_1) == 2
|
||||
assert Enum.count_until(tracks_page_1, 3) == 2
|
||||
|
||||
# Get next 2 tracks
|
||||
tracks_page_2 = list_tracks(%{page: 2, page_size: 2})
|
||||
assert length(tracks_page_2) == 2
|
||||
assert Enum.count_until(tracks_page_2, 3) == 2
|
||||
|
||||
# Ensure they're different tracks
|
||||
page_1_ids = Enum.map(tracks_page_1, & &1.scrobbled_at_uts)
|
||||
@@ -386,10 +386,12 @@ defmodule MusicLibrary.ListeningStatsTest do
|
||||
tracks = ListeningStats.list_tracks()
|
||||
|
||||
titles = Enum.map(tracks, & &1.track.title)
|
||||
assert length(titles) == length(Enum.uniq(titles)), "list_tracks returned duplicate rows"
|
||||
|
||||
assert Enum.count(titles) == Enum.count(Enum.uniq(titles)),
|
||||
"list_tracks returned duplicate rows"
|
||||
|
||||
for result <- tracks do
|
||||
assert length(result.matching_records) == 2
|
||||
assert Enum.count_until(result.matching_records, 3) == 2
|
||||
|
||||
record_ids = Enum.map(result.matching_records, & &1.id)
|
||||
assert expected_record_id in record_ids
|
||||
@@ -402,11 +404,11 @@ defmodule MusicLibrary.ListeningStatsTest do
|
||||
|
||||
titles = Enum.map(recent_tracks, & &1.track.title)
|
||||
|
||||
assert length(titles) == length(Enum.uniq(titles)),
|
||||
assert Enum.count(titles) == Enum.count(Enum.uniq(titles)),
|
||||
"recent_activity returned duplicate rows"
|
||||
|
||||
for result <- recent_tracks do
|
||||
assert length(result.matching_records) == 2
|
||||
assert Enum.count_until(result.matching_records, 3) == 2
|
||||
|
||||
record_ids = Enum.map(result.matching_records, & &1.id)
|
||||
assert expected_record_id in record_ids
|
||||
@@ -417,7 +419,9 @@ defmodule MusicLibrary.ListeningStatsTest do
|
||||
results = ListeningStats.get_top_albums(limit: 10)
|
||||
|
||||
marbles_entries = Enum.filter(results, fn r -> r.album_title == "Marbles" end)
|
||||
assert length(marbles_entries) == 1, "get_top_albums returned duplicate album entries"
|
||||
|
||||
assert Enum.count_until(marbles_entries, 2) == 1,
|
||||
"get_top_albums returned duplicate album entries"
|
||||
|
||||
[entry] = marbles_entries
|
||||
assert entry.play_count == 2
|
||||
@@ -433,7 +437,7 @@ defmodule MusicLibrary.ListeningStatsTest do
|
||||
|
||||
for result <- recent_tracks do
|
||||
assert is_list(result.matching_records)
|
||||
assert length(result.matching_records) == 2
|
||||
assert Enum.count_until(result.matching_records, 3) == 2
|
||||
|
||||
for record <- result.matching_records do
|
||||
assert Map.has_key?(record, :id)
|
||||
@@ -489,7 +493,7 @@ defmodule MusicLibrary.ListeningStatsTest do
|
||||
|
||||
[result] = recent_tracks
|
||||
|
||||
assert length(result.matching_records) == 2
|
||||
assert Enum.count_until(result.matching_records, 3) == 2
|
||||
|
||||
record_ids = Enum.map(result.matching_records, & &1.id)
|
||||
assert collected.id in record_ids
|
||||
@@ -507,10 +511,10 @@ defmodule MusicLibrary.ListeningStatsTest do
|
||||
results = ListeningStats.get_top_albums(limit: 10)
|
||||
|
||||
marbles_entries = Enum.filter(results, fn r -> r.album_title == "Marbles" end)
|
||||
assert length(marbles_entries) == 1
|
||||
assert Enum.count_until(marbles_entries, 2) == 1
|
||||
|
||||
[entry] = marbles_entries
|
||||
assert length(entry.matching_records) == 2
|
||||
assert Enum.count_until(entry.matching_records, 3) == 2
|
||||
|
||||
record_ids = Enum.map(entry.matching_records, & &1.id)
|
||||
assert collected.id in record_ids
|
||||
|
||||
@@ -85,7 +85,7 @@ defmodule MusicLibrary.Logger.SingleLineFormatterTest do
|
||||
|> IO.chardata_to_string()
|
||||
|
||||
lines = String.split(result, "\n", trim: true)
|
||||
assert length(lines) == 1
|
||||
assert Enum.count_until(lines, 2) == 1
|
||||
end
|
||||
|
||||
test "includes level and timestamp" do
|
||||
|
||||
@@ -106,7 +106,7 @@ defmodule MusicLibrary.MaintenanceTest do
|
||||
|
||||
result = Maintenance.get_artists_missing_musicbrainz_id()
|
||||
|
||||
assert length(result) == 2
|
||||
assert Enum.count_until(result, 3) == 2
|
||||
|
||||
artist_a = Enum.find(result, fn r -> r.artist_name == "Artist A" end)
|
||||
artist_b = Enum.find(result, fn r -> r.artist_name == "Artist B" end)
|
||||
@@ -123,7 +123,7 @@ defmodule MusicLibrary.MaintenanceTest do
|
||||
|
||||
result = Maintenance.get_artists_missing_musicbrainz_id()
|
||||
|
||||
assert length(result) == 2
|
||||
assert Enum.count_until(result, 3) == 2
|
||||
assert List.first(result).artist_name == "Artist B"
|
||||
assert List.first(result).track_count == 3
|
||||
end
|
||||
@@ -135,7 +135,7 @@ defmodule MusicLibrary.MaintenanceTest do
|
||||
|
||||
result = Maintenance.get_artists_missing_musicbrainz_id(limit: 2)
|
||||
|
||||
assert length(result) == 2
|
||||
assert Enum.count_until(result, 3) == 2
|
||||
end
|
||||
|
||||
test "excludes artists with valid musicbrainz_id" do
|
||||
@@ -144,7 +144,7 @@ defmodule MusicLibrary.MaintenanceTest do
|
||||
|
||||
result = Maintenance.get_artists_missing_musicbrainz_id()
|
||||
|
||||
assert length(result) == 1
|
||||
assert Enum.count_until(result, 2) == 1
|
||||
assert List.first(result).artist_name == "Artist A"
|
||||
end
|
||||
end
|
||||
@@ -177,7 +177,7 @@ defmodule MusicLibrary.MaintenanceTest do
|
||||
|
||||
result = Maintenance.get_albums_missing_musicbrainz_id()
|
||||
|
||||
assert length(result) == 2
|
||||
assert Enum.count_until(result, 3) == 2
|
||||
|
||||
album_a = Enum.find(result, fn r -> r.album_title == "Album A" end)
|
||||
album_b = Enum.find(result, fn r -> r.album_title == "Album B" end)
|
||||
@@ -196,7 +196,7 @@ defmodule MusicLibrary.MaintenanceTest do
|
||||
|
||||
result = Maintenance.get_albums_missing_musicbrainz_id()
|
||||
|
||||
assert length(result) == 2
|
||||
assert Enum.count_until(result, 3) == 2
|
||||
assert List.first(result).album_title == "Album B"
|
||||
assert List.first(result).track_count == 3
|
||||
end
|
||||
@@ -208,7 +208,7 @@ defmodule MusicLibrary.MaintenanceTest do
|
||||
|
||||
result = Maintenance.get_albums_missing_musicbrainz_id(limit: 2)
|
||||
|
||||
assert length(result) == 2
|
||||
assert Enum.count_until(result, 3) == 2
|
||||
end
|
||||
|
||||
test "excludes albums with valid musicbrainz_id" do
|
||||
@@ -217,7 +217,7 @@ defmodule MusicLibrary.MaintenanceTest do
|
||||
|
||||
result = Maintenance.get_albums_missing_musicbrainz_id()
|
||||
|
||||
assert length(result) == 1
|
||||
assert Enum.count_until(result, 2) == 1
|
||||
assert List.first(result).album_title == "Album A"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -34,7 +34,7 @@ defmodule MusicLibrary.OnlineStoreTemplatesTest do
|
||||
online_store_template(%{name: "Bandcamp"})
|
||||
|
||||
results = OnlineStoreTemplates.list_templates(query: "Amazon")
|
||||
assert length(results) == 1
|
||||
assert Enum.count_until(results, 2) == 1
|
||||
assert hd(results).name == "Amazon UK"
|
||||
end
|
||||
|
||||
@@ -43,7 +43,7 @@ defmodule MusicLibrary.OnlineStoreTemplatesTest do
|
||||
online_store_template(%{name: "Store B", description: "digital downloads"})
|
||||
|
||||
results = OnlineStoreTemplates.list_templates(query: "vinyl")
|
||||
assert length(results) == 1
|
||||
assert Enum.count_until(results, 2) == 1
|
||||
assert hd(results).name == "Store A"
|
||||
end
|
||||
|
||||
@@ -51,7 +51,7 @@ defmodule MusicLibrary.OnlineStoreTemplatesTest do
|
||||
for i <- 1..3, do: online_store_template(%{name: "Store #{i}"})
|
||||
|
||||
results = OnlineStoreTemplates.list_templates(limit: 1)
|
||||
assert length(results) == 1
|
||||
assert Enum.count_until(results, 2) == 1
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ defmodule MusicLibrary.QueryReporterTest do
|
||||
|
||||
handlers = :telemetry.list_handlers(@event)
|
||||
matching = Enum.filter(handlers, &(&1.id == "music-library-query-reporter"))
|
||||
assert length(matching) == 1
|
||||
assert Enum.count_until(matching, 2) == 1
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ defmodule MusicLibrary.RecordSetsTest do
|
||||
for i <- 1..5, do: record_set(%{name: "Set #{i}"})
|
||||
|
||||
results = RecordSets.search_record_sets("", limit: 2)
|
||||
assert length(results) == 2
|
||||
assert Enum.count_until(results, 3) == 2
|
||||
|
||||
all = RecordSets.search_record_sets("")
|
||||
offset_results = RecordSets.search_record_sets("", offset: 2, limit: 2)
|
||||
@@ -151,7 +151,7 @@ defmodule MusicLibrary.RecordSetsTest do
|
||||
rec = record()
|
||||
|
||||
assert {:ok, updated} = RecordSets.add_record_to_set(set, rec.id)
|
||||
assert length(updated.items) == 1
|
||||
assert Enum.count_until(updated.items, 2) == 1
|
||||
assert hd(updated.items).record.id == rec.id
|
||||
end
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ defmodule MusicLibrary.Records.RecordReleaseTest do
|
||||
|
||||
rows = list_releases(record.id)
|
||||
|
||||
assert length(rows) == 2
|
||||
assert Enum.count_until(rows, 3) == 2
|
||||
assert Enum.all?(rows, fn row -> row.cover_hash == nil end)
|
||||
assert Enum.all?(rows, fn row -> row.purchased_at == nil end)
|
||||
end
|
||||
@@ -123,7 +123,7 @@ defmodule MusicLibrary.Records.RecordReleaseTest do
|
||||
|
||||
rows = list_releases(record.id)
|
||||
|
||||
assert length(rows) == 2
|
||||
assert Enum.count_until(rows, 3) == 2
|
||||
assert Enum.all?(rows, fn row -> row.cover_hash == "hash-new" end)
|
||||
end
|
||||
|
||||
@@ -136,7 +136,7 @@ defmodule MusicLibrary.Records.RecordReleaseTest do
|
||||
|
||||
rows = list_releases(record.id)
|
||||
|
||||
assert length(rows) == 2
|
||||
assert Enum.count_until(rows, 3) == 2
|
||||
assert Enum.all?(rows, fn row -> row.purchased_at == ~U[2025-02-20 12:00:00Z] end)
|
||||
end
|
||||
|
||||
@@ -157,7 +157,7 @@ defmodule MusicLibrary.Records.RecordReleaseTest do
|
||||
describe "before delete trigger" do
|
||||
test "remove all rows when the record is deleted" do
|
||||
record = insert_record()
|
||||
assert length(list_releases(record.id)) == 2
|
||||
assert Enum.count_until(list_releases(record.id), 3) == 2
|
||||
|
||||
Repo.delete!(record)
|
||||
|
||||
|
||||
@@ -412,7 +412,7 @@ defmodule MusicLibrary.Records.SimilarityTest do
|
||||
test "respects limit option", %{record1: record1} do
|
||||
similar = Similarity.find_similar(record1.id, limit: 1, max_distance: 1.0)
|
||||
|
||||
assert length(similar) == 1
|
||||
assert Enum.count_until(similar, 2) == 1
|
||||
end
|
||||
|
||||
test "returns empty list for record without embedding" do
|
||||
|
||||
@@ -24,7 +24,7 @@ defmodule MusicLibrary.RecordsTest do
|
||||
assert record.cover_hash ==
|
||||
"599407DDF69907D4A60FE13CCAA824D25CF08DC124FD6AA3E8E7ECD98C885FFE"
|
||||
|
||||
assert length(record.dominant_colors) == 5
|
||||
assert Enum.count_until(record.dominant_colors, 6) == 5
|
||||
assert Enum.all?(record.dominant_colors, &color_hex?/1)
|
||||
end
|
||||
|
||||
|
||||
@@ -278,7 +278,7 @@ defmodule MusicLibrary.ScrobbleRulesTest do
|
||||
})
|
||||
|
||||
assert results = ScrobbleRules.apply_all_rules()
|
||||
assert length(results) == 2
|
||||
assert Enum.count_until(results, 3) == 2
|
||||
|
||||
# Verify all results are successful
|
||||
Enum.each(results, fn result ->
|
||||
@@ -495,7 +495,7 @@ defmodule MusicLibrary.ScrobbleRulesTest do
|
||||
results = ScrobbleRules.apply_all_rules()
|
||||
|
||||
# Should have 4 results (one for each rule)
|
||||
assert length(results) == 4
|
||||
assert Enum.count_until(results, 5) == 4
|
||||
|
||||
# All results should be successful
|
||||
Enum.each(results, fn result ->
|
||||
|
||||
@@ -93,10 +93,10 @@ defmodule MusicLibrary.SearchTest do
|
||||
test "respects limit", %{collected: _collected} do
|
||||
results = Search.universal_search("Marillion", limit: 1)
|
||||
|
||||
assert length(results.collection) <= 1
|
||||
assert length(results.wishlist) <= 1
|
||||
assert length(results.artists) <= 1
|
||||
assert length(results.record_sets) <= 1
|
||||
assert Enum.count_until(results.collection, 2) <= 1
|
||||
assert Enum.count_until(results.wishlist, 2) <= 1
|
||||
assert Enum.count_until(results.artists, 2) <= 1
|
||||
assert Enum.count_until(results.record_sets, 2) <= 1
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -360,7 +360,7 @@ defmodule MusicLibraryWeb.Components.ChatTest do
|
||||
# contains two user rows with the same content.
|
||||
reloaded = Chats.get_chat!(chat.id)
|
||||
user_messages = Enum.filter(reloaded.messages, &(&1.role == "user"))
|
||||
assert length(user_messages) == 2
|
||||
assert Enum.count_until(user_messages, 3) == 2
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -78,7 +78,7 @@ defmodule MusicLibraryWeb.ErrorControllerTest do
|
||||
assert %{"errors" => returned, "total" => 3, "limit" => 50, "offset" => 0} =
|
||||
json_response(conn, 200)
|
||||
|
||||
assert length(returned) == 3
|
||||
assert Enum.count_until(returned, 4) == 3
|
||||
|
||||
# Verify each returned error has the expected fields
|
||||
for error <- returned do
|
||||
@@ -138,7 +138,7 @@ defmodule MusicLibraryWeb.ErrorControllerTest do
|
||||
assert %{"errors" => returned, "total" => 3, "limit" => 2, "offset" => 1} =
|
||||
json_response(conn, 200)
|
||||
|
||||
assert length(returned) == 2
|
||||
assert Enum.count_until(returned, 3) == 2
|
||||
end
|
||||
|
||||
test "returns empty list when no errors match", %{conn: conn} do
|
||||
@@ -224,7 +224,7 @@ defmodule MusicLibraryWeb.ErrorControllerTest do
|
||||
|
||||
# Occurrences
|
||||
occurrences = returned["occurrences"]
|
||||
assert length(occurrences) == 2
|
||||
assert Enum.count_until(occurrences, 3) == 2
|
||||
|
||||
# Most recent first (desc inserted_at)
|
||||
first_occ = hd(occurrences)
|
||||
@@ -240,7 +240,7 @@ defmodule MusicLibraryWeb.ErrorControllerTest do
|
||||
|
||||
# Stacktrace lines
|
||||
lines = first_occ["stacktrace"]["lines"]
|
||||
assert length(lines) == 2
|
||||
assert Enum.count_until(lines, 3) == 2
|
||||
[line1, line2] = lines
|
||||
|
||||
assert line1["module"] == "OtherModule"
|
||||
|
||||
@@ -680,7 +680,7 @@ defmodule MusicLibraryWeb.CollectionLive.IndexTest do
|
||||
|
||||
# Verify exactly two distinct import jobs were enqueued
|
||||
enqueued = all_enqueued(worker: ImportFromMusicbrainzRelease)
|
||||
assert length(enqueued) == 2
|
||||
assert Enum.count_until(enqueued, 3) == 2
|
||||
assert Enum.all?(enqueued, & &1.args["release_id"])
|
||||
|
||||
# No records should have been inserted synchronously
|
||||
|
||||
@@ -176,7 +176,7 @@ defmodule MusicLibraryWeb.ScrobbledTracksLive.RulePickerTest do
|
||||
assert_has(session, "#rule-picker-modal")
|
||||
|
||||
# Only the original rule exists, no duplicate was created
|
||||
assert length(ScrobbleRules.list_scrobble_rules(type: :album)) == 1
|
||||
assert Enum.count_until(ScrobbleRules.list_scrobble_rules(type: :album), 2) == 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -217,7 +217,7 @@ defmodule MusicLibraryWeb.LiveHelpers.RecordActionsTest do
|
||||
|
||||
updated = Records.get_record!(record.id)
|
||||
# FakeColorExtractor returns a fixed 5-color palette
|
||||
assert length(updated.dominant_colors) == 5
|
||||
assert Enum.count_until(updated.dominant_colors, 6) == 5
|
||||
end
|
||||
|
||||
@tag :capture_log
|
||||
|
||||
Reference in New Issue
Block a user