Update to refactor tests for Author and Book.

dev
KKlochko 3 months ago
parent 89c871110c
commit 8a3b522049

@ -56,7 +56,7 @@ defmodule DecentralisedBookIndex.Metadata.AuthorTest do
test "new author has no alternatives names", %{user: user} do test "new author has no alternatives names", %{user: user} do
{:ok, author} = Metadata.create_author("Author", "An description", nil, nil, actor: user) {:ok, author} = Metadata.create_author("Author", "An description", nil, nil, actor: user)
assert {:ok, alternatives_names} = Metadata.get_author_alternative_names(author) assert {:ok, alternatives_names} = Metadata.get_author_alternative_names(author)
assert alternatives_names = [] assert ^alternatives_names = []
end end
test "author has related author so they has one alternative name", %{user: user} do test "author has related author so they has one alternative name", %{user: user} do
@ -73,7 +73,7 @@ defmodule DecentralisedBookIndex.Metadata.AuthorTest do
) )
assert {:ok, alternatives_names} = Metadata.get_author_alternative_names(author) assert {:ok, alternatives_names} = Metadata.get_author_alternative_names(author)
assert alternatives_names = [related_author] assert get_ids(alternatives_names) == [related_author.id]
end end
end end

@ -118,7 +118,8 @@ defmodule DecentralisedBookIndex.Metadata.BookTest do
bids, bids,
author_roles, author_roles,
publisher.id, publisher.id,
nil nil,
actor: user
) )
end end
end end
@ -146,7 +147,7 @@ defmodule DecentralisedBookIndex.Metadata.BookTest do
) )
assert {:ok, alternatives_names} = Metadata.get_book_alternative_editions(book) assert {:ok, alternatives_names} = Metadata.get_book_alternative_editions(book)
assert alternatives_names = [] assert ^alternatives_names = []
end end
test "book has related book so they has one alternative name", %{user: user} do test "book has related book so they has one alternative name", %{user: user} do
@ -187,7 +188,7 @@ defmodule DecentralisedBookIndex.Metadata.BookTest do
) )
assert {:ok, alternatives_names} = Metadata.get_book_alternative_editions(book) assert {:ok, alternatives_names} = Metadata.get_book_alternative_editions(book)
assert alternatives_names = [related_book] assert get_ids(alternatives_names) == [related_book.id]
end end
end end
@ -201,7 +202,7 @@ defmodule DecentralisedBookIndex.Metadata.BookTest do
%{order: 1, author_id: author.id, role: ""} %{order: 1, author_id: author.id, role: ""}
] ]
{:ok, book} = {:ok, _book} =
Metadata.create_book( Metadata.create_book(
"Book", "Book",
"An description", "An description",
@ -217,7 +218,7 @@ defmodule DecentralisedBookIndex.Metadata.BookTest do
actor: user actor: user
) )
assert {:ok, books} = Metadata.get_author_books(author) assert {:ok, _books} = Metadata.get_author_books(author)
end end
test "get the list contains aliases' books", %{user: user} do test "get the list contains aliases' books", %{user: user} do
@ -256,7 +257,7 @@ defmodule DecentralisedBookIndex.Metadata.BookTest do
end end
describe "get a book by book id" do describe "get a book by book id" do
test "get by bid", %{user: user} do test "get by bid" do
expected_book = generate(book()) expected_book = generate(book())
[%Metadata.BookId{type: type, bid: bid} | _] = expected_book.bids [%Metadata.BookId{type: type, bid: bid} | _] = expected_book.bids

Loading…
Cancel
Save