1 defmodule Pleroma.Repo.Migrations.FixMalformedFormatterConfigTest do
4 import Pleroma.Tests.Helpers, only: [require_migration: 1]
7 setup_all do: require_migration("20200722185515_fix_malformed_formatter_config")
9 test "change/0 converts a map into a list", %{migration: migration} do
18 insert(:config, group: :pleroma, key: Pleroma.Formatter, value: incorrect_opts)
20 assert :ok == migration.change()
22 %{value: new_opts} = ConfigDB.get_by_params(%{group: :pleroma, key: Pleroma.Formatter})
32 {text, _mentions, []} =
33 Pleroma.Formatter.linkify(
34 "https://www.businessinsider.com/walmart-will-close-stores-on-thanksgiving-ending-black-friday-tradition-2020-7\n\nOmg will COVID finally end Black Friday???"
38 "<a href=\"https://www.businessinsider.com/walmart-will-close-stores-on-thanksgiving-ending-black-friday-tradition-2020-7\" rel=\"ugc\">https://www.businessinsider.com/walmart-will-close-stores-on-thanksgiving-ending-black-friday-tradition-2020-7</a>\n\nOmg will COVID finally end Black Friday???"
41 test "change/0 skips if Pleroma.Formatter config is already a list", %{migration: migration} do
50 insert(:config, group: :pleroma, key: Pleroma.Formatter, value: opts)
52 assert :skipped == migration.change()
54 %{value: new_opts} = ConfigDB.get_by_params(%{group: :pleroma, key: Pleroma.Formatter})
56 assert new_opts == opts
59 test "change/0 skips if Pleroma.Formatter is empty", %{migration: migration} do
60 assert :skipped == migration.change()