Skip to content

Commit d98acbc

Browse files
Fix flaky test
1 parent bd6d4f2 commit d98acbc

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

test/api_test.exs

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -155,15 +155,25 @@ defmodule ApiTest do
155155
assert {:ok, []} = Exq.Api.retries(Exq.Api)
156156
end
157157

158-
test "retry with data" do
159-
JobQueue.retry_job(:testredis, "test", %Job{jid: "1"}, 1, "this is an error")
160-
JobQueue.retry_job(:testredis, "test", %Job{jid: "2"}, 1, "this is an error")
161-
{:ok, jobs} = Exq.Api.retries(Exq.Api)
162-
assert Enum.count(jobs) == 2
163-
assert Enum.at(jobs, 0).jid == "1"
158+
defmodule ConstantBackoff do
159+
@behaviour Exq.Backoff.Behaviour
160+
161+
def offset(_job) do
162+
1
163+
end
164+
end
164165

165-
{:ok, [job]} = Exq.Api.retries(Exq.Api, size: 1, raw: true, offset: 1)
166-
assert Jason.decode!(job)["jid"] == "2"
166+
test "retry with data" do
167+
with_application_env(:exq, :backoff, ConstantBackoff, fn ->
168+
JobQueue.retry_job(:testredis, "test", %Job{jid: "1"}, 1, "this is an error")
169+
JobQueue.retry_job(:testredis, "test", %Job{jid: "2"}, 1, "this is an error")
170+
{:ok, jobs} = Exq.Api.retries(Exq.Api)
171+
assert Enum.count(jobs) == 2
172+
assert Enum.at(jobs, 0).jid == "1"
173+
174+
{:ok, [job]} = Exq.Api.retries(Exq.Api, size: 1, raw: true, offset: 1)
175+
assert Jason.decode!(job)["jid"] == "2"
176+
end)
167177
end
168178

169179
test "scheduled when empty" do

0 commit comments

Comments
 (0)