Commit 5ff87dc8 authored by Gabriel Mazetto's avatar Gabriel Mazetto

Fix specs for Geo node's backfill feature

parent c0eef344
......@@ -91,30 +91,6 @@ describe GeoNode, type: :model do
expect(node.system_hook.push_events).to be_truthy
expect(node.system_hook.tag_push_events).to be_truthy
end
context 'backfill mechanism for a secondary node' do
before do
Sidekiq::Worker.clear_all
end
it 'schedules the scheduler worker' do
Sidekiq::Testing.fake! do
expect{ create(:geo_node, primary: false) }.to change(GeoScheduleBackfillWorker.jobs, :size).by(1)
end
end
it 'schedules the correct worker for the number of projects' do
Sidekiq::Testing.fake! do
2.times do
create(:project)
end
create(:geo_node, primary: false)
expect{ GeoScheduleBackfillWorker.drain }.to change(GeoBackfillWorker.jobs, :size).by(2)
end
end
end
end
end
......@@ -249,4 +225,28 @@ describe GeoNode, type: :model do
expect(node).to be_missing_oauth_application
end
end
describe '#backfill_repositories' do
before do
Sidekiq::Worker.clear_all
end
it 'schedules the scheduler worker' do
Sidekiq::Testing.fake! do
expect { node.backfill_repositories }.to change(GeoScheduleBackfillWorker.jobs, :size).by(1)
end
end
it 'schedules the correct worker for the number of projects' do
Sidekiq::Testing.fake! do
2.times do
create(:project)
end
node.backfill_repositories
expect { GeoScheduleBackfillWorker.drain }.to change(GeoBackfillWorker.jobs, :size).by(2)
end
end
end
end
require 'spec_helper'
describe Geo::RepositoryBackfillService, services: true do
subject { Geo::RepositoryBackfillService.new(project, geo_node) }
SYSTEM_HOOKS_HEADER = { 'Content-Type' => 'application/json', 'X-Gitlab-Event' => 'System Hook' }
let(:project) { create(:project) }
let(:geo_node) { create(:geo_node) }
subject { Geo::RepositoryBackfillService.new(project, geo_node) }
describe '#execute' do
it 'calls upon the system hook of the Geo Node' do
WebMock.stub_request(:post, geo_node.geo_events_url)
......@@ -12,7 +15,7 @@ describe Geo::RepositoryBackfillService, services: true do
subject.execute
expect(WebMock).to have_requested(:post, geo_node.geo_events_url).with(
headers: { 'Content-Type' => 'application/json', 'X-Gitlab-Event' => 'System Hook' },
headers: SYSTEM_HOOKS_HEADER,
body: {
event_name: 'push',
project_id: project.id,
......
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