1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Mix.PleromaTest do
6 use ExUnit.Case, async: true
10 Mix.shell(Mix.Shell.Process)
13 Mix.shell(Mix.Shell.IO)
19 describe "shell_prompt/1" do
21 send(self(), {:mix_shell_input, :prompt, "Yes"})
23 answer = shell_prompt("Do you want this?")
24 assert_received {:mix_shell, :prompt, [message]}
25 assert message =~ "Do you want this?"
26 assert answer == "Yes"
30 send(self(), {:mix_shell_input, :prompt, "\n"})
32 answer = shell_prompt("Do you want this?", "defval")
34 assert_received {:mix_shell, :prompt, [message]}
35 assert message =~ "Do you want this? [defval]"
36 assert answer == "defval"
40 describe "get_option/3" do
41 test "get from options" do
42 assert get_option([domain: "some-domain.com"], :domain, "Prompt") == "some-domain.com"
45 test "get from prompt" do
46 send(self(), {:mix_shell_input, :prompt, "another-domain.com"})
47 assert get_option([], :domain, "Prompt") == "another-domain.com"