summaryrefslogtreecommitdiff
path: root/test/tasks/pleroma_test.exs
diff options
context:
space:
mode:
authorMark Felder <feld@FreeBSD.org>2019-07-09 12:49:04 -0500
committerMark Felder <feld@FreeBSD.org>2019-07-09 12:49:04 -0500
commit9a9b60cfbcbcdf3e48e42aa75ff530007cf03b96 (patch)
treefc28e2fb05ad0158fe881de7a49e90d941e10ad4 /test/tasks/pleroma_test.exs
parent9f235028569968871ef9ea933459c6e9369e737a (diff)
parente19e82975871388831fd23adc50fcaaea85ad5da (diff)
downloadpleroma-9a9b60cfbcbcdf3e48e42aa75ff530007cf03b96.tar.gz
pleroma-9a9b60cfbcbcdf3e48e42aa75ff530007cf03b96.zip
Merge branch 'develop' into feature/allow-user-query-via-id
Diffstat (limited to 'test/tasks/pleroma_test.exs')
-rw-r--r--test/tasks/pleroma_test.exs46
1 files changed, 46 insertions, 0 deletions
diff --git a/test/tasks/pleroma_test.exs b/test/tasks/pleroma_test.exs
new file mode 100644
index 000000000..e236ccbbb
--- /dev/null
+++ b/test/tasks/pleroma_test.exs
@@ -0,0 +1,46 @@
+defmodule Mix.PleromaTest do
+ use ExUnit.Case, async: true
+ import Mix.Pleroma
+
+ setup_all do
+ Mix.shell(Mix.Shell.Process)
+
+ on_exit(fn ->
+ Mix.shell(Mix.Shell.IO)
+ end)
+
+ :ok
+ end
+
+ describe "shell_prompt/1" do
+ test "input" do
+ send(self(), {:mix_shell_input, :prompt, "Yes"})
+
+ answer = shell_prompt("Do you want this?")
+ assert_received {:mix_shell, :prompt, [message]}
+ assert message =~ "Do you want this?"
+ assert answer == "Yes"
+ end
+
+ test "with defval" do
+ send(self(), {:mix_shell_input, :prompt, "\n"})
+
+ answer = shell_prompt("Do you want this?", "defval")
+
+ assert_received {:mix_shell, :prompt, [message]}
+ assert message =~ "Do you want this? [defval]"
+ assert answer == "defval"
+ end
+ end
+
+ describe "get_option/3" do
+ test "get from options" do
+ assert get_option([domain: "some-domain.com"], :domain, "Promt") == "some-domain.com"
+ end
+
+ test "get from prompt" do
+ send(self(), {:mix_shell_input, :prompt, "another-domain.com"})
+ assert get_option([], :domain, "Prompt") == "another-domain.com"
+ end
+ end
+end