Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShinya Maeda <shinya@gitlab.com>2018-08-03 14:08:13 +0300
committerShinya Maeda <shinya@gitlab.com>2018-08-03 14:08:13 +0300
commit41f28a9ffabf4eb45c53836ea4de3b7a49229eaa (patch)
tree174d41cf6bb28ccc3c88727618886a431364a63c /spec/services/ci/compare_test_reports_service_spec.rb
parent06b8f47cf3b8ce65012fe905f6d3953ff175fa85 (diff)
Add factory for parsers. Add required specification in json schema matcher. Improved test code.
Diffstat (limited to 'spec/services/ci/compare_test_reports_service_spec.rb')
-rw-r--r--spec/services/ci/compare_test_reports_service_spec.rb44
1 files changed, 17 insertions, 27 deletions
diff --git a/spec/services/ci/compare_test_reports_service_spec.rb b/spec/services/ci/compare_test_reports_service_spec.rb
index 6278774f446..d3bbf17cc5c 100644
--- a/spec/services/ci/compare_test_reports_service_spec.rb
+++ b/spec/services/ci/compare_test_reports_service_spec.rb
@@ -3,37 +3,23 @@ require 'spec_helper'
describe Ci::CompareTestReportsService do
let(:service) { described_class.new(project) }
let(:project) { create(:project, :repository) }
- let(:merge_request) { create(:merge_request, source_project: project) }
describe '#execute' do
- subject { service.execute(base_pipeline.iid, head_pipeline.iid) }
-
- let!(:base_pipeline) do
- create(:ci_pipeline,
- :success,
- project: merge_request.source_project,
- ref: merge_request.source_branch,
- sha: merge_request.diff_base_sha).tap do |pipeline|
- merge_request.update!(head_pipeline_id: pipeline.id)
- create(:ci_build, name: 'rspec', pipeline: pipeline, project: project)
- end
- end
+ 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) }
- let!(:head_pipeline) do
- create(:ci_pipeline,
- :success,
- project: merge_request.source_project,
- ref: merge_request.source_branch,
- sha: merge_request.diff_head_sha).tap do |pipeline|
- merge_request.update!(head_pipeline_id: pipeline.id)
- create(:ci_build, name: 'rspec', pipeline: pipeline, 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 test reports' do
- before do
- create(:ci_job_artifact, :junit, job: head_pipeline.builds.first, project: project)
- 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)
@@ -42,13 +28,17 @@ describe Ci::CompareTestReportsService do
end
context 'when head pipeline has corrupted test reports' do
+ let!(:base_pipeline) { nil }
+ let!(:head_pipeline) { create(:ci_pipeline, project: project) }
+
before do
- create(:ci_job_artifact, :junit_with_corrupted_data, job: head_pipeline.builds.first, project: project)
+ 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 eq('Failed to parse XML')
+ expect(subject[:status_reason]).to include('XML parsing failed')
end
end
end