mirror of
https://framagit.org/framasoft/mobilizon.git
synced 2024-12-21 23:44:30 +00:00
ed7b53357f
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
57 lines
1.4 KiB
Elixir
57 lines
1.4 KiB
Elixir
defmodule Mix.Tasks.Mobilizon.ActorsTest do
|
|
use Mobilizon.DataCase
|
|
|
|
import Mobilizon.Factory
|
|
|
|
alias Mix.Tasks.Mobilizon.Actors.Show
|
|
|
|
alias Mobilizon.Actors.Actor
|
|
|
|
Mix.shell(Mix.Shell.Process)
|
|
|
|
@username "someone"
|
|
@domain "somewhere.tld"
|
|
@error "Error: No such actor"
|
|
|
|
describe "show actor" do
|
|
test "show existing local actor" do
|
|
%Actor{} = actor = insert(:actor, preferred_username: @username)
|
|
|
|
output = """
|
|
Informations for the actor #{@username}:
|
|
- Type: Person
|
|
- Domain: Local
|
|
- Name: #{actor.name}
|
|
- Summary: #{actor.summary}
|
|
- User: #{actor.user.email}
|
|
"""
|
|
|
|
Show.run([@username])
|
|
assert_received {:mix_shell, :info, [output_received]}
|
|
assert output_received == output
|
|
end
|
|
|
|
test "show existing remote actor" do
|
|
%Actor{} = actor = insert(:actor, preferred_username: @username, user: nil, domain: @domain)
|
|
|
|
output = """
|
|
Informations for the actor #{@username}:
|
|
- Type: Person
|
|
- Domain: #{@domain}
|
|
- Name: #{actor.name}
|
|
- Summary: #{actor.summary}
|
|
- User: Remote
|
|
"""
|
|
|
|
Show.run(["#{@username}@#{@domain}"])
|
|
assert_received {:mix_shell, :info, [output_received]}
|
|
assert output_received == output
|
|
end
|
|
|
|
test "show non-existing actor" do
|
|
Show.run([@username])
|
|
assert_received {:mix_shell, :error, [message]}
|
|
assert message =~ @error
|
|
end
|
|
end
|
|
end
|