Skip to content

Commit

Permalink
Assert on insert notifications in stager test
Browse files Browse the repository at this point in the history
  • Loading branch information
sorentwo committed Feb 12, 2024
1 parent 02541e8 commit 335fc37
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions test/oban/stager_test.exs
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
defmodule Oban.StagerTest do
use Oban.Case, async: true

alias Oban.Stager
alias Oban.{Notifier, Stager}
alias Oban.TelemetryHandler

describe "integration" do
test "executing jobs from an insert notification" do
name =
start_supervised_oban!(
queues: [alpha: 1, gamma: 1],
stage_interval: 10_000,
testing: :disabled
)
name = start_supervised_oban!(stage_interval: 10_000, testing: :disabled)

Notifier.listen(name, :insert)

Oban.insert(name, Worker.new(%{action: "OK", ref: 0}, queue: :alpha))
Oban.insert_all(name, [Worker.new(%{action: "OK", ref: 1}, queue: :gamma)])

assert_receive {:ok, 0}
assert_receive {:ok, 1}
Oban.insert_all(name, [
Worker.new(%{action: "OK", ref: 1}, queue: :gamma),
Worker.new(%{action: "OK", ref: 2}, queue: :delta)
])

assert_receive {:notification, :insert, %{"queue" => "alpha"}}
assert_receive {:notification, :insert, %{"queue" => "gamma"}}
assert_receive {:notification, :insert, %{"queue" => "delta"}}
end

test "descheduling jobs to make them available for execution" do
Expand Down

0 comments on commit 335fc37

Please sign in to comment.