2019-11-21 15:51:13 +01:00
|
|
|
defmodule Mix.Tasks.Mobilizon.ActorsTest do
|
|
|
|
use Mobilizon.DataCase
|
|
|
|
|
|
|
|
import Mobilizon.Factory
|
|
|
|
|
2020-01-28 20:15:59 +01:00
|
|
|
alias Mix.Tasks.Mobilizon.Actors.Show
|
|
|
|
|
|
|
|
alias Mobilizon.Actors.Actor
|
|
|
|
|
2019-11-21 15:51:13 +01:00
|
|
|
Mix.shell(Mix.Shell.Process)
|
|
|
|
|
|
|
|
@username "someone"
|
|
|
|
@domain "somewhere.tld"
|
2021-04-12 12:01:09 +02:00
|
|
|
@error "Error: No such actor"
|
2019-11-21 15:51:13 +01:00
|
|
|
|
|
|
|
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
|
2020-10-30 15:16:01 +01:00
|
|
|
Show.run([@username])
|
|
|
|
assert_received {:mix_shell, :error, [message]}
|
2021-04-12 12:01:09 +02:00
|
|
|
assert message =~ @error
|
2019-11-21 15:51:13 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|