debian-mirror-gitlab/spec/support/helpers/idempotent_worker_helper.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

16 lines
419 B
Ruby
Raw Permalink Normal View History

2020-04-08 14:13:33 +05:30
# frozen_string_literal: true
module IdempotentWorkerHelper
WORKER_EXEC_TIMES = 2
def perform_multiple(args = [], worker: described_class.new, exec_times: WORKER_EXEC_TIMES)
Sidekiq::Testing.inline! do
job_args = args.nil? ? [nil] : Array.wrap(args)
expect(worker).to receive(:perform).exactly(exec_times).and_call_original
exec_times.times { worker.perform(*job_args) }
end
end
end