1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Repo.Migrations.AutolinkerToLinkifyTest do
8 import Pleroma.Tests.Helpers
11 setup do: clear_config(Pleroma.Formatter)
12 setup_all do: require_migration("20200716195806_autolinker_to_linkify")
14 test "change/0 converts auto_linker opts for Pleroma.Formatter", %{migration: migration} do
24 insert(:config, group: :auto_linker, key: :opts, value: autolinker_opts)
28 assert nil == ConfigDB.get_by_params(%{group: :auto_linker, key: :opts})
30 %{value: new_opts} = ConfigDB.get_by_params(%{group: :pleroma, key: Pleroma.Formatter})
40 clear_config(Pleroma.Formatter, new_opts)
41 assert new_opts == Pleroma.Config.get(Pleroma.Formatter)
43 {text, _mentions, []} =
44 Pleroma.Formatter.linkify(
45 "https://www.businessinsider.com/walmart-will-close-stores-on-thanksgiving-ending-black-friday-tradition-2020-7\n\nOmg will COVID finally end Black Friday???"
49 "<a href=\"https://www.businessinsider.com/walmart-will-close-stores-on-thanksgiving-ending-black-friday-tradition-2020-7\" rel=\"testing\">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???"
52 test "transform_opts/1 returns a list of compatible opts", %{migration: migration} do
70 assert migration.transform_opts(old_opts) == expected_opts