Welcome to mirror list, hosted at ThFree Co, Russian Federation.

idempotent_worker_helper.rb « helpers « support « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: b80758d10bdbc51b343c5bc68891c046250c55be (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# 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