From 0e0e7e09beff30348edd99ecbded414d9699dfe5 Mon Sep 17 00:00:00 2001 From: Claudio Ortolina Date: Mon, 11 Nov 2024 19:02:10 +0000 Subject: [PATCH] Add tests for get_record!/1 and get_cover/1 --- test/music_library/records_test.exs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/test/music_library/records_test.exs b/test/music_library/records_test.exs index 349b71c3..b0c31479 100644 --- a/test/music_library/records_test.exs +++ b/test/music_library/records_test.exs @@ -96,4 +96,24 @@ defmodule MusicLibrary.RecordsTest do assert 1 == Records.search_records_count(Record, "mbid:#{airbag_au_mbid}") end end + + describe "get_record!/1" do + test "it fetches the record by id" do + # while this test may seem redundant, it implicitely checks that ALL record fields are returned, + # as opposed to other code paths where we only return essential ones. + expected = record_fixture() + + assert expected == Records.get_record!(expected.id) + end + end + + describe "get_cover/1" do + test "it returns the record cover by id" do + # while this test may seem redundant, it implicitely checks that ALL record fields are returned, + # as opposed to other code paths where we only return essential ones. + expected = record_fixture() + + assert Map.take(expected, [:cover_hash, :cover_data]) == Records.get_cover(expected.id) + end + end end