2017-01-20 08:32:32 -05:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2017-07-10 10:24:02 -04:00
|
|
|
describe Ci::UpdateBuildQueueService do
|
2017-03-27 17:14:01 -04:00
|
|
|
let(:project) { create(:project, :repository) }
|
2017-01-20 08:32:32 -05:00
|
|
|
let(:build) { create(:ci_build, pipeline: pipeline) }
|
|
|
|
let(:pipeline) { create(:ci_pipeline, project: project) }
|
|
|
|
|
|
|
|
context 'when updating specific runners' do
|
|
|
|
let(:runner) { create(:ci_runner) }
|
|
|
|
|
|
|
|
context 'when there are runner that can pick build' do
|
2017-06-14 14:18:56 -04:00
|
|
|
before do
|
|
|
|
build.project.runners << runner
|
|
|
|
end
|
2017-01-20 08:32:32 -05:00
|
|
|
|
|
|
|
it 'ticks runner queue value' do
|
|
|
|
expect { subject.execute(build) }
|
|
|
|
.to change { runner.ensure_runner_queue_value }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when there are no runners that can pick build' do
|
|
|
|
it 'does not tick runner queue value' do
|
|
|
|
expect { subject.execute(build) }
|
|
|
|
.not_to change { runner.ensure_runner_queue_value }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when updating shared runners' do
|
|
|
|
let(:runner) { create(:ci_runner, :shared) }
|
|
|
|
|
|
|
|
context 'when there are runner that can pick build' do
|
|
|
|
it 'ticks runner queue value' do
|
|
|
|
expect { subject.execute(build) }
|
|
|
|
.to change { runner.ensure_runner_queue_value }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when there are no runners that can pick build' do
|
2017-06-14 14:18:56 -04:00
|
|
|
before do
|
|
|
|
build.tag_list = [:docker]
|
|
|
|
end
|
2017-01-20 08:32:32 -05:00
|
|
|
|
|
|
|
it 'does not tick runner queue value' do
|
|
|
|
expect { subject.execute(build) }
|
|
|
|
.not_to change { runner.ensure_runner_queue_value }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|