|
|
@ -5,8 +5,13 @@ defmodule DecentralisedBookIndex.Sync.DataTransformers.AuthorSyncTest do
|
|
|
|
alias DecentralisedBookIndex.Metadata.Author
|
|
|
|
alias DecentralisedBookIndex.Metadata.Author
|
|
|
|
alias DecentralisedBookIndex.Metadata
|
|
|
|
alias DecentralisedBookIndex.Metadata
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
alias DecentralisedBookIndex.TestEndpoints
|
|
|
|
|
|
|
|
@test_server_endpoint TestEndpoints.test_api_endpoint()
|
|
|
|
|
|
|
|
|
|
|
|
describe "sync author transformations" do
|
|
|
|
describe "sync author transformations" do
|
|
|
|
test "a new author will be created" do
|
|
|
|
test "a new author will be created" do
|
|
|
|
|
|
|
|
server = generate(dbi_server(url: @test_server_endpoint))
|
|
|
|
|
|
|
|
|
|
|
|
author = %{
|
|
|
|
author = %{
|
|
|
|
id: "889a323e-d104-4b5d-b276-dad5a9b1da9d",
|
|
|
|
id: "889a323e-d104-4b5d-b276-dad5a9b1da9d",
|
|
|
|
name: "Author",
|
|
|
|
name: "Author",
|
|
|
@ -14,15 +19,18 @@ defmodule DecentralisedBookIndex.Sync.DataTransformers.AuthorSyncTest do
|
|
|
|
author_alias_registry_id: nil
|
|
|
|
author_alias_registry_id: nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
assert :ok = AuthorSync.create_update(author)
|
|
|
|
assert :ok = AuthorSync.create_update(author, server.id)
|
|
|
|
assert {:ok, saved_author} = Metadata.get_author_by_id(author.id)
|
|
|
|
assert {:ok, saved_author} = Metadata.get_author_by_id(author.id)
|
|
|
|
|
|
|
|
|
|
|
|
assert author.id == saved_author.id
|
|
|
|
assert author.id == saved_author.id
|
|
|
|
assert author.name == saved_author.name
|
|
|
|
assert author.name == saved_author.name
|
|
|
|
assert nil != saved_author.author_alias_registry_id
|
|
|
|
assert nil != saved_author.author_alias_registry_id
|
|
|
|
|
|
|
|
assert server.id == saved_author.dbi_server_id
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
test "update an existing author" do
|
|
|
|
test "update an existing author" do
|
|
|
|
|
|
|
|
server = generate(dbi_server(url: @test_server_endpoint))
|
|
|
|
|
|
|
|
|
|
|
|
{:ok, author} = Metadata.create_author("Author", "An description")
|
|
|
|
{:ok, author} = Metadata.create_author("Author", "An description")
|
|
|
|
|
|
|
|
|
|
|
|
author_attrs = %{
|
|
|
|
author_attrs = %{
|
|
|
@ -32,7 +40,7 @@ defmodule DecentralisedBookIndex.Sync.DataTransformers.AuthorSyncTest do
|
|
|
|
author_alias_registry_id: nil
|
|
|
|
author_alias_registry_id: nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
assert :ok = AuthorSync.create_update(author_attrs)
|
|
|
|
assert :ok = AuthorSync.create_update(author_attrs, server.id)
|
|
|
|
assert {:ok, saved_author} = Metadata.get_author_by_id(author.id)
|
|
|
|
assert {:ok, saved_author} = Metadata.get_author_by_id(author.id)
|
|
|
|
|
|
|
|
|
|
|
|
assert author.id == saved_author.id
|
|
|
|
assert author.id == saved_author.id
|
|
|
|