Refactor require_migration/1 into a test helper function
authorAlex Gleason <alex@alexgleason.me>
Wed, 22 Jul 2020 18:45:15 +0000 (13:45 -0500)
committerAlex Gleason <alex@alexgleason.me>
Wed, 22 Jul 2020 19:32:44 +0000 (14:32 -0500)
test/migrations/20200716195806_autolinker_to_linkify_test.exs
test/support/helpers.ex

index 362cf5535c70c77b5c7f3c293bd45f73f386149f..063dab0f70c0b199079835759a00e2c7f3aaad90 100644 (file)
@@ -1,14 +1,10 @@
 defmodule Pleroma.Repo.Migrations.AutolinkerToLinkifyTest do
   use Pleroma.DataCase
   import Pleroma.Factory
+  import Pleroma.Tests.Helpers, only: [require_migration: 1]
   alias Pleroma.ConfigDB
 
-  setup_all do
-    [{module, _}] =
-      Code.require_file("20200716195806_autolinker_to_linkify.exs", "priv/repo/migrations")
-
-    {:ok, %{migration: module}}
-  end
+  setup_all do: require_migration("20200716195806_autolinker_to_linkify")
 
   test "change/0 converts auto_linker opts for Pleroma.Formatter", %{migration: migration} do
     autolinker_opts = [
index 26281b45e74dd5a9d5bba84321b755d590a70bf9..5cbf2e29197c14de391dcef39aea3126ef3401d3 100644 (file)
@@ -32,6 +32,11 @@ defmodule Pleroma.Tests.Helpers do
     end
   end
 
+  def require_migration(migration_name) do
+    [{module, _}] = Code.require_file("#{migration_name}.exs", "priv/repo/migrations")
+    {:ok, %{migration: module}}
+  end
+
   defmacro __using__(_opts) do
     quote do
       import Pleroma.Tests.Helpers,