Commit 884094a7 authored by Kamil Trzciński's avatar Kamil Trzciński

Merge branch 'ci/extend-summary-status-specs' into 'master'

Extend specs for summary build status

Additional specs cover a case when one of the builds is running but
allowed to fail. Previous implementation returned `running` status,
which is wrong. This behavior has been changed in 8.5, this commit adds
missing specs.

See merge request !2904
parents e6195b85 c8b4c874
...@@ -4,38 +4,68 @@ describe Ci::Status do ...@@ -4,38 +4,68 @@ describe Ci::Status do
describe '.get_status' do describe '.get_status' do
subject { described_class.get_status(statuses) } subject { described_class.get_status(statuses) }
[:ci_build, :generic_commit_status].each do |type| shared_examples 'build status summary' do
context "for #{type}" do context 'all successful' do
context 'all successful' do let(:statuses) { Array.new(2) { create(type, status: :success) } }
let(:statuses) { Array.new(2) { create(type, status: :success) } } it { is_expected.to eq 'success' }
it { is_expected.to eq 'success' } end
end
context 'at least one failed' do context 'at least one failed' do
let(:statuses) { [create(type, status: :success), create(type, status: :failed)] } let(:statuses) do
it { is_expected.to eq 'failed' } [create(type, status: :success), create(type, status: :failed)]
end end
context 'at least one running' do it { is_expected.to eq 'failed' }
let(:statuses) { [create(type, status: :success), create(type, status: :running)] } end
it { is_expected.to eq 'running' }
context 'at least one running' do
let(:statuses) do
[create(type, status: :success), create(type, status: :running)]
end end
context 'at least one pending' do it { is_expected.to eq 'running' }
let(:statuses) { [create(type, status: :success), create(type, status: :pending)] } end
it { is_expected.to eq 'running' }
context 'at least one pending' do
let(:statuses) do
[create(type, status: :success), create(type, status: :pending)]
end end
context 'success and failed but allowed to fail' do it { is_expected.to eq 'running' }
let(:statuses) { [create(type, status: :success), create(type, status: :failed, allow_failure: true)] } end
it { is_expected.to eq 'success' }
context 'success and failed but allowed to fail' do
let(:statuses) do
[create(type, status: :success),
create(type, status: :failed, allow_failure: true)]
end end
context 'one failed but allowed to fail' do it { is_expected.to eq 'success' }
let(:statuses) { [create(type, status: :failed, allow_failure: true)] } end
it { is_expected.to eq 'success' }
context 'one failed but allowed to fail' do
let(:statuses) { [create(type, status: :failed, allow_failure: true)] }
it { is_expected.to eq 'success' }
end
context 'one finished and second running but allowed to fail' do
let(:statuses) do
[create(type, status: :success),
create(type, status: :running, allow_failure: true)]
end end
it { is_expected.to eq 'running' }
end end
end end
context 'ci build statuses' do
let(:type) { :ci_build }
it_behaves_like 'build status summary'
end
context 'generic commit statuses' do
let(:type) { :generic_commit_status }
it_behaves_like 'build status summary'
end
end end
end end
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