Fix Oban warning
authorEgor Kislitsyn <egor@kislitsyn.com>
Wed, 22 Apr 2020 15:00:08 +0000 (19:00 +0400)
committerEgor Kislitsyn <egor@kislitsyn.com>
Wed, 22 Apr 2020 15:27:28 +0000 (19:27 +0400)
Warning example:

     [warn] Expected Elixir.Pleroma.Workers.BackgroundWorker.perform/2 to return :ok, {:ok, value}, or {:error, reason}. Instead received:  [error: "not found @user@server.party", error: "not found "]  The job will be considered a success.

lib/pleroma/workers/background_worker.ex
test/user_test.exs
test/web/twitter_api/util_controller_test.exs

index 0f8ece2c4cfc2acd9e4da300de866716e322e308..57c3a9c3a30c9209683362b4d730523fefc75202 100644 (file)
@@ -35,7 +35,7 @@ defmodule Pleroma.Workers.BackgroundWorker do
         _job
       ) do
     blocker = User.get_cached_by_id(blocker_id)
-    User.perform(:blocks_import, blocker, blocked_identifiers)
+    {:ok, User.perform(:blocks_import, blocker, blocked_identifiers)}
   end
 
   def perform(
@@ -47,7 +47,7 @@ defmodule Pleroma.Workers.BackgroundWorker do
         _job
       ) do
     follower = User.get_cached_by_id(follower_id)
-    User.perform(:follow_import, follower, followed_identifiers)
+    {:ok, User.perform(:follow_import, follower, followed_identifiers)}
   end
 
   def perform(%{"op" => "media_proxy_preload", "message" => message}, _job) do
index 65e118d6dc9da90e99405005ffc2a1e9bea03869..23e7cf6e3b83dc37a53fad114ef015bfd2a2ce80 100644 (file)
@@ -756,8 +756,8 @@ defmodule Pleroma.UserTest do
       ]
 
       {:ok, job} = User.follow_import(user1, identifiers)
-      result = ObanHelpers.perform(job)
 
+      assert {:ok, result} = ObanHelpers.perform(job)
       assert is_list(result)
       assert result == [user2, user3]
     end
@@ -979,8 +979,8 @@ defmodule Pleroma.UserTest do
       ]
 
       {:ok, job} = User.blocks_import(user1, identifiers)
-      result = ObanHelpers.perform(job)
 
+      assert {:ok, result} = ObanHelpers.perform(job)
       assert is_list(result)
       assert result == [user2, user3]
     end
index d835331ae303c584f78bd4bbe577f3358e8d91ca..b701239a01cd36374a4bff2fc864fb57471f79c5 100644 (file)
@@ -116,7 +116,7 @@ defmodule Pleroma.Web.TwitterAPI.UtilControllerTest do
         |> json_response(:ok)
 
       assert response == "job started"
-      assert [job_result] = ObanHelpers.perform_all()
+      assert [{:ok, job_result}] = ObanHelpers.perform_all()
       assert job_result == [user2, user3, user4, user5, user6]
     end
   end
@@ -180,7 +180,7 @@ defmodule Pleroma.Web.TwitterAPI.UtilControllerTest do
         |> json_response(:ok)
 
       assert response == "job started"
-      assert [job_result] = ObanHelpers.perform_all()
+      assert [{:ok, job_result}] = ObanHelpers.perform_all()
       assert job_result == [user2, user3, user4, user5, user6]
     end
   end