This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
defmodule DecentralisedBookIndex.Sync.DataTransformers.AuthorSyncTest do
|
||||
use DecentralisedBookIndex.DataCase, async: true
|
||||
|
||||
alias DecentralisedBookIndex.Sync.AuthorSync
|
||||
alias DecentralisedBookIndex.Metadata.Author
|
||||
alias DecentralisedBookIndex.Metadata
|
||||
|
||||
describe "sync author transformations" do
|
||||
test "a new author will be created" do
|
||||
author = %{
|
||||
id: "889a323e-d104-4b5d-b276-dad5a9b1da9d",
|
||||
name: "Author",
|
||||
description: "Something",
|
||||
author_alias_registry_id: nil
|
||||
}
|
||||
|
||||
assert :ok = AuthorSync.create_update(author)
|
||||
assert {:ok, saved_author} = Metadata.get_author_by_id(author.id)
|
||||
|
||||
assert author.id == saved_author.id
|
||||
assert author.name == saved_author.name
|
||||
assert nil != saved_author.author_alias_registry_id
|
||||
end
|
||||
|
||||
test "update an existing author" do
|
||||
{:ok, author} = Metadata.create_author("Author", "An description")
|
||||
|
||||
author_attrs = %{
|
||||
id: author.id,
|
||||
name: "Author2",
|
||||
description: "Something2",
|
||||
author_alias_registry_id: nil
|
||||
}
|
||||
|
||||
assert :ok = AuthorSync.create_update(author_attrs)
|
||||
assert {:ok, saved_author} = Metadata.get_author_by_id(author.id)
|
||||
|
||||
assert author.id == saved_author.id
|
||||
assert author_attrs.name == saved_author.name
|
||||
assert author_attrs.description == saved_author.description
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user