1
0
Fork 1
mirror of https://akkoma.dev/AkkomaGang/akkoma.git synced 2024-12-25 04:53:06 +00:00

Update test for RenameInstanceChat migration

This commit is contained in:
Roman Chvanikov 2020-08-07 12:18:55 +03:00 committed by Mark Felder
parent e0bb655773
commit d7dfa6d27c

View file

@ -8,14 +8,45 @@ defmodule Pleroma.Repo.Migrations.RenameInstanceChatTest do
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"])
describe "up/0" do
test "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 migration.up() == :ok
assert nil == ConfigDB.get_by_params(%{group: :pleroma, key: :chat})
assert ConfigDB.get_by_params(%{group: :pleroma, key: :chat}) == nil
assert ConfigDB.get_by_params(%{group: :pleroma, key: :instance}) == nil
assert %{value: [limit: 6000, enabled: true]} == ConfigDB.get_by_params(%{group: :pleroma, key: :shout})
assert ConfigDB.get_by_params(%{group: :pleroma, key: :shout}).value == [
limit: 6000,
enabled: true
]
end
test "does nothing when chat settings are not set", %{migration: migration} do
assert migration.up() == :noop
assert ConfigDB.get_by_params(%{group: :pleroma, key: :chat}) == nil
assert ConfigDB.get_by_params(%{group: :pleroma, key: :shout}) == nil
end
end
describe "down/0" do
test "migrates shout settings back to instance and chat", %{migration: migration} do
insert(:config, group: :pleroma, key: :shout, value: [limit: 42, enabled: true])
assert migration.down() == :ok
assert ConfigDB.get_by_params(%{group: :pleroma, key: :chat}).value == [enabled: true]
assert ConfigDB.get_by_params(%{group: :pleroma, key: :instance}).value == [chat_limit: 42]
assert ConfigDB.get_by_params(%{group: :pleroma, key: :shout}) == nil
end
test "does nothing when shout settings are not set", %{migration: migration} do
assert migration.down() == :noop
assert ConfigDB.get_by_params(%{group: :pleroma, key: :chat}) == nil
assert ConfigDB.get_by_params(%{group: :pleroma, key: :instance}) == nil
assert ConfigDB.get_by_params(%{group: :pleroma, key: :shout}) == nil
end
end
end