Add the json fetchers to scrape the API.
continuous-integration/drone/push Build is passing

This commit is contained in:
2025-03-18 18:34:43 +02:00
parent 52ff683c2d
commit 57ead52ba2
4 changed files with 87 additions and 0 deletions
@@ -0,0 +1,18 @@
defmodule DecentralisedBookIndex.Sync.ApiClients.FetchJsonTest do
use DecentralisedBookIndex.DataCase
alias DecentralisedBookIndex.Sync.ApiClients.FetchJson
alias DecentralisedBookIndex.Metadata
alias DecentralisedBookIndex.TestEndpoints
@test_server_endpoint TestEndpoints.test_api_endpoint()
describe "authors api" do
test "get an author" do
{:ok, author} = Metadata.create_author("Author", "An description")
assert {:ok, data} = FetchJson.get("#{@test_server_endpoint}/api/v1/json/author/#{author.id}")
assert data["data"]["id"] == author.id
end
end
end
@@ -0,0 +1,21 @@
defmodule DecentralisedBookIndex.Sync.ApiClients.FetchJsonsTest do
use DecentralisedBookIndex.DataCase
alias DecentralisedBookIndex.Sync.ApiClients.FetchJsons
alias DecentralisedBookIndex.Metadata
alias DecentralisedBookIndex.TestEndpoints
@test_server_endpoint TestEndpoints.test_api_endpoint()
describe "authors api" do
test "get authors" do
for number <- 1..11 do
Metadata.create_author!("Author#{number}", "An description#{number}")
end
assert {:ok, records} = FetchJsons.get("#{@test_server_endpoint}/api/v1/json/author")
assert length(records) == 11
end
end
end