Add the attribute for a cover image url for Book.

This commit is contained in:
2025-03-16 08:42:25 +02:00
parent ddc5cc590f
commit 100d8ba39a
5 changed files with 223 additions and 4 deletions
@@ -102,21 +102,21 @@ defmodule DecentralisedBookIndex.Metadata.BookTest do
{:ok, book} = Metadata.create_book("Book", "An description", "English", "Paperback", 256, ~D[2025-03-04], bids, author_roles, publisher.id)
author_roles = [
author_roles2 = [
%{order: 1, author_id: alias1.id, role: ""}
]
bids2 = bids()
publisher2 = generate(publisher())
{:ok, book2} = Metadata.create_book("Book2", "An description", "English", "Paperback", 256, ~D[2025-03-04], bids, author_roles, publisher2.id)
{:ok, book2} = Metadata.create_book("Book2", "An description", "English", "Paperback", 256, ~D[2025-03-04], bids2, author_roles2, publisher2.id)
author_roles = [
author_roles3 = [
%{order: 1, author_id: alias2.id, role: ""}
]
bids3 = bids()
publisher3 = generate(publisher())
{:ok, book3} = Metadata.create_book("Book3", "An description", "English", "Paperback", 256, ~D[2025-03-04], bids, author_roles, publisher3.id)
{:ok, book3} = Metadata.create_book("Book3", "An description", "English", "Paperback", 256, ~D[2025-03-04], bids3, author_roles3, publisher3.id)
assert {:ok, books} = Metadata.get_author_books(author)
@@ -138,4 +138,15 @@ defmodule DecentralisedBookIndex.Metadata.BookTest do
assert expected_book.id == book.id
end
end
describe "book's cover image" do
test "update cover image" do
cover_image_url = "/images/book.avif"
book = generate(book())
assert {:ok, book} = Metadata.assign_book_cover_image(book, cover_image_url)
assert book.cover_image_url == cover_image_url
end
end
end