Commit 2ebba1ff authored by Kamil Trzciński's avatar Kamil Trzciński

Improve Ci::Status::Build specs

parent 8ce4bf20
......@@ -4,13 +4,13 @@ module Gitlab
module Build
class Failed < Status::Extended
REASONS = {
'unknown_failure' => 'unknown failure',
'script_failure' => 'script failure',
'api_failure' => 'API failure',
'stuck_or_timeout_failure' => 'stuck or timeout failure',
'runner_system_failure' => 'runner system failure',
'missing_dependency_failure' => 'missing dependency failure',
# COMMENTED to check if CI fails: 'runner_unsupported' => 'unsuported runner',
unknown_failure: 'unknown failure',
script_failure: 'script failure',
api_failure: 'API failure',
stuck_or_timeout_failure: 'stuck or timeout failure',
runner_system_failure: 'runner system failure',
missing_dependency_failure: 'missing dependency failure',
runner_unsupported: 'Your runner is outdated, please upgrade your runner'
}.freeze
def status_tooltip
......@@ -32,7 +32,11 @@ module Gitlab
end
def description
"<br> (#{REASONS[subject.failure_reason]})"
"<br> (#{failure_reason_message})"
end
def failure_reason_message
REASONS.fetch(subject.failure_reason.to_sym)
end
end
end
......
......@@ -80,4 +80,31 @@ describe Gitlab::Ci::Status::Build::Failed do
end
end
end
describe 'covers all failure reasons' do
let(:status) { Gitlab::Ci::Status::Failed.new(build, user) }
let(:tooltip) { subject.status_tooltip }
CommitStatus.failure_reasons.keys.each do |failure_reason|
context failure_reason do
before do
build.failure_reason = failure_reason
end
it "is a valid status" do
expect { tooltip }.not_to raise_error
end
end
end
context 'invalid failure message' do
before do
expect(build).to receive(:failure_reason) { 'invalid failure message' }
end
it "is an invalid status" do
expect { tooltip }.to raise_error(/key not found:/)
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