Add tests for assigning DBIServer to Author and Book.
continuous-integration/drone/push Build is passing
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -3,6 +3,9 @@ defmodule DecentralisedBookIndex.Metadata.AuthorTest do
|
|||||||
|
|
||||||
alias DecentralisedBookIndex.Metadata
|
alias DecentralisedBookIndex.Metadata
|
||||||
|
|
||||||
|
alias DecentralisedBookIndex.TestEndpoints
|
||||||
|
@test_server_endpoint TestEndpoints.test_api_endpoint()
|
||||||
|
|
||||||
setup do
|
setup do
|
||||||
user = generate(user(role: :moderator))
|
user = generate(user(role: :moderator))
|
||||||
%{user: user}
|
%{user: user}
|
||||||
@@ -129,6 +132,17 @@ defmodule DecentralisedBookIndex.Metadata.AuthorTest do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "author and DBIServer relationship" do
|
||||||
|
test "assign a DBIServer", %{user: user} do
|
||||||
|
server = generate(dbi_server(url: @test_server_endpoint))
|
||||||
|
|
||||||
|
assert {:ok, author} =
|
||||||
|
Metadata.create_author("Author", "An description", nil, nil, actor: user)
|
||||||
|
assert {:ok, author} = Metadata.assign_author_dbi_server(author, server.id, actor: user)
|
||||||
|
assert author.dbi_server_id == server.id
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe "calculate a brief description" do
|
describe "calculate a brief description" do
|
||||||
test "a short description is already enough" do
|
test "a short description is already enough" do
|
||||||
description = "Amazing!"
|
description = "Amazing!"
|
||||||
|
|||||||
@@ -3,6 +3,9 @@ defmodule DecentralisedBookIndex.Metadata.BookTest do
|
|||||||
|
|
||||||
alias DecentralisedBookIndex.Metadata
|
alias DecentralisedBookIndex.Metadata
|
||||||
|
|
||||||
|
alias DecentralisedBookIndex.TestEndpoints
|
||||||
|
@test_server_endpoint TestEndpoints.test_api_endpoint()
|
||||||
|
|
||||||
setup do
|
setup do
|
||||||
user = generate(user(role: :moderator))
|
user = generate(user(role: :moderator))
|
||||||
%{user: user}
|
%{user: user}
|
||||||
@@ -274,6 +277,16 @@ defmodule DecentralisedBookIndex.Metadata.BookTest do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "book and DBIServer relationship" do
|
||||||
|
test "assign a DBIServer", %{user: user} do
|
||||||
|
server = generate(dbi_server(url: @test_server_endpoint))
|
||||||
|
book = generate(book())
|
||||||
|
|
||||||
|
assert {:ok, book} = Metadata.assign_book_dbi_server(book, server.id, actor: user)
|
||||||
|
assert book.dbi_server_id == server.id
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe "calculate a brief description" do
|
describe "calculate a brief description" do
|
||||||
test "a short description is already enough" do
|
test "a short description is already enough" do
|
||||||
description = "Amazing!"
|
description = "Amazing!"
|
||||||
|
|||||||
Reference in New Issue
Block a user