Update the sync task for Author to link the record with the server.
continuous-integration/drone/push Build is passing

This commit is contained in:
2025-03-23 12:33:41 +02:00
parent e5e05320cf
commit b8a7ac9a48
5 changed files with 37 additions and 13 deletions
@@ -5,8 +5,13 @@ defmodule DecentralisedBookIndex.Sync.DataTransformers.AuthorSyncTest do
alias DecentralisedBookIndex.Metadata.Author
alias DecentralisedBookIndex.Metadata
alias DecentralisedBookIndex.TestEndpoints
@test_server_endpoint TestEndpoints.test_api_endpoint()
describe "sync author transformations" do
test "a new author will be created" do
server = generate(dbi_server(url: @test_server_endpoint))
author = %{
id: "889a323e-d104-4b5d-b276-dad5a9b1da9d",
name: "Author",
@@ -14,15 +19,18 @@ defmodule DecentralisedBookIndex.Sync.DataTransformers.AuthorSyncTest do
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 author.id == saved_author.id
assert author.name == saved_author.name
assert nil != saved_author.author_alias_registry_id
assert server.id == saved_author.dbi_server_id
end
test "update an existing author" do
server = generate(dbi_server(url: @test_server_endpoint))
{:ok, author} = Metadata.create_author("Author", "An description")
author_attrs = %{
@@ -32,7 +40,7 @@ defmodule DecentralisedBookIndex.Sync.DataTransformers.AuthorSyncTest do
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 author.id == saved_author.id
@@ -9,12 +9,12 @@ defmodule DecentralisedBookIndex.SyncTasks.SyncAuthorsTaskTest do
describe "sync authors tasks" do
test "sync authors" do
server = generate(dbi_server(url: @test_server_endpoint))
{:ok, author} = Metadata.create_author("Author", "An description")
{:ok, author} = Metadata.create_author("Author2", "An description")
endpoint = @test_server_endpoint
assert endpoint = SyncAuthorsTask.sync(endpoint)
assert server = SyncAuthorsTask.sync(server)
end
end
end