diff --git a/lib/oban/testing.ex b/lib/oban/testing.ex index 94f13bb9..9930409a 100644 --- a/lib/oban/testing.ex +++ b/lib/oban/testing.ex @@ -610,13 +610,12 @@ defmodule Oban.Testing do defp conditions({key, val}, query) when key in @timestamp_fields do {time, delta} = case val do - {time, delta: delta} -> - {time, delta} - - time -> - {time, 1} + {time, delta: delta} -> {time, delta} + time -> {time, 1} end + {:ok, time} = Ecto.Type.cast(:utc_datetime, time) + begin = DateTime.add(time, -delta, :second) until = DateTime.add(time, +delta, :second) diff --git a/test/oban/testing_test.exs b/test/oban/testing_test.exs index eeb3ee8f..625a9894 100644 --- a/test/oban/testing_test.exs +++ b/test/oban/testing_test.exs @@ -264,6 +264,7 @@ defmodule Oban.TestingTest do insert!(%{}, worker: Pong, scheduled_at: seconds_from_now(60)) assert_enqueued worker: Ping, state: "available", scheduled_at: DateTime.utc_now() + assert_enqueued worker: Ping, scheduled_at: DateTime.now!("America/Chicago") assert_enqueued worker: Pong, scheduled_at: seconds_from_now(60) assert_enqueued worker: Pong, scheduled_at: {seconds_from_now(69), delta: 10} end