From 3d50f2d90dca953d42755712e6e87143269c4bcb Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Wed, 23 Mar 2022 11:38:25 +0100 Subject: [PATCH] Update pattern matching for Oban.drain_queue following update Signed-off-by: Thomas Citharel --- .../transmogrifier/delete_test.exs | 4 +++- .../transmogrifier/update_test.exs | 4 ++-- test/graphql/resolvers/activity_test.exs | 20 +++++++++++++++---- test/graphql/resolvers/group_test.exs | 2 +- test/graphql/resolvers/person_test.exs | 6 ++++-- test/graphql/resolvers/user_test.exs | 3 ++- test/mobilizon/actors/actors_test.exs | 3 ++- 7 files changed, 30 insertions(+), 12 deletions(-) diff --git a/test/federation/activity_pub/transmogrifier/delete_test.exs b/test/federation/activity_pub/transmogrifier/delete_test.exs index 00ec4af19..c5b4a8457 100644 --- a/test/federation/activity_pub/transmogrifier/delete_test.exs +++ b/test/federation/activity_pub/transmogrifier/delete_test.exs @@ -117,7 +117,9 @@ defmodule Mobilizon.Federation.ActivityPub.Transmogrifier.DeleteTest do end) {:ok, _activity, _actor} = Transmogrifier.handle_incoming(data) - assert %{success: 1, snoozed: 0, failure: 0} == Oban.drain_queue(queue: :background) + + assert %{success: 1, snoozed: 0, failure: 0, discard: 0} == + Oban.drain_queue(queue: :background) assert {:error, :actor_not_found} = Actors.get_actor_by_url(url) assert {:error, :event_not_found} = Events.get_event(event1.id) diff --git a/test/federation/activity_pub/transmogrifier/update_test.exs b/test/federation/activity_pub/transmogrifier/update_test.exs index d40c9cb55..a5724ff60 100644 --- a/test/federation/activity_pub/transmogrifier/update_test.exs +++ b/test/federation/activity_pub/transmogrifier/update_test.exs @@ -74,7 +74,7 @@ defmodule Mobilizon.Federation.ActivityPub.Transmogrifier.UpdateTest do args: %{event_id: event_id, op: :insert_search_event} ) - assert %{success: 1, snoozed: 0, failure: 0} == Oban.drain_queue(queue: :search) + assert %{success: 1, snoozed: 0, failure: 0, discard: 0} == Oban.drain_queue(queue: :search) update_data = File.read!("test/fixtures/mastodon-update.json") |> Jason.decode!() @@ -99,7 +99,7 @@ defmodule Mobilizon.Federation.ActivityPub.Transmogrifier.UpdateTest do args: %{event_id: event_id, op: :update_search_event} ) - assert %{success: 1, snoozed: 0, failure: 0} == Oban.drain_queue(queue: :search) + assert %{success: 1, snoozed: 0, failure: 0, discard: 0} == Oban.drain_queue(queue: :search) assert event.title == "My updated event" diff --git a/test/graphql/resolvers/activity_test.exs b/test/graphql/resolvers/activity_test.exs index d020d4723..3eff21afb 100644 --- a/test/graphql/resolvers/activity_test.exs +++ b/test/graphql/resolvers/activity_test.exs @@ -181,7 +181,10 @@ defmodule Mobilizon.GraphQL.Resolvers.ActivityTest do event = insert(:event, attributed_to: group, organizer_actor: actor) EventActivity.insert_activity(event, subject: "event_created") - assert %{success: 1, snoozed: 0, failure: 0} == Oban.drain_queue(queue: :activity) + + assert %{success: 1, snoozed: 0, failure: 0, discard: 0} == + Oban.drain_queue(queue: :activity) + assert Activities.list_activities() |> length() == 1 [%Activity{author_id: author_id, group_id: activity_group_id}] = @@ -230,7 +233,10 @@ defmodule Mobilizon.GraphQL.Resolvers.ActivityTest do post = insert(:post, author: actor, attributed_to: group) EventActivity.insert_activity(event, subject: "event_created") PostActivity.insert_activity(post, subject: "post_created") - assert %{success: 2, snoozed: 0, failure: 0} == Oban.drain_queue(queue: :activity) + + assert %{success: 2, snoozed: 0, failure: 0, discard: 0} == + Oban.drain_queue(queue: :activity) + assert Activities.list_activities() |> length() == 2 res = @@ -274,7 +280,10 @@ defmodule Mobilizon.GraphQL.Resolvers.ActivityTest do post = insert(:post, attributed_to: group) EventActivity.insert_activity(event, subject: "event_created") PostActivity.insert_activity(post, subject: "post_created") - assert %{success: 2, snoozed: 0, failure: 0} == Oban.drain_queue(queue: :activity) + + assert %{success: 2, snoozed: 0, failure: 0, discard: 0} == + Oban.drain_queue(queue: :activity) + assert Activities.list_activities() |> length() == 2 res = @@ -318,7 +327,10 @@ defmodule Mobilizon.GraphQL.Resolvers.ActivityTest do Process.sleep(1000) Posts.delete_post(post) PostActivity.insert_activity(post, subject: "post_deleted") - assert %{success: 2, snoozed: 0, failure: 0} == Oban.drain_queue(queue: :activity) + + assert %{success: 2, snoozed: 0, failure: 0, discard: 0} == + Oban.drain_queue(queue: :activity) + assert Activities.list_activities() |> length() == 2 res = diff --git a/test/graphql/resolvers/group_test.exs b/test/graphql/resolvers/group_test.exs index 4803fcc8b..6fa9944ba 100644 --- a/test/graphql/resolvers/group_test.exs +++ b/test/graphql/resolvers/group_test.exs @@ -385,7 +385,7 @@ defmodule Mobilizon.Web.Resolvers.GroupTest do # Can't be used right now, probably because we try to run a transaction in a Oban Job while using Ecto Sandbox - # assert %{success: 1, snoozed: 0, failure: 0} == Oban.drain_queue(queue: :background) + # assert %{success: 1, snoozed: 0, failure: 0, discard: 0} == Oban.drain_queue(queue: :background) # res = # conn diff --git a/test/graphql/resolvers/person_test.exs b/test/graphql/resolvers/person_test.exs index 7d2c272c8..173e45b1a 100644 --- a/test/graphql/resolvers/person_test.exs +++ b/test/graphql/resolvers/person_test.exs @@ -519,7 +519,8 @@ defmodule Mobilizon.GraphQL.Resolvers.PersonTest do } ) - assert %{success: 1, snoozed: 0, failure: 0} == Oban.drain_queue(queue: :background) + assert %{success: 1, snoozed: 0, failure: 0, discard: 0} == + Oban.drain_queue(queue: :background) query = """ { @@ -719,7 +720,8 @@ defmodule Mobilizon.GraphQL.Resolvers.PersonTest do assert is_nil(res["errors"]) assert res["data"]["suspendProfile"]["id"] == to_string(remote_profile_id) - assert %{success: 1, snoozed: 0, failure: 0} == Oban.drain_queue(queue: :background) + assert %{success: 1, snoozed: 0, failure: 0, discard: 0} == + Oban.drain_queue(queue: :background) res = conn diff --git a/test/graphql/resolvers/user_test.exs b/test/graphql/resolvers/user_test.exs index f9cf72dce..1510f56ba 100644 --- a/test/graphql/resolvers/user_test.exs +++ b/test/graphql/resolvers/user_test.exs @@ -1478,7 +1478,8 @@ defmodule Mobilizon.GraphQL.Resolvers.UserTest do assert is_nil(Users.get_user(user.id)) - assert %{success: 2, snoozed: 0, failure: 0} == Oban.drain_queue(queue: :background) + assert %{success: 2, snoozed: 0, failure: 0, discard: 0} == + Oban.drain_queue(queue: :background) assert_raise Ecto.NoResultsError, fn -> Events.get_event!(event_id) diff --git a/test/mobilizon/actors/actors_test.exs b/test/mobilizon/actors/actors_test.exs index c8bb2d2cb..423b5c758 100644 --- a/test/mobilizon/actors/actors_test.exs +++ b/test/mobilizon/actors/actors_test.exs @@ -349,7 +349,8 @@ defmodule Mobilizon.ActorsTest do } ) - assert %{success: 1, snoozed: 0, failure: 0} == Oban.drain_queue(queue: :background) + assert %{success: 1, snoozed: 0, failure: 0, discard: 0} == + Oban.drain_queue(queue: :background) assert %Actor{ name: nil,