Commit cd23850e authored by Shinya Maeda's avatar Shinya Maeda

Fix tests

parent 6171db2d
...@@ -1891,11 +1891,7 @@ describe Ci::Build do ...@@ -1891,11 +1891,7 @@ describe Ci::Build do
let(:options) { { dependencies: ['test'] } } let(:options) { { dependencies: ['test'] } }
context 'when a depended job exists' do context 'when a depended job exists' do
let!(:pre_stage_job) { create(:ci_build, :success, pipeline: pipeline, name: 'test', stage_idx: 0) } context 'when depended job has artifacts' do
it { expect { build.run! }.not_to raise_error }
context 'when "artifacts" keyword is specified on depended job' do
let!(:pre_stage_job) do let!(:pre_stage_job) do
create(:ci_build, create(:ci_build,
:success, :success,
...@@ -1906,22 +1902,36 @@ describe Ci::Build do ...@@ -1906,22 +1902,36 @@ describe Ci::Build do
options: { artifacts: { paths: ['binaries/'] } } ) options: { artifacts: { paths: ['binaries/'] } } )
end end
context 'when artifacts of depended job has existsed' do it { expect { build.run! }.not_to raise_error }
it { expect { build.run! }.not_to raise_error } end
end
context 'when artifacts of depended job has not existsed' do context 'when depended job does not have artifacts' do
before do let!(:pre_stage_job) { create(:ci_build, :success, pipeline: pipeline, name: 'test', stage_idx: 0) }
pre_stage_job.erase_artifacts!
end
it { expect { build.run! }.to raise_error(Ci::Build::MissingDependenciesError) } it { expect { build.run! }.not_to raise_error }
end
end end
end
context 'when depended jobs do not exist' do context 'when depended job has not been completed yet' do
it { expect { build.run! }.to raise_error(Ci::Build::MissingDependenciesError) } 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
it { expect { build.run! }.to raise_error(Ci::Build::MissingDependenciesError) }
end
end end
end end
end end
......
...@@ -277,6 +277,10 @@ module Ci ...@@ -277,6 +277,10 @@ module Ci
end end
context 'when "dependencies" keyword is specified' do 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!(:pre_stage_job) { create(:ci_build, :success, pipeline: pipeline, name: job_name, stage_idx: 0) }
let!(:pending_job) do let!(:pending_job) do
...@@ -311,7 +315,7 @@ module Ci ...@@ -311,7 +315,7 @@ module Ci
context 'when artifacts of depended job has not existsed' do context 'when artifacts of depended job has not existsed' do
before do before do
pre_stage_job.erase_artifacts! pre_stage_job.erase
end end
it 'does not pick the build and drops the build' do it 'does not pick the build and drops the build' do
...@@ -322,16 +326,6 @@ module Ci ...@@ -322,16 +326,6 @@ module Ci
end end
end 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 end
def execute(runner) 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