Commit d8d3db7f authored by Matija Čupić's avatar Matija Čupić

Handle test_reports erroring out

parent 09813909
...@@ -9,6 +9,8 @@ class PipelineDetailsEntity < PipelineEntity ...@@ -9,6 +9,8 @@ class PipelineDetailsEntity < PipelineEntity
expose :artifacts, using: BuildArtifactEntity expose :artifacts, using: BuildArtifactEntity
expose :test_reports, using: TestReportEntity do |pipeline| expose :test_reports, using: TestReportEntity do |pipeline|
pipeline.test_reports.total_count.zero? ? nil : pipeline.test_reports pipeline.test_reports.total_count.zero? ? nil : pipeline.test_reports
rescue
nil
end end
expose :manual_actions, using: BuildActionEntity expose :manual_actions, using: BuildActionEntity
expose :scheduled_actions, using: BuildActionEntity expose :scheduled_actions, using: BuildActionEntity
......
...@@ -121,6 +121,23 @@ describe PipelineDetailsEntity do ...@@ -121,6 +121,23 @@ describe PipelineDetailsEntity do
expect(subject[:details]).to include(:test_reports) expect(subject[:details]).to include(:test_reports)
expect(subject[:details][:test_reports][:total_time]).to eq(pipeline.test_reports.total_time) expect(subject[:details][:test_reports][:total_time]).to eq(pipeline.test_reports.total_time)
end end
context 'when pipeline has corrupt test reports' do
before do
job = create(:ci_build, pipeline: pipeline)
create(:ci_job_artifact, :junit_with_corrupted_data, job: job)
end
it 'does not error out' do
expect { subject }.not_to raise_error
end
it 'shows an empty test_reports section' do
expect(subject).to include(:details)
expect(subject[:details]).to include(:test_reports)
expect(subject[:details][:test_reports]).to eq(nil)
end
end
end end
context 'when pipeline has YAML errors' do context 'when pipeline has YAML errors' do
......
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