Add basic test for Records.Cover module
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
defmodule MusicLibrary.Records.Cover do
|
||||
@size 600
|
||||
|
||||
def resize(cover_data) do
|
||||
{:ok, thumb} = Vix.Vips.Operation.thumbnail_buffer(cover_data, @size)
|
||||
Vix.Vips.Image.write_to_buffer(thumb, ".jpg")
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
defmodule MusicLibrary.Records.CoverTest do
|
||||
use ExUnit.Case, async: true
|
||||
|
||||
import MusicLibrary.RecordsFixtures
|
||||
|
||||
describe "resize/1" do
|
||||
test "it resizes to the desired size" do
|
||||
cover_data = File.read!(marbles_cover_fixture())
|
||||
{:ok, resized_cover} = MusicLibrary.Records.Cover.resize(cover_data)
|
||||
assert cover_data !== resized_cover
|
||||
assert MusicLibrary.Records.Cover.correct_size?(resized_cover)
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user