logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma git clone https://hacktivis.me/git/pleroma.git

deprecate_public_endpoint_test.exs (1970B)


  1. # Pleroma: A lightweight social networking server
  2. # Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
  3. # SPDX-License-Identifier: AGPL-3.0-only
  4. defmodule Pleroma.Repo.Migrations.DeprecatePublicEndpointTest do
  5. use Pleroma.DataCase
  6. import Pleroma.Factory
  7. import Pleroma.Tests.Helpers
  8. alias Pleroma.ConfigDB
  9. setup do: clear_config(Pleroma.Upload)
  10. setup do: clear_config(Pleroma.Uploaders.S3)
  11. setup_all do: require_migration("20210113225652_deprecate_public_endpoint")
  12. test "up/0 migrates public_endpoint to base_url", %{migration: migration} do
  13. s3_values = [
  14. public_endpoint: "https://coolhost.com/",
  15. bucket: "secret_bucket"
  16. ]
  17. insert(:config, group: :pleroma, key: Pleroma.Uploaders.S3, value: s3_values)
  18. upload_values = [
  19. uploader: Pleroma.Uploaders.S3
  20. ]
  21. insert(:config, group: :pleroma, key: Pleroma.Upload, value: upload_values)
  22. migration.up()
  23. assert [bucket: "secret_bucket"] ==
  24. ConfigDB.get_by_params(%{group: :pleroma, key: Pleroma.Uploaders.S3}).value
  25. assert [uploader: Pleroma.Uploaders.S3, base_url: "https://coolhost.com/"] ==
  26. ConfigDB.get_by_params(%{group: :pleroma, key: Pleroma.Upload}).value
  27. end
  28. test "down/0 reverts base_url to public_endpoint", %{migration: migration} do
  29. s3_values = [
  30. bucket: "secret_bucket"
  31. ]
  32. insert(:config, group: :pleroma, key: Pleroma.Uploaders.S3, value: s3_values)
  33. upload_values = [
  34. uploader: Pleroma.Uploaders.S3,
  35. base_url: "https://coolhost.com/"
  36. ]
  37. insert(:config, group: :pleroma, key: Pleroma.Upload, value: upload_values)
  38. migration.down()
  39. assert [bucket: "secret_bucket", public_endpoint: "https://coolhost.com/"] ==
  40. ConfigDB.get_by_params(%{group: :pleroma, key: Pleroma.Uploaders.S3}).value
  41. assert [uploader: Pleroma.Uploaders.S3] ==
  42. ConfigDB.get_by_params(%{group: :pleroma, key: Pleroma.Upload}).value
  43. end
  44. end