2019-08-22 06:57:44 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-11-28 11:16:50 -05:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-24 14:09:03 -04:00
|
|
|
RSpec.describe Gitlab::SidekiqVersioning, :redis do
|
2017-11-28 11:16:50 -05:00
|
|
|
let(:foo_worker) do
|
|
|
|
Class.new do
|
|
|
|
def self.name
|
|
|
|
'FooWorker'
|
|
|
|
end
|
|
|
|
|
|
|
|
include ApplicationWorker
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
let(:bar_worker) do
|
|
|
|
Class.new do
|
|
|
|
def self.name
|
|
|
|
'BarWorker'
|
|
|
|
end
|
|
|
|
|
|
|
|
include ApplicationWorker
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
before do
|
|
|
|
allow(Gitlab::SidekiqConfig).to receive(:workers).and_return([foo_worker, bar_worker])
|
|
|
|
allow(Gitlab::SidekiqConfig).to receive(:worker_queues).and_return([foo_worker.queue, bar_worker.queue])
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '.install!' do
|
|
|
|
it 'prepends SidekiqVersioning::Manager into Sidekiq::Manager' do
|
|
|
|
described_class.install!
|
|
|
|
|
|
|
|
expect(Sidekiq::Manager).to include(Gitlab::SidekiqVersioning::Manager)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'registers all versionless and versioned queues with Redis' do
|
|
|
|
described_class.install!
|
|
|
|
|
|
|
|
queues = Sidekiq::Queue.all.map(&:name)
|
|
|
|
expect(queues).to include('foo')
|
|
|
|
expect(queues).to include('bar')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|