Add tests for /api/collection/random endpoint

This commit is contained in:
Claudio Ortolina
2025-01-01 20:57:01 +00:00
parent d194a54760
commit 65899b8077
2 changed files with 38 additions and 0 deletions
+11
View File
@@ -96,4 +96,15 @@ defmodule MusicLibrary.CollectionTest do
assert expected_record.id == most_recent_purchase.id
end
end
describe "get_random_record!/0" do
setup [:fill_collection]
test "returns a random record", %{collection: collection} do
random_record = Collection.get_latest_record!()
collection_ids = Enum.map(collection, & &1.id)
assert random_record.id in collection_ids
end
end
end