logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma

pleroma_test.exs (1302B)


  1. # Pleroma: A lightweight social networking server
  2. # Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
  3. # SPDX-License-Identifier: AGPL-3.0-only
  4. defmodule Mix.PleromaTest do
  5. use ExUnit.Case, async: true
  6. import Mix.Pleroma
  7. setup_all do
  8. Mix.shell(Mix.Shell.Process)
  9. on_exit(fn ->
  10. Mix.shell(Mix.Shell.IO)
  11. end)
  12. :ok
  13. end
  14. describe "shell_prompt/1" do
  15. test "input" do
  16. send(self(), {:mix_shell_input, :prompt, "Yes"})
  17. answer = shell_prompt("Do you want this?")
  18. assert_received {:mix_shell, :prompt, [message]}
  19. assert message =~ "Do you want this?"
  20. assert answer == "Yes"
  21. end
  22. test "with defval" do
  23. send(self(), {:mix_shell_input, :prompt, "\n"})
  24. answer = shell_prompt("Do you want this?", "defval")
  25. assert_received {:mix_shell, :prompt, [message]}
  26. assert message =~ "Do you want this? [defval]"
  27. assert answer == "defval"
  28. end
  29. end
  30. describe "get_option/3" do
  31. test "get from options" do
  32. assert get_option([domain: "some-domain.com"], :domain, "Promt") == "some-domain.com"
  33. end
  34. test "get from prompt" do
  35. send(self(), {:mix_shell_input, :prompt, "another-domain.com"})
  36. assert get_option([], :domain, "Prompt") == "another-domain.com"
  37. end
  38. end
  39. end