Improve test coverage
Files Created (8 files, 54 new tests) Fixtures 1. test/support/fixtures/music_library/record_sets.ex — record_set/1 and record_set_with_records/2 helpers 2. test/support/fixtures/music_library/online_store_templates.ex — online_store_template/1 helper Context Tests 3. test/music_library/record_sets_test.exs — 20 tests covering search, count, CRUD, add/remove/move records 4. test/music_library/online_store_templates_test.exs — 8 tests covering list, CRUD, URL generation, validation 5. test/music_library/search_test.exs — 5 tests covering universal search and search counts 6. test/music_library/notes_test.exs — 4 tests covering get, create, update LiveView Tests 7. test/music_library_web/live/record_set_live/index_test.exs — 11 tests covering listing, empty state, search, ordering, create/edit/delete sets, remove records, reorder records 8. test/music_library_web/live/online_store_template_live/index_test.exs — 6 tests covering listing, create/edit/delete, toggle enabled Results - 297 tests, 0 failures (up from 243 — 54 new tests added) - All existing tests continue to pass There's a remaining gettext warning that needs to be investigated
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
defmodule MusicLibrary.Fixtures.OnlineStoreTemplates do
|
||||
@moduledoc """
|
||||
This module defines test helpers for creating
|
||||
entities via the `MusicLibrary.OnlineStoreTemplates` context.
|
||||
"""
|
||||
|
||||
alias MusicLibrary.OnlineStoreTemplates
|
||||
|
||||
def online_store_template(attrs \\ %{}) do
|
||||
n = System.unique_integer([:positive])
|
||||
|
||||
{:ok, template} =
|
||||
attrs
|
||||
|> Enum.into(%{
|
||||
name: "Store #{n}",
|
||||
description: "A test store template",
|
||||
url_template: "https://example.com/search?q={artist}+{title}+{format}",
|
||||
enabled: true
|
||||
})
|
||||
|> OnlineStoreTemplates.create_template()
|
||||
|
||||
template
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,35 @@
|
||||
defmodule MusicLibrary.Fixtures.RecordSets do
|
||||
@moduledoc """
|
||||
This module defines test helpers for creating
|
||||
entities via the `MusicLibrary.RecordSets` context.
|
||||
"""
|
||||
|
||||
alias MusicLibrary.RecordSets
|
||||
|
||||
def record_set(attrs \\ %{}) do
|
||||
{:ok, record_set} =
|
||||
attrs
|
||||
|> Enum.into(%{
|
||||
name: "Set #{System.unique_integer([:positive])}",
|
||||
description: "A test record set"
|
||||
})
|
||||
|> RecordSets.create_record_set()
|
||||
|
||||
record_set
|
||||
end
|
||||
|
||||
def record_set_with_records(n, attrs \\ %{}) do
|
||||
import MusicLibrary.Fixtures.Records, only: [record: 1]
|
||||
|
||||
set = record_set(attrs)
|
||||
|
||||
records =
|
||||
Enum.map(1..n, fn _ ->
|
||||
rec = record(%{})
|
||||
{:ok, _} = RecordSets.add_record_to_set(set, rec.id)
|
||||
rec
|
||||
end)
|
||||
|
||||
{RecordSets.get_record_set!(set.id), records}
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user