Update the action to get the author's books including aliases.
continuous-integration/drone/push Build is passing
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -72,5 +72,39 @@ defmodule DecentralisedBookIndex.Metadata.BookTest do
|
||||
|
||||
assert {:ok, books} = Metadata.get_author_books(author)
|
||||
end
|
||||
|
||||
test "get the list contains aliases' books" do
|
||||
{:ok, author} = Metadata.create_author("Author", "An description")
|
||||
{:ok, alias1} =
|
||||
Metadata.add_author_to_related_alias_registry("Author2", "An description2", author.id)
|
||||
{:ok, alias2} =
|
||||
Metadata.add_author_to_related_alias_registry("Author3", "An description3", author.id)
|
||||
|
||||
author_roles = [
|
||||
%{order: 1, author_id: author.id, role: ""}
|
||||
]
|
||||
|
||||
{:ok, book} = Metadata.create_book("Book", "1234567890", "An description", author_roles)
|
||||
|
||||
author_roles = [
|
||||
%{order: 1, author_id: alias1.id, role: ""}
|
||||
]
|
||||
|
||||
{:ok, book2} = Metadata.create_book("Book2", "1234567890", "An description", author_roles)
|
||||
|
||||
author_roles = [
|
||||
%{order: 1, author_id: alias2.id, role: ""}
|
||||
]
|
||||
|
||||
{:ok, book3} = Metadata.create_book("Book3", "1234567890", "An description", author_roles)
|
||||
|
||||
assert {:ok, books} = Metadata.get_author_books(author)
|
||||
|
||||
book_ids = Enum.map(books, & &1.id)
|
||||
|
||||
assert book.id in book_ids
|
||||
assert book2.id in book_ids
|
||||
assert book3.id in book_ids
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user