This commit is contained in:
@@ -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
|
||||
Reference in New Issue
Block a user