From 23cfb1009ab23ed6b291654e47e46eb5b9759992 Mon Sep 17 00:00:00 2001 From: KKlochko Date: Fri, 14 Mar 2025 10:53:28 +0200 Subject: [PATCH] Update tests for Book to use bids. --- .../metadata/book_test.exs | 34 ++++++++++++------- 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/test/decentralised_book_index/metadata/book_test.exs b/test/decentralised_book_index/metadata/book_test.exs index bf13449..f604d2d 100644 --- a/test/decentralised_book_index/metadata/book_test.exs +++ b/test/decentralised_book_index/metadata/book_test.exs @@ -6,54 +6,60 @@ defmodule DecentralisedBookIndex.Metadata.BookTest do describe "books and registries relationship" do test "a new book get new registry by default" do author_roles = author_roles() + bids = bids() - assert {:ok, book} = Metadata.create_book("Book", "1234567890", "An description", author_roles) + assert {:ok, book} = Metadata.create_book("Book", "An description", bids, author_roles) assert book.book_editions_registry_id != nil end test "a new book belongs to a registry if specified" do author_roles = author_roles() + bids = bids() assert {:ok, registry} = Metadata.create_book_editions_registry() - assert {:ok, book} = Metadata.create_book("Book", "1234567890", "An description", author_roles, registry.id) + assert {:ok, book} = Metadata.create_book("Book", "An description", bids, author_roles, registry.id) assert book.book_editions_registry_id == registry.id end test "a new book to a registry via a related book record" do author_roles = author_roles() + bids = bids() - {:ok, related_book} = Metadata.create_book("Book", "1234567890", "An description", author_roles) + {:ok, related_book} = Metadata.create_book("Book", "An description", bids, author_roles) assert {:ok, book} = - Metadata.add_book_to_related_editions_registry("Book2", "1234567891", "An description2", author_roles, related_book.id) + Metadata.add_book_to_related_editions_registry("Book2", "An description2", bids, author_roles, related_book.id) assert related_book.book_editions_registry_id == book.book_editions_registry_id end test "a new book to a registry via a empty related book record" do author_roles = author_roles() + bids = bids() assert {:error, _} = - Metadata.add_book_to_related_editions_registry("Book2", "1234567891", "An description2", author_roles, nil) + Metadata.add_book_to_related_editions_registry("Book2", "An description2", bids, author_roles, nil) end end describe "books alternatives names" do test "new book has no alternatives names" do author_roles = author_roles() + bids = bids() - {:ok, book} = Metadata.create_book("Book", "1234567890", "An description", author_roles) + {:ok, book} = Metadata.create_book("Book", "An description", bids, author_roles) assert {:ok, alternatives_names} = Metadata.get_book_alternative_editions(book) assert alternatives_names = [] end test "book has related book so they has one alternative name" do author_roles = author_roles() + bids = bids() - {:ok, related_book} = Metadata.create_book("Book", "1234567890", "An description", author_roles) + {:ok, related_book} = Metadata.create_book("Book", "An description", bids, author_roles) {:ok, book} = - Metadata.add_book_to_related_editions_registry("Book2", "1234567891", "An description2", author_roles, related_book.id) + Metadata.add_book_to_related_editions_registry("Book2", "An description2", bids, author_roles, related_book.id) assert {:ok, alternatives_names} = Metadata.get_book_alternative_editions(book) assert alternatives_names = [related_book] @@ -63,12 +69,13 @@ defmodule DecentralisedBookIndex.Metadata.BookTest do describe "author's books" do test "get the list via author's id" do {:ok, author} = Metadata.create_author("Author", "An description") + bids = bids() author_roles = [ %{order: 1, author_id: author.id, role: ""} ] - {:ok, book} = Metadata.create_book("Book", "1234567890", "An description", author_roles) + {:ok, book} = Metadata.create_book("Book", "An description", bids, author_roles) assert {:ok, books} = Metadata.get_author_books(author) end @@ -83,20 +90,23 @@ defmodule DecentralisedBookIndex.Metadata.BookTest do author_roles = [ %{order: 1, author_id: author.id, role: ""} ] + bids = bids() - {:ok, book} = Metadata.create_book("Book", "1234567890", "An description", author_roles) + {:ok, book} = Metadata.create_book("Book", "An description", bids, author_roles) author_roles = [ %{order: 1, author_id: alias1.id, role: ""} ] + bids2 = bids() - {:ok, book2} = Metadata.create_book("Book2", "1234567890", "An description", author_roles) + {:ok, book2} = Metadata.create_book("Book2", "An description", bids, author_roles) author_roles = [ %{order: 1, author_id: alias2.id, role: ""} ] + bids3 = bids() - {:ok, book3} = Metadata.create_book("Book3", "1234567890", "An description", author_roles) + {:ok, book3} = Metadata.create_book("Book3", "An description", bids, author_roles) assert {:ok, books} = Metadata.get_author_books(author)