Commit 7bb99c21 authored by Kamil Trzciński's avatar Kamil Trzciński

Add specs for unsupported runner

parent c944e22d
...@@ -22,6 +22,6 @@ class CommitStatusPresenter < Gitlab::View::Presenter::Delegated ...@@ -22,6 +22,6 @@ class CommitStatusPresenter < Gitlab::View::Presenter::Delegated
end end
def unrecoverable? def unrecoverable?
script_failure? || missing_dependency_failure? || runner_unsupported? script_failure? || missing_dependency_failure?
end end
end end
...@@ -2813,4 +2813,76 @@ describe Ci::Build do ...@@ -2813,4 +2813,76 @@ describe Ci::Build do
end end
end end
end end
describe '#publishes_artifacts_reports?' do
let(:build) { create(:ci_build, options: options) }
subject { build.publishes_artifacts_reports? }
context 'when artifacts reports are defined' do
let(:options) do
{ artifacts: { reports: { junit: "junit.xml" } } }
end
it { is_expected.to be_truthy }
end
context 'when artifacts reports missing defined' do
let(:options) do
{ artifacts: { paths: ["file.txt"] } }
end
it { is_expected.to be_falsey }
end
context 'when options are missing' do
let(:options) { nil }
it { is_expected.to be_falsey }
end
end
describe '#runner_required_feature_names' do
let(:build) { create(:ci_build, options: options) }
subject { build.runner_required_feature_names }
context 'when artifacts reports are defined' do
let(:options) do
{ artifacts: { reports: { junit: "junit.xml" } } }
end
it { is_expected.to include(:upload_multiple_artifacts) }
end
end
describe '#supported_runner?' do
set(:build) { create(:ci_build) }
subject { build.supported_runner?(runner_features) }
context 'when feature is required by build' do
before do
expect(build).to receive(:runner_required_feature_names) do
[:upload_multiple_artifacts]
end
end
context 'when runner provides given feature' do
let(:runner_features) do
{ upload_multiple_artifacts: true }
end
it { is_expected.to be_truthy }
end
context 'when runner does not provide given feature' do
let(:runner_features) do
{}
end
it { is_expected.to be_falsey }
end
end
end
end end
...@@ -231,7 +231,7 @@ describe Ci::BuildPresenter do ...@@ -231,7 +231,7 @@ describe Ci::BuildPresenter do
let(:build) { create(:ci_build, :failed, :script_failure) } let(:build) { create(:ci_build, :failed, :script_failure) }
context 'when is a script or missing dependency failure' do context 'when is a script or missing dependency failure' do
let(:failure_reasons) { %w(script_failure missing_dependency_failure runner_unsupported) } let(:failure_reasons) { %w(script_failure missing_dependency_failure) }
it 'should return false' do it 'should return false' do
failure_reasons.each do |failure_reason| failure_reasons.each do |failure_reason|
......
...@@ -351,6 +351,38 @@ module Ci ...@@ -351,6 +351,38 @@ module Ci
end end
end end
context 'runner feature set is verified' do
set(:pending_job) { create(:ci_build, :pending, pipeline: pipeline) }
before do
expect_any_instance_of(Ci::Build).to receive(:runner_required_feature_names) do
[:runner_required_feature]
end
end
subject { execute(specific_runner, params) }
context 'when feature is missing by runner' do
let(:params) { {} }
it 'does not pick the build and drops the build' do
expect(subject).to be_nil
expect(pending_job.reload).to be_failed
expect(pending_job).to be_runner_unsupported
end
end
context 'when feature is supported by runner' do
let(:params) do
{ info: { features: { runner_required_feature: true } } }
end
it 'does pick job' do
expect(subject).not_to be_nil
end
end
end
context 'when "dependencies" keyword is specified' do context 'when "dependencies" keyword is specified' do
shared_examples 'not pick' do shared_examples 'not pick' do
it 'does not pick the build and drops the build' do it 'does not pick the build and drops the build' do
...@@ -403,6 +435,7 @@ module Ci ...@@ -403,6 +435,7 @@ module Ci
it { expect(subject).to eq(pending_job) } it { expect(subject).to eq(pending_job) }
end end
context 'when artifacts of depended job has been expired' do 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) } let!(:pre_stage_job) { create(:ci_build, :success, :expired, pipeline: pipeline, name: 'test', stage_idx: 0) }
......
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