Add generators for user, author and author_roles for tests.
This commit is contained in:
@@ -5,22 +5,14 @@ defmodule DecentralisedBookIndex.Metadata.BookTest do
|
||||
|
||||
describe "books and registries relationship" do
|
||||
test "a new book get new registry by default" do
|
||||
{:ok, author} = Metadata.create_author("Author", "An description")
|
||||
|
||||
author_roles = [
|
||||
%{order: 1, author_id: author.id, role: ""}
|
||||
]
|
||||
author_roles = author_roles()
|
||||
|
||||
assert {:ok, book} = Metadata.create_book("Book", "1234567890", "An description", author_roles)
|
||||
assert book.book_editions_registry_id != nil
|
||||
end
|
||||
|
||||
test "a new book belongs to a registry if specified" do
|
||||
{:ok, author} = Metadata.create_author("Author", "An description")
|
||||
|
||||
author_roles = [
|
||||
%{order: 1, author_id: author.id, role: ""}
|
||||
]
|
||||
author_roles = author_roles()
|
||||
|
||||
assert {:ok, registry} = Metadata.create_book_editions_registry()
|
||||
assert {:ok, book} = Metadata.create_book("Book", "1234567890", "An description", author_roles, registry.id)
|
||||
@@ -28,11 +20,7 @@ defmodule DecentralisedBookIndex.Metadata.BookTest do
|
||||
end
|
||||
|
||||
test "a new book to a registry via a related book record" do
|
||||
{:ok, author} = Metadata.create_author("Author", "An description")
|
||||
|
||||
author_roles = [
|
||||
%{order: 1, author_id: author.id, role: ""}
|
||||
]
|
||||
author_roles = author_roles()
|
||||
|
||||
{:ok, related_book} = Metadata.create_book("Book", "1234567890", "An description", author_roles)
|
||||
|
||||
@@ -43,11 +31,7 @@ defmodule DecentralisedBookIndex.Metadata.BookTest do
|
||||
end
|
||||
|
||||
test "a new book to a registry via a empty related book record" do
|
||||
{:ok, author} = Metadata.create_author("Author", "An description")
|
||||
|
||||
author_roles = [
|
||||
%{order: 1, author_id: author.id, role: ""}
|
||||
]
|
||||
author_roles = author_roles()
|
||||
|
||||
assert {:error, _} =
|
||||
Metadata.add_book_to_related_editions_registry("Book2", "1234567891", "An description2", author_roles, nil)
|
||||
@@ -56,11 +40,7 @@ defmodule DecentralisedBookIndex.Metadata.BookTest do
|
||||
|
||||
describe "books alternatives names" do
|
||||
test "new book has no alternatives names" do
|
||||
{:ok, author} = Metadata.create_author("Author", "An description")
|
||||
|
||||
author_roles = [
|
||||
%{order: 1, author_id: author.id, role: ""}
|
||||
]
|
||||
author_roles = author_roles()
|
||||
|
||||
{:ok, book} = Metadata.create_book("Book", "1234567890", "An description", author_roles)
|
||||
assert {:ok, alternatives_names} = Metadata.get_book_alternative_editions(book)
|
||||
@@ -68,11 +48,7 @@ defmodule DecentralisedBookIndex.Metadata.BookTest do
|
||||
end
|
||||
|
||||
test "book has related book so they has one alternative name" do
|
||||
{:ok, author} = Metadata.create_author("Author", "An description")
|
||||
|
||||
author_roles = [
|
||||
%{order: 1, author_id: author.id, role: ""}
|
||||
]
|
||||
author_roles = author_roles()
|
||||
|
||||
{:ok, related_book} = Metadata.create_book("Book", "1234567890", "An description", author_roles)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user