Add the sync server task.
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
b8a7ac9a48
commit
1b27b07268
@ -0,0 +1,23 @@
|
|||||||
|
defmodule DecentralisedBookIndex.Sync.SyncServerTask do
|
||||||
|
alias DecentralisedBookIndex.Metadata
|
||||||
|
alias DecentralisedBookIndex.Metadata.DBIServer
|
||||||
|
|
||||||
|
alias DecentralisedBookIndex.SyncTasks.SyncAuthorsTask
|
||||||
|
|
||||||
|
def sync_all() do
|
||||||
|
{:ok, servers} = Metadata.list_dbi_server()
|
||||||
|
|
||||||
|
for server <- servers do
|
||||||
|
sync_one(server)
|
||||||
|
end
|
||||||
|
|
||||||
|
:ok
|
||||||
|
end
|
||||||
|
|
||||||
|
def sync_one(%DBIServer{} = server) do
|
||||||
|
server
|
||||||
|
|> SyncAuthorsTask.sync()
|
||||||
|
|
||||||
|
:ok
|
||||||
|
end
|
||||||
|
end
|
@ -0,0 +1,31 @@
|
|||||||
|
defmodule DecentralisedBookIndex.Sync.SyncServerTaskTest do
|
||||||
|
use DecentralisedBookIndex.DataCase
|
||||||
|
|
||||||
|
alias DecentralisedBookIndex.Sync.SyncServerTask
|
||||||
|
|
||||||
|
alias DecentralisedBookIndex.Sync.ApiClients.FetchJson
|
||||||
|
alias DecentralisedBookIndex.Sync.AuthorSync
|
||||||
|
|
||||||
|
alias DecentralisedBookIndex.Metadata
|
||||||
|
|
||||||
|
alias DecentralisedBookIndex.TestEndpoints
|
||||||
|
@test_server_endpoint TestEndpoints.test_api_endpoint()
|
||||||
|
|
||||||
|
describe "sync all" do
|
||||||
|
test "servers" do
|
||||||
|
server = generate(dbi_server(url: @test_server_endpoint))
|
||||||
|
{:ok, author} = Metadata.create_author("Author", "An description")
|
||||||
|
|
||||||
|
assert server = SyncServerTask.sync_all()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "sync one" do
|
||||||
|
test "server" do
|
||||||
|
server = generate(dbi_server(url: @test_server_endpoint))
|
||||||
|
{:ok, author} = Metadata.create_author("Author", "An description")
|
||||||
|
|
||||||
|
assert server = SyncServerTask.sync_one(server)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in new issue