From 335fc37430a2846a97c88f78710d9be7490259c1 Mon Sep 17 00:00:00 2001 From: Parker Selbert Date: Mon, 12 Feb 2024 10:17:02 -0600 Subject: [PATCH] Assert on insert notifications in stager test --- test/oban/stager_test.exs | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/test/oban/stager_test.exs b/test/oban/stager_test.exs index 0d545aae..aa5398ff 100644 --- a/test/oban/stager_test.exs +++ b/test/oban/stager_test.exs @@ -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