2019-12-04 20:38:33 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2022-01-26 12:08:38 +05:30
|
|
|
require 'fast_spec_helper'
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2020-07-28 23:09:34 +05:30
|
|
|
RSpec.describe Gitlab::SidekiqStatus::ClientMiddleware do
|
2017-08-17 22:00:37 +05:30
|
|
|
describe '#call' do
|
2022-01-26 12:08:38 +05:30
|
|
|
context 'when the job has status_expiration set' do
|
|
|
|
it 'tracks the job in Redis with a value of 2' do
|
|
|
|
expect(Gitlab::SidekiqStatus).to receive(:set).with('123', 1.hour.to_i, value: 2)
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2022-01-26 12:08:38 +05:30
|
|
|
described_class.new
|
|
|
|
.call('Foo', { 'jid' => '123', 'status_expiration' => 1.hour.to_i }, double(:queue), double(:pool)) { nil }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when the job does not have status_expiration set' do
|
|
|
|
it 'tracks the job in Redis with a value of 1' do
|
|
|
|
expect(Gitlab::SidekiqStatus).to receive(:set).with('123', Gitlab::SidekiqStatus::DEFAULT_EXPIRATION, value: 1)
|
|
|
|
|
|
|
|
described_class.new
|
|
|
|
.call('Foo', { 'jid' => '123' }, double(:queue), double(:pool)) { nil }
|
|
|
|
end
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|