Here is an example:
args = ["arg1", "arg2"]
unique_token = "my_unique_token"
Exq.enqueue(Exq, "queue", MyWorker, args, unique_token: unique_token, unique_for: 5)
Exq.enqueue(Exq, "queue", MyWorker, args, unique_token: unique_token, unique_for: 5)
Exq.enqueue(Exq, "queue", MyWorker, args, unique_token: unique_token, unique_for: 5)
Expected result: A single instance of the job is returned by Exq.Mock.jobs().
Actual result: Three instances of the job get returned by Exq.Mock.jobs().
Additionally, the returned jobs have their uniqueness attributes set to nil while it might be expected those would carry at least some of the supplied values:
[
%Exq.Support.Job{
error_message: nil,
error_class: nil,
retried_at: nil,
failed_at: nil,
retry: false,
retry_count: 0,
processor: nil,
queue: "queue",
class: MyWorker,
args: ["arg1", "arg2"],
jid: "7789467e-dc08-4af4-a006-6ad9e5113f21",
finished_at: nil,
enqueued_at: ~U[2024-07-08 11:31:22.577966Z],
unique_for: nil,
unique_until: nil,
unique_token: nil,
unlocks_at: nil
},
...
]
Exq config:
In config/config.exs:
config :exq,
name: Exq,
...
middleware: [Exq.Middleware.Stats, Exq.Middleware.Job, Exq.Middleware.Manager,
Exq.Middleware.Unique, Exq.Middleware.Logger]
In config/test.exs:
config :exq,
queue_adapter: Exq.Adapters.Queue.Mock,
start_on_application: false
In test_helper.exs:
Exq.Mock.start_link(mode: :fake)
Changing the Mock config to mode: :inline correctly enqueues just a single instance of worker.
Here is an example:
Expected result: A single instance of the job is returned by
Exq.Mock.jobs().Actual result: Three instances of the job get returned by
Exq.Mock.jobs().Additionally, the returned jobs have their uniqueness attributes set to
nilwhile it might be expected those would carry at least some of the supplied values:Exq config:
In
config/config.exs:In
config/test.exs:In
test_helper.exs:Changing the Mock config to
mode: :inlinecorrectly enqueues just a single instance of worker.