Update pattern matching for Oban.drain_queue following update

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel 2022-03-23 11:38:25 +01:00 committed by tykayn
parent 2d99fe877c
commit 379e97107f
7 changed files with 30 additions and 12 deletions

View File

@ -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)

View File

@ -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"

View File

@ -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 =

View File

@ -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

View File

@ -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

View File

@ -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)

View File

@ -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,