diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-02 09:07:52 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-02 09:07:52 +0300 |
commit | ba836d98593d68d8d6c22c540e31c8031a786bd8 (patch) | |
tree | 09e500506edc566b08ea006ce41aa411990b9236 /spec/lib/gitlab/ci | |
parent | 796b00a98a82fcbe082c9343fd4efcccc77478dc (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib/gitlab/ci')
-rw-r--r-- | spec/lib/gitlab/ci/reports/test_reports_spec.rb | 32 | ||||
-rw-r--r-- | spec/lib/gitlab/ci/reports/test_suite_spec.rb | 29 |
2 files changed, 61 insertions, 0 deletions
diff --git a/spec/lib/gitlab/ci/reports/test_reports_spec.rb b/spec/lib/gitlab/ci/reports/test_reports_spec.rb index 0b5d05bada3..638acde69eb 100644 --- a/spec/lib/gitlab/ci/reports/test_reports_spec.rb +++ b/spec/lib/gitlab/ci/reports/test_reports_spec.rb @@ -109,6 +109,38 @@ describe Gitlab::Ci::Reports::TestReports do end end + describe '#with_attachment' do + let(:test_case) { build(:test_case, :failed) } + + subject { test_reports.with_attachment! } + + context 'when test suites do not contain an attachment' do + before do + test_reports.get_suite('rspec').add_test_case(create_test_case_rspec_success) + test_reports.get_suite('junit').add_test_case(test_case) + end + + it 'returns empty test suites' do + expect(subject.test_suites).to be_empty + end + end + + context 'when test suites contain an attachment' do + let(:test_case_succes) { build(:test_case) } + let(:test_case_with_attachment) { build(:test_case, :with_attachment) } + + before do + test_reports.get_suite('rspec').add_test_case(test_case_succes) + test_reports.get_suite('junit').add_test_case(test_case_with_attachment) + end + + it 'returns test suites with attachment' do + expect(subject.test_suites.count).to eq(1) + expect(subject.test_suites['junit'].test_cases['failed']).to be_present + end + end + end + Gitlab::Ci::Reports::TestCase::STATUS_TYPES.each do |status_type| describe "##{status_type}_count" do subject { test_reports.public_send("#{status_type}_count") } diff --git a/spec/lib/gitlab/ci/reports/test_suite_spec.rb b/spec/lib/gitlab/ci/reports/test_suite_spec.rb index 217713fd899..9d9774afc82 100644 --- a/spec/lib/gitlab/ci/reports/test_suite_spec.rb +++ b/spec/lib/gitlab/ci/reports/test_suite_spec.rb @@ -85,6 +85,35 @@ describe Gitlab::Ci::Reports::TestSuite do end end + describe '#with_attachment' do + subject { test_suite.with_attachment! } + + context 'when test cases do not contain an attachment' do + let(:test_case) { build(:test_case, :failed)} + + before do + test_suite.add_test_case(test_case) + end + + it 'returns an empty hash' do + expect(subject).to be_empty + end + end + + context 'when test cases contain an attachment' do + let(:test_case_with_attachment) { build(:test_case, :with_attachment)} + + before do + test_suite.add_test_case(test_case_with_attachment) + end + + it 'returns failed test cases with attachment' do + expect(subject.count).to eq(1) + expect(subject['failed']).to be_present + end + end + end + Gitlab::Ci::Reports::TestCase::STATUS_TYPES.each do |status_type| describe "##{status_type}" do subject { test_suite.public_send("#{status_type}") } |