Add a test for the migration
authorMark Felder <feld@FreeBSD.org>
Thu, 6 Aug 2020 21:37:17 +0000 (16:37 -0500)
committerMark Felder <feld@feld.me>
Tue, 1 Jun 2021 16:49:47 +0000 (11:49 -0500)
test/migrations/20200806175913_rename_instance_chat_test.exs [new file with mode: 0644]

diff --git a/test/migrations/20200806175913_rename_instance_chat_test.exs b/test/migrations/20200806175913_rename_instance_chat_test.exs
new file mode 100644 (file)
index 0000000..66341bd
--- /dev/null
@@ -0,0 +1,21 @@
+defmodule Pleroma.Repo.Migrations.RenameInstanceChatTest do
+  use Pleroma.DataCase
+  import Pleroma.Factory
+  import Pleroma.Tests.Helpers
+  alias Pleroma.ConfigDB
+
+  setup do: clear_config([:instance])
+  setup do: clear_config([:chat])
+  setup_all do: require_migration("20200806175913_rename_instance_chat")
+
+  test "up/0 migrates chat settings to shout", %{migration: migration} do
+    insert(:config, group: :pleroma, key: :instance, value: ["chat_limit: 6000"])
+    insert(:config, group: :pleroma, key: :chat, value: ["enabled: true"])
+
+    migration.up()
+
+    assert nil == ConfigDB.get_by_params(%{group: :pleroma, key: :chat})
+
+    assert %{value: [limit: 6000, enabled: true]} == ConfigDB.get_by_params(%{group: :pleroma, key: :shout})
+  end
+end