diff options
author | Kamil Trzciński <ayufan@ayufan.eu> | 2018-08-03 21:39:48 +0300 |
---|---|---|
committer | Kamil Trzciński <ayufan@ayufan.eu> | 2018-08-03 21:39:48 +0300 |
commit | 99c033f2888a96267aa0443ad7a07f1f0e861992 (patch) | |
tree | a1d7bb68dfaba668987705538bfa4526c473010d /spec/services | |
parent | 53ecd2e147eb24f7e53385cb21f0c9759a482d6c (diff) | |
parent | fafd1764ca71156d261a604d64b43d531667cb17 (diff) |
Merge branch 'artifact-format-v2-with-parser' into 'master'
Parse junit.xml.gz and calculate the difference between head and base
See merge request gitlab-org/gitlab-ce!20576
Diffstat (limited to 'spec/services')
-rw-r--r-- | spec/services/ci/compare_test_reports_service_spec.rb | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/spec/services/ci/compare_test_reports_service_spec.rb b/spec/services/ci/compare_test_reports_service_spec.rb new file mode 100644 index 00000000000..d3bbf17cc5c --- /dev/null +++ b/spec/services/ci/compare_test_reports_service_spec.rb @@ -0,0 +1,45 @@ +require 'spec_helper' + +describe Ci::CompareTestReportsService do + let(:service) { described_class.new(project) } + let(:project) { create(:project, :repository) } + + describe '#execute' do + subject { service.execute(base_pipeline&.iid, head_pipeline.iid) } + + context 'when head pipeline has test reports' do + let!(:base_pipeline) { nil } + let!(:head_pipeline) { create(:ci_pipeline, :with_test_reports, project: project) } + + it 'returns status and data' do + expect(subject[:status]).to eq(:parsed) + expect(subject[:data]).to match_schema('entities/test_reports_comparer') + end + end + + context 'when base and head pipelines have test reports' do + let!(:base_pipeline) { create(:ci_pipeline, :with_test_reports, project: project) } + let!(:head_pipeline) { create(:ci_pipeline, :with_test_reports, project: project) } + + it 'returns status and data' do + expect(subject[:status]).to eq(:parsed) + expect(subject[:data]).to match_schema('entities/test_reports_comparer') + end + end + + context 'when head pipeline has corrupted test reports' do + let!(:base_pipeline) { nil } + let!(:head_pipeline) { create(:ci_pipeline, project: project) } + + before do + build = create(:ci_build, pipeline: head_pipeline, project: head_pipeline.project) + create(:ci_job_artifact, :junit_with_corrupted_data, job: build, project: project) + end + + it 'returns status and error message' do + expect(subject[:status]).to eq(:error) + expect(subject[:status_reason]).to include('XML parsing failed') + end + end + end +end |