Fork of Pleroma with site-specific changes and feature branches https://git.pleroma.social/pleroma/pleroma
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

58 lines
1.6KB

  1. # Pleroma: A lightweight social networking server
  2. # Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
  3. # SPDX-License-Identifier: AGPL-3.0-only
  4. defmodule Pleroma.Config.TransferTaskTest do
  5. use Pleroma.DataCase
  6. setup do
  7. dynamic = Pleroma.Config.get([:instance, :dynamic_configuration])
  8. Pleroma.Config.put([:instance, :dynamic_configuration], true)
  9. on_exit(fn ->
  10. Pleroma.Config.put([:instance, :dynamic_configuration], dynamic)
  11. end)
  12. end
  13. test "transfer config values from db to env" do
  14. refute Application.get_env(:pleroma, :test_key)
  15. refute Application.get_env(:idna, :test_key)
  16. Pleroma.Web.AdminAPI.Config.create(%{
  17. group: "pleroma",
  18. key: "test_key",
  19. value: [live: 2, com: 3]
  20. })
  21. Pleroma.Web.AdminAPI.Config.create(%{
  22. group: "idna",
  23. key: "test_key",
  24. value: [live: 15, com: 35]
  25. })
  26. Pleroma.Config.TransferTask.start_link()
  27. assert Application.get_env(:pleroma, :test_key) == [live: 2, com: 3]
  28. assert Application.get_env(:idna, :test_key) == [live: 15, com: 35]
  29. on_exit(fn ->
  30. Application.delete_env(:pleroma, :test_key)
  31. Application.delete_env(:idna, :test_key)
  32. end)
  33. end
  34. test "non existing atom" do
  35. Pleroma.Web.AdminAPI.Config.create(%{
  36. group: "pleroma",
  37. key: "undefined_atom_key",
  38. value: [live: 2, com: 3]
  39. })
  40. assert ExUnit.CaptureLog.capture_log(fn ->
  41. Pleroma.Config.TransferTask.start_link()
  42. end) =~
  43. "updating env causes error, key: \"undefined_atom_key\", error: %ArgumentError{message: \"argument error\"}"
  44. end
  45. end