Add an action to get author's alternatives names.

This commit is contained in:
2025-03-08 21:28:46 +02:00
parent f0f7037447
commit ee72055f81
3 changed files with 34 additions and 1 deletions
@@ -16,7 +16,7 @@ defmodule DecentralisedBookIndex.Metadata.AuthorTest do
end
test "a new author to a registry via a related author record" do
{:ok, related_author} = Metadata.create_author("Author", "An description")
{:ok, related_author} = Metadata.create_author("Author", "An description")
assert {:ok, author} =
Metadata.add_author_to_related_alias_registry("Author2", "An description2", related_author.id)
@@ -29,4 +29,22 @@ defmodule DecentralisedBookIndex.Metadata.AuthorTest do
Metadata.add_author_to_related_alias_registry("Author2", "An description2", nil)
end
end
describe "authors alternatives names" do
test "new author has no alternatives names" do
{:ok, author} = Metadata.create_author("Author", "An description")
assert {:ok, alternatives_names} = Metadata.get_author_alternative_names(author)
assert alternatives_names = []
end
test "author has related author so they has one alternative name" do
{:ok, related_author} = Metadata.create_author("Author", "An description")
{:ok, author} =
Metadata.add_author_to_related_alias_registry("Author2", "An description2", related_author.id)
assert {:ok, alternatives_names} = Metadata.get_author_alternative_names(author)
assert alternatives_names = [related_author]
end
end
end