2019-07-07 11:18:12 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-04-08 14:13:33 +05:30
|
|
|
describe Gitlab::NotifyUponDeath do
|
2018-03-17 18:26:18 +05:30
|
|
|
let(:worker_class) do
|
|
|
|
Class.new do
|
|
|
|
include Sidekiq::Worker
|
2020-04-08 14:13:33 +05:30
|
|
|
include Gitlab::NotifyUponDeath
|
2018-03-17 18:26:18 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '.sidekiq_retries_exhausted' do
|
|
|
|
it 'notifies the JobWaiter when 3 arguments are given and the last is a String' do
|
|
|
|
job = { 'args' => [12, {}, '123abc'], 'jid' => '123' }
|
|
|
|
|
|
|
|
expect(Gitlab::JobWaiter)
|
|
|
|
.to receive(:notify)
|
|
|
|
.with('123abc', '123')
|
|
|
|
|
|
|
|
worker_class.sidekiq_retries_exhausted_block.call(job)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not notify the JobWaiter when only 2 arguments are given' do
|
|
|
|
job = { 'args' => [12, {}], 'jid' => '123' }
|
|
|
|
|
|
|
|
expect(Gitlab::JobWaiter)
|
|
|
|
.not_to receive(:notify)
|
|
|
|
|
|
|
|
worker_class.sidekiq_retries_exhausted_block.call(job)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not notify the JobWaiter when only 1 argument is given' do
|
|
|
|
job = { 'args' => [12], 'jid' => '123' }
|
|
|
|
|
|
|
|
expect(Gitlab::JobWaiter)
|
|
|
|
.not_to receive(:notify)
|
|
|
|
|
|
|
|
worker_class.sidekiq_retries_exhausted_block.call(job)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not notify the JobWaiter when the last argument is not a String' do
|
|
|
|
job = { 'args' => [12, {}, 40], 'jid' => '123' }
|
|
|
|
|
|
|
|
expect(Gitlab::JobWaiter)
|
|
|
|
.not_to receive(:notify)
|
|
|
|
|
|
|
|
worker_class.sidekiq_retries_exhausted_block.call(job)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|