Commit cd23850e authored by Shinya Maeda's avatar Shinya Maeda

Fix tests

parent 6171db2d
......@@ -1891,11 +1891,7 @@ describe Ci::Build do
let(:options) { { dependencies: ['test'] } }
context 'when a depended job exists' do
let!(:pre_stage_job) { create(:ci_build, :success, pipeline: pipeline, name: 'test', stage_idx: 0) }
it { expect { build.run! }.not_to raise_error }
context 'when "artifacts" keyword is specified on depended job' do
context 'when depended job has artifacts' do
let!(:pre_stage_job) do
create(:ci_build,
:success,
......@@ -1906,25 +1902,39 @@ describe Ci::Build do
options: { artifacts: { paths: ['binaries/'] } } )
end
context 'when artifacts of depended job has existsed' do
it { expect { build.run! }.not_to raise_error }
end
context 'when artifacts of depended job has not existsed' do
before do
pre_stage_job.erase_artifacts!
context 'when depended job does not have artifacts' do
let!(:pre_stage_job) { create(:ci_build, :success, pipeline: pipeline, name: 'test', stage_idx: 0) }
it { expect { build.run! }.not_to raise_error }
end
context 'when depended job has not been completed yet' do
let!(:pre_stage_job) { create(:ci_build, :running, pipeline: pipeline, name: 'test', stage_idx: 0) }
it { expect { build.run! }.to raise_error(Ci::Build::MissingDependenciesError) }
end
context 'when artifacts of depended job has been expired' do
let!(:pre_stage_job) { create(:ci_build, :success, :expired, pipeline: pipeline, name: 'test', stage_idx: 0) }
it { expect { build.run! }.to raise_error(Ci::Build::MissingDependenciesError) }
end
context 'when artifacts of depended job has been erased' do
let!(:pre_stage_job) { create(:ci_build, :success, pipeline: pipeline, name: 'test', stage_idx: 0, erased_at: 1.minute.ago) }
before do
pre_stage_job.erase
end
context 'when depended jobs do not exist' do
it { expect { build.run! }.to raise_error(Ci::Build::MissingDependenciesError) }
end
end
end
end
describe 'state transition when build fails' do
let(:service) { MergeRequests::AddTodoWhenBuildFailsService.new(project, user) }
......
......@@ -277,6 +277,10 @@ module Ci
end
context 'when "dependencies" keyword is specified' do
before do
stub_feature_flags(ci_validates_dependencies: true)
end
let!(:pre_stage_job) { create(:ci_build, :success, pipeline: pipeline, name: job_name, stage_idx: 0) }
let!(:pending_job) do
......@@ -311,7 +315,7 @@ module Ci
context 'when artifacts of depended job has not existsed' do
before do
pre_stage_job.erase_artifacts!
pre_stage_job.erase
end
it 'does not pick the build and drops the build' do
......@@ -322,16 +326,6 @@ module Ci
end
end
end
context 'when depended jobs do not exist' do
let(:job_name) { 'robocop' }
it 'does not pick the build and drops the build' do
expect(picked_job).to be_nil
expect(pending_job.reload).to be_failed
expect(pending_job).to be_missing_dependency_failure
end
end
end
def execute(runner)
......
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