Commit 6789e4fc authored by Douglas Barbosa Alexandre's avatar Douglas Barbosa Alexandre 🌴

Add tests for Geo::GeoBackfillWorker

parent 6b5997eb
require 'spec_helper'
describe Geo::GeoBackfillWorker, services: true do
let!(:primary) { create(:geo_node, :primary, host: 'primary-geo-node') }
let!(:secondary) { create(:geo_node, :current) }
let!(:projects) { create_list(:empty_project, 2) }
subject { described_class.new }
describe '#perform' do
pending { raise 'must be implemented' }
it 'performs GeoSingleRepositoryBackfillWorker for each project' do
expect(GeoSingleRepositoryBackfillWorker).to receive(:new).exactly(2).and_call_original
subject.perform
end
it 'does not perform GeoSingleRepositoryBackfillWorker when node is disabled' do
allow(secondary).to receive(:enabled?) { false }
expect(GeoSingleRepositoryBackfillWorker).not_to receive(:new)
subject.perform
end
it 'does not perform GeoSingleRepositoryBackfillWorker for projects that repository exists' do
create_list(:project, 2)
expect(GeoSingleRepositoryBackfillWorker).to receive(:new).exactly(2).and_call_original
subject.perform
end
it 'does not perform GeoSingleRepositoryBackfillWorker when can not obtain a lease' do
allow_any_instance_of(Gitlab::ExclusiveLease).to receive(:try_obtain) { false }
expect(GeoSingleRepositoryBackfillWorker).not_to receive(:new)
subject.perform
end
end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment