debian-mirror-gitlab/spec/services/ci/after_requeue_job_service_spec.rb

61 lines
2 KiB
Ruby
Raw Normal View History

2021-04-29 21:17:54 +05:30
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Ci::AfterRequeueJobService do
let_it_be(:project) { create(:project) }
let_it_be(:user) { project.owner }
let(:pipeline) { create(:ci_pipeline, project: project) }
2021-10-27 15:23:28 +05:30
let!(:build) { create(:ci_build, pipeline: pipeline, stage_idx: 0, name: 'build') }
2021-04-29 21:17:54 +05:30
let!(:test1) { create(:ci_build, :success, pipeline: pipeline, stage_idx: 1) }
let!(:test2) { create(:ci_build, :skipped, pipeline: pipeline, stage_idx: 1) }
2021-10-27 15:23:28 +05:30
let!(:test3) { create(:ci_build, :skipped, :dependent, pipeline: pipeline, stage_idx: 1, needed: build) }
let!(:deploy) { create(:ci_build, :skipped, :dependent, pipeline: pipeline, stage_idx: 2, needed: test3) }
2021-04-29 21:17:54 +05:30
subject(:execute_service) { described_class.new(project, user).execute(build) }
it 'marks subsequent skipped jobs as processable' do
expect(test1.reload).to be_success
expect(test2.reload).to be_skipped
2021-10-27 15:23:28 +05:30
expect(test3.reload).to be_skipped
expect(deploy.reload).to be_skipped
2021-04-29 21:17:54 +05:30
execute_service
expect(test1.reload).to be_success
expect(test2.reload).to be_created
2021-10-27 15:23:28 +05:30
expect(test3.reload).to be_created
expect(deploy.reload).to be_created
2021-04-29 21:17:54 +05:30
end
2021-09-30 23:02:18 +05:30
context 'when there is a job need from the same stage' do
2021-10-27 15:23:28 +05:30
let!(:test4) do
2021-09-30 23:02:18 +05:30
create(:ci_build,
:skipped,
2021-10-27 15:23:28 +05:30
:dependent,
2021-09-30 23:02:18 +05:30
pipeline: pipeline,
stage_idx: 0,
2021-10-27 15:23:28 +05:30
scheduling_type: :dag,
needed: build)
2021-09-30 23:02:18 +05:30
end
it 'marks subsequent skipped jobs as processable' do
2021-10-27 15:23:28 +05:30
expect { execute_service }.to change { test4.reload.status }.from('skipped').to('created')
2021-09-30 23:02:18 +05:30
end
end
2021-04-29 21:17:54 +05:30
context 'when the pipeline is a downstream pipeline and the bridge is depended' do
let!(:trigger_job) { create(:ci_bridge, :strategy_depend, status: 'success') }
before do
create(:ci_sources_pipeline, pipeline: pipeline, source_job: trigger_job)
end
it 'marks source bridge as pending' do
expect { execute_service }.to change { trigger_job.reload.status }.from('success').to('pending')
end
end
end