diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-17 15:09:20 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-17 15:09:20 +0300 |
commit | b84eeb256c4a780d902faee1f99ca9a711b3214a (patch) | |
tree | 32918aadbea9210eace50efbce9afbfb8cd3ba84 /spec/lib/gitlab/ci | |
parent | 53ae6b7e3f83591ad251a3f771f5bf3b8cf087ba (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib/gitlab/ci')
-rw-r--r-- | spec/lib/gitlab/ci/parsers/test/junit_spec.rb | 2 | ||||
-rw-r--r-- | spec/lib/gitlab/ci/reports/test_reports_comparer_spec.rb | 52 | ||||
-rw-r--r-- | spec/lib/gitlab/ci/reports/test_suite_comparer_spec.rb | 140 | ||||
-rw-r--r-- | spec/lib/gitlab/ci/reports/test_suite_spec.rb | 9 |
4 files changed, 198 insertions, 5 deletions
diff --git a/spec/lib/gitlab/ci/parsers/test/junit_spec.rb b/spec/lib/gitlab/ci/parsers/test/junit_spec.rb index 6a7fe7a5927..b91cf1dd3ed 100644 --- a/spec/lib/gitlab/ci/parsers/test/junit_spec.rb +++ b/spec/lib/gitlab/ci/parsers/test/junit_spec.rb @@ -99,7 +99,7 @@ describe Gitlab::Ci::Parsers::Test::Junit do let(:testcase_content) { '<error>Some error</error>' } it_behaves_like '<testcase> XML parser', - ::Gitlab::Ci::Reports::TestCase::STATUS_FAILED, + ::Gitlab::Ci::Reports::TestCase::STATUS_ERROR, 'Some error' end diff --git a/spec/lib/gitlab/ci/reports/test_reports_comparer_spec.rb b/spec/lib/gitlab/ci/reports/test_reports_comparer_spec.rb index 48eef0643b2..d731afe1fff 100644 --- a/spec/lib/gitlab/ci/reports/test_reports_comparer_spec.rb +++ b/spec/lib/gitlab/ci/reports/test_reports_comparer_spec.rb @@ -57,6 +57,17 @@ describe Gitlab::Ci::Reports::TestReportsComparer do is_expected.to eq(Gitlab::Ci::Reports::TestCase::STATUS_FAILED) end end + + context 'when there is an error test case in head suites' do + before do + head_reports.get_suite('rspec').add_test_case(create_test_case_rspec_success) + head_reports.get_suite('junit').add_test_case(create_test_case_java_error) + end + + it 'returns the total status in head suite' do + is_expected.to eq(Gitlab::Ci::Reports::TestCase::STATUS_FAILED) + end + end end describe '#total_count' do @@ -75,7 +86,7 @@ describe Gitlab::Ci::Reports::TestReportsComparer do describe '#resolved_count' do subject { comparer.resolved_count } - context 'when there is a resolved test case in head suites' do + context 'when there is a resolved failure test case in head suites' do before do base_reports.get_suite('rspec').add_test_case(create_test_case_rspec_success) base_reports.get_suite('junit').add_test_case(create_test_case_java_failed) @@ -88,6 +99,19 @@ describe Gitlab::Ci::Reports::TestReportsComparer do end end + context 'when there is a resolved error test case in head suites' do + before do + base_reports.get_suite('rspec').add_test_case(create_test_case_rspec_success) + base_reports.get_suite('junit').add_test_case(create_test_case_java_error) + head_reports.get_suite('rspec').add_test_case(create_test_case_rspec_success) + head_reports.get_suite('junit').add_test_case(create_test_case_java_success) + end + + it 'returns the correct count' do + is_expected.to eq(1) + end + end + context 'when there are no resolved test cases in head suites' do before do base_reports.get_suite('rspec').add_test_case(create_test_case_rspec_success) @@ -127,4 +151,30 @@ describe Gitlab::Ci::Reports::TestReportsComparer do end end end + + describe '#error_count' do + subject { comparer.error_count } + + context 'when there is an error test case in head suites' do + before do + head_reports.get_suite('rspec').add_test_case(create_test_case_rspec_success) + head_reports.get_suite('junit').add_test_case(create_test_case_java_error) + end + + it 'returns the correct count' do + is_expected.to eq(1) + end + end + + context 'when there are no error test cases in head suites' do + before do + head_reports.get_suite('rspec').add_test_case(create_test_case_rspec_success) + head_reports.get_suite('junit').add_test_case(create_test_case_rspec_success) + end + + it 'returns the correct count' do + is_expected.to eq(0) + end + end + end end diff --git a/spec/lib/gitlab/ci/reports/test_suite_comparer_spec.rb b/spec/lib/gitlab/ci/reports/test_suite_comparer_spec.rb index cf4690bb334..2d2179a690b 100644 --- a/spec/lib/gitlab/ci/reports/test_suite_comparer_spec.rb +++ b/spec/lib/gitlab/ci/reports/test_suite_comparer_spec.rb @@ -9,8 +9,9 @@ describe Gitlab::Ci::Reports::TestSuiteComparer do let(:name) { 'rpsec' } let(:base_suite) { Gitlab::Ci::Reports::TestSuite.new(name) } let(:head_suite) { Gitlab::Ci::Reports::TestSuite.new(name) } - let(:test_case_success) { create_test_case_rspec_success } - let(:test_case_failed) { create_test_case_rspec_failed } + let(:test_case_success) { create_test_case_java_success } + let(:test_case_failed) { create_test_case_java_failed } + let(:test_case_error) { create_test_case_java_error } describe '#new_failures' do subject { comparer.new_failures } @@ -135,6 +136,129 @@ describe Gitlab::Ci::Reports::TestSuiteComparer do end end + describe '#new_errors' do + subject { comparer.new_errors } + + context 'when head suite has a new error test case which does not exist in base' do + before do + base_suite.add_test_case(test_case_success) + head_suite.add_test_case(test_case_error) + end + + it 'returns the error test case' do + is_expected.to eq([test_case_error]) + end + end + + context 'when head suite still has an error test case which errored in base' do + before do + base_suite.add_test_case(test_case_error) + head_suite.add_test_case(test_case_error) + end + + it 'does not return the error test case' do + is_expected.to be_empty + end + end + + context 'when head suite has a success test case which errored in base' do + before do + base_suite.add_test_case(test_case_error) + head_suite.add_test_case(test_case_success) + end + + it 'does not return the error test case' do + is_expected.to be_empty + end + end + end + + describe '#existing_errors' do + subject { comparer.existing_errors } + + context 'when head suite has a new error test case which does not exist in base' do + before do + base_suite.add_test_case(test_case_success) + head_suite.add_test_case(test_case_error) + end + + it 'does not return the error test case' do + is_expected.to be_empty + end + end + + context 'when head suite still has an error test case which errored in base' do + before do + base_suite.add_test_case(test_case_error) + head_suite.add_test_case(test_case_error) + end + + it 'returns the error test case' do + is_expected.to eq([test_case_error]) + end + end + + context 'when head suite has a success test case which errored in base' do + before do + base_suite.add_test_case(test_case_error) + head_suite.add_test_case(test_case_success) + end + + it 'does not return the error test case' do + is_expected.to be_empty + end + end + end + + describe '#resolved_errors' do + subject { comparer.resolved_errors } + + context 'when head suite has a new error test case which does not exist in base' do + before do + base_suite.add_test_case(test_case_success) + head_suite.add_test_case(test_case_error) + end + + it 'does not return the error test case' do + is_expected.to be_empty + end + + it 'returns the correct resolved count' do + expect(comparer.resolved_count).to eq(0) + end + end + + context 'when head suite still has an error test case which errored in base' do + before do + base_suite.add_test_case(test_case_error) + head_suite.add_test_case(test_case_error) + end + + it 'does not return the error test case' do + is_expected.to be_empty + end + + it 'returns the correct resolved count' do + expect(comparer.resolved_count).to eq(0) + end + end + + context 'when head suite has a success test case which errored in base' do + before do + base_suite.add_test_case(test_case_error) + head_suite.add_test_case(test_case_success) + end + + it 'returns the resolved test case' do + is_expected.to eq([test_case_success]) + end + + it 'returns the correct resolved count' do + expect(comparer.resolved_count).to eq(1) + end + end + end + describe '#total_count' do subject { comparer.total_count } @@ -208,7 +332,17 @@ describe Gitlab::Ci::Reports::TestSuiteComparer do head_suite.add_test_case(test_case_failed) end - it 'returns the total status in head suite' do + it 'returns the total status in head suite as failed' do + is_expected.to eq(Gitlab::Ci::Reports::TestCase::STATUS_FAILED) + end + end + + context 'when there is an error test case in head suite' do + before do + head_suite.add_test_case(test_case_error) + end + + it 'returns the total status in head suite as failed' do is_expected.to eq(Gitlab::Ci::Reports::TestCase::STATUS_FAILED) end end diff --git a/spec/lib/gitlab/ci/reports/test_suite_spec.rb b/spec/lib/gitlab/ci/reports/test_suite_spec.rb index 8646db43bc8..217713fd899 100644 --- a/spec/lib/gitlab/ci/reports/test_suite_spec.rb +++ b/spec/lib/gitlab/ci/reports/test_suite_spec.rb @@ -74,6 +74,15 @@ describe Gitlab::Ci::Reports::TestSuite do it { is_expected.to eq(Gitlab::Ci::Reports::TestCase::STATUS_FAILED) } end + + context 'when a test case errored' do + before do + test_suite.add_test_case(test_case_success) + test_suite.add_test_case(test_case_error) + end + + it { is_expected.to eq(Gitlab::Ci::Reports::TestCase::STATUS_FAILED) } + end end Gitlab::Ci::Reports::TestCase::STATUS_TYPES.each do |status_type| |