Fix tests
This commit is contained in:
parent
6171db2d2d
commit
cd23850e00
2 changed files with 34 additions and 30 deletions
|
@ -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,24 +1902,38 @@ 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
|
||||
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_artifacts!
|
||||
pre_stage_job.erase
|
||||
end
|
||||
|
||||
it { expect { build.run! }.to raise_error(Ci::Build::MissingDependenciesError) }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'when depended jobs do not exist' do
|
||||
it { expect { build.run! }.to raise_error(Ci::Build::MissingDependenciesError) }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'state transition when build fails' do
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue