From 8a3b522049796d30d3e455433aa5c05a52f12ac6 Mon Sep 17 00:00:00 2001 From: KKlochko Date: Sat, 24 May 2025 21:21:04 +0300 Subject: [PATCH] Update to refactor tests for Author and Book. --- .../metadata/author_test.exs | 4 ++-- .../decentralised_book_index/metadata/book_test.exs | 13 +++++++------ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/test/decentralised_book_index/metadata/author_test.exs b/test/decentralised_book_index/metadata/author_test.exs index 233c88c..dfaaa49 100644 --- a/test/decentralised_book_index/metadata/author_test.exs +++ b/test/decentralised_book_index/metadata/author_test.exs @@ -56,7 +56,7 @@ defmodule DecentralisedBookIndex.Metadata.AuthorTest do test "new author has no alternatives names", %{user: user} do {:ok, author} = Metadata.create_author("Author", "An description", nil, nil, actor: user) assert {:ok, alternatives_names} = Metadata.get_author_alternative_names(author) - assert alternatives_names = [] + assert ^alternatives_names = [] end 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 alternatives_names = [related_author] + assert get_ids(alternatives_names) == [related_author.id] end end diff --git a/test/decentralised_book_index/metadata/book_test.exs b/test/decentralised_book_index/metadata/book_test.exs index 969e029..d4db31b 100644 --- a/test/decentralised_book_index/metadata/book_test.exs +++ b/test/decentralised_book_index/metadata/book_test.exs @@ -118,7 +118,8 @@ defmodule DecentralisedBookIndex.Metadata.BookTest do bids, author_roles, publisher.id, - nil + nil, + actor: user ) end end @@ -146,7 +147,7 @@ defmodule DecentralisedBookIndex.Metadata.BookTest do ) assert {:ok, alternatives_names} = Metadata.get_book_alternative_editions(book) - assert alternatives_names = [] + assert ^alternatives_names = [] end 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 alternatives_names = [related_book] + assert get_ids(alternatives_names) == [related_book.id] end end @@ -201,7 +202,7 @@ defmodule DecentralisedBookIndex.Metadata.BookTest do %{order: 1, author_id: author.id, role: ""} ] - {:ok, book} = + {:ok, _book} = Metadata.create_book( "Book", "An description", @@ -217,7 +218,7 @@ defmodule DecentralisedBookIndex.Metadata.BookTest do actor: user ) - assert {:ok, books} = Metadata.get_author_books(author) + assert {:ok, _books} = Metadata.get_author_books(author) end test "get the list contains aliases' books", %{user: user} do @@ -256,7 +257,7 @@ defmodule DecentralisedBookIndex.Metadata.BookTest do end describe "get a book by book id" do - test "get by bid", %{user: user} do + test "get by bid" do expected_book = generate(book()) [%Metadata.BookId{type: type, bid: bid} | _] = expected_book.bids