summaryrefslogtreecommitdiff
path: root/spec/serializers
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-02-17 12:09:20 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-02-17 12:09:20 +0000
commitb84eeb256c4a780d902faee1f99ca9a711b3214a (patch)
tree32918aadbea9210eace50efbce9afbfb8cd3ba84 /spec/serializers
parent53ae6b7e3f83591ad251a3f771f5bf3b8cf087ba (diff)
downloadgitlab-ce-b84eeb256c4a780d902faee1f99ca9a711b3214a.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/serializers')
-rw-r--r--spec/serializers/test_reports_comparer_entity_spec.rb6
-rw-r--r--spec/serializers/test_suite_comparer_entity_spec.rb78
2 files changed, 70 insertions, 14 deletions
diff --git a/spec/serializers/test_reports_comparer_entity_spec.rb b/spec/serializers/test_reports_comparer_entity_spec.rb
index 2627ad536e4..e7dabc67325 100644
--- a/spec/serializers/test_reports_comparer_entity_spec.rb
+++ b/spec/serializers/test_reports_comparer_entity_spec.rb
@@ -24,7 +24,7 @@ describe TestReportsComparerEntity do
it 'contains correct compared test reports details' do
expect(subject[:status]).to eq('success')
- expect(subject[:summary]).to include(total: 2, resolved: 0, failed: 0)
+ expect(subject[:summary]).to include(total: 2, resolved: 0, failed: 0, errored: 0)
expect(subject[:suites].first[:name]).to eq('rspec')
expect(subject[:suites].first[:status]).to eq('success')
expect(subject[:suites].second[:name]).to eq('junit')
@@ -42,7 +42,7 @@ describe TestReportsComparerEntity do
it 'contains correct compared test reports details' do
expect(subject[:status]).to eq('failed')
- expect(subject[:summary]).to include(total: 2, resolved: 0, failed: 1)
+ expect(subject[:summary]).to include(total: 2, resolved: 0, failed: 1, errored: 0)
expect(subject[:suites].first[:name]).to eq('rspec')
expect(subject[:suites].first[:status]).to eq('success')
expect(subject[:suites].second[:name]).to eq('junit')
@@ -60,7 +60,7 @@ describe TestReportsComparerEntity do
it 'contains correct compared test reports details' do
expect(subject[:status]).to eq('success')
- expect(subject[:summary]).to include(total: 2, resolved: 1, failed: 0)
+ expect(subject[:summary]).to include(total: 2, resolved: 1, failed: 0, errored: 0)
expect(subject[:suites].first[:name]).to eq('rspec')
expect(subject[:suites].first[:status]).to eq('success')
expect(subject[:suites].second[:name]).to eq('junit')
diff --git a/spec/serializers/test_suite_comparer_entity_spec.rb b/spec/serializers/test_suite_comparer_entity_spec.rb
index e22387130a1..9790777a570 100644
--- a/spec/serializers/test_suite_comparer_entity_spec.rb
+++ b/spec/serializers/test_suite_comparer_entity_spec.rb
@@ -12,6 +12,7 @@ describe TestSuiteComparerEntity do
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_error) { create_test_case_rspec_error }
describe '#as_json' do
subject { entity.as_json }
@@ -25,7 +26,7 @@ describe TestSuiteComparerEntity do
it 'contains correct compared test suite details' do
expect(subject[:name]).to eq(name)
expect(subject[:status]).to eq('failed')
- expect(subject[:summary]).to include(total: 1, resolved: 0, failed: 1)
+ expect(subject[:summary]).to include(total: 1, resolved: 0, failed: 1, errored: 0)
subject[:new_failures].first.tap do |new_failure|
expect(new_failure[:status]).to eq(test_case_failed.status)
expect(new_failure[:name]).to eq(test_case_failed.name)
@@ -37,6 +38,27 @@ describe TestSuiteComparerEntity do
end
end
+ 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 'contains correct compared test suite details' do
+ expect(subject[:name]).to eq(name)
+ expect(subject[:status]).to eq('failed')
+ expect(subject[:summary]).to include(total: 1, resolved: 0, failed: 0, errored: 1)
+ subject[:new_errors].first.tap do |new_error|
+ expect(new_error[:status]).to eq(test_case_error.status)
+ expect(new_error[:name]).to eq(test_case_error.name)
+ expect(new_error[:execution_time]).to eq(test_case_error.execution_time)
+ expect(new_error[:system_output]).to eq(test_case_error.system_output)
+ end
+ expect(subject[:resolved_failures]).to be_empty
+ expect(subject[:existing_failures]).to be_empty
+ end
+ end
+
context 'when head suite still has a failed test case which failed in base' do
before do
base_suite.add_test_case(test_case_failed)
@@ -46,7 +68,7 @@ describe TestSuiteComparerEntity do
it 'contains correct compared test suite details' do
expect(subject[:name]).to eq(name)
expect(subject[:status]).to eq('failed')
- expect(subject[:summary]).to include(total: 1, resolved: 0, failed: 1)
+ expect(subject[:summary]).to include(total: 1, resolved: 0, failed: 1, errored: 0)
expect(subject[:new_failures]).to be_empty
expect(subject[:resolved_failures]).to be_empty
subject[:existing_failures].first.tap do |existing_failure|
@@ -67,7 +89,7 @@ describe TestSuiteComparerEntity do
it 'contains correct compared test suite details' do
expect(subject[:name]).to eq(name)
expect(subject[:status]).to eq('success')
- expect(subject[:summary]).to include(total: 1, resolved: 1, failed: 0)
+ expect(subject[:summary]).to include(total: 1, resolved: 1, failed: 0, errored: 0)
expect(subject[:new_failures]).to be_empty
subject[:resolved_failures].first.tap do |resolved_failure|
expect(resolved_failure[:status]).to eq(test_case_success.status)
@@ -88,42 +110,57 @@ describe TestSuiteComparerEntity do
context 'prefers new over existing and resolved' do
before do
3.times { add_new_failure }
+ 3.times { add_new_error }
3.times { add_existing_failure }
+ 3.times { add_existing_error }
3.times { add_resolved_failure }
+ 3.times { add_resolved_error }
end
- it 'returns 2 new failures, and 1 of resolved and existing' do
- expect(subject[:summary]).to include(total: 9, resolved: 3, failed: 6)
+ it 'returns 2 of each new category, and 1 of each resolved and existing' do
+ expect(subject[:summary]).to include(total: 18, resolved: 6, failed: 6, errored: 6)
expect(subject[:new_failures].count).to eq(2)
+ expect(subject[:new_errors].count).to eq(2)
expect(subject[:existing_failures].count).to eq(1)
+ expect(subject[:existing_errors].count).to eq(1)
expect(subject[:resolved_failures].count).to eq(1)
+ expect(subject[:resolved_errors].count).to eq(1)
end
end
context 'prefers existing over resolved' do
before do
3.times { add_existing_failure }
+ 3.times { add_existing_error }
3.times { add_resolved_failure }
+ 3.times { add_resolved_error }
end
- it 'returns 2 existing failures, and 1 resolved' do
- expect(subject[:summary]).to include(total: 6, resolved: 3, failed: 3)
+ it 'returns 2 of each existing category, and 1 of each resolved' do
+ expect(subject[:summary]).to include(total: 12, resolved: 6, failed: 3, errored: 3)
expect(subject[:new_failures].count).to eq(0)
+ expect(subject[:new_errors].count).to eq(0)
expect(subject[:existing_failures].count).to eq(2)
+ expect(subject[:existing_errors].count).to eq(2)
expect(subject[:resolved_failures].count).to eq(1)
+ expect(subject[:resolved_errors].count).to eq(1)
end
end
context 'limits amount of resolved' do
before do
3.times { add_resolved_failure }
+ 3.times { add_resolved_error }
end
- it 'returns 2 resolved failures' do
- expect(subject[:summary]).to include(total: 3, resolved: 3, failed: 0)
+ it 'returns 2 of each resolved category' do
+ expect(subject[:summary]).to include(total: 6, resolved: 6, failed: 0, errored: 0)
expect(subject[:new_failures].count).to eq(0)
+ expect(subject[:new_errors].count).to eq(0)
expect(subject[:existing_failures].count).to eq(0)
+ expect(subject[:existing_errors].count).to eq(0)
expect(subject[:resolved_failures].count).to eq(2)
+ expect(subject[:resolved_errors].count).to eq(2)
end
end
@@ -134,19 +171,38 @@ describe TestSuiteComparerEntity do
head_suite.add_test_case(failed_case)
end
+ def add_new_error
+ error_case = create_test_case_rspec_error(SecureRandom.hex)
+ head_suite.add_test_case(error_case)
+ end
+
def add_existing_failure
failed_case = create_test_case_rspec_failed(SecureRandom.hex)
base_suite.add_test_case(failed_case)
head_suite.add_test_case(failed_case)
end
+ def add_existing_error
+ error_case = create_test_case_rspec_error(SecureRandom.hex)
+ base_suite.add_test_case(error_case)
+ head_suite.add_test_case(error_case)
+ end
+
def add_resolved_failure
case_name = SecureRandom.hex
- failed_case = create_test_case_rspec_failed(case_name)
- success_case = create_test_case_rspec_success(case_name)
+ failed_case = create_test_case_java_failed(case_name)
+ success_case = create_test_case_java_success(case_name)
base_suite.add_test_case(failed_case)
head_suite.add_test_case(success_case)
end
+
+ def add_resolved_error
+ case_name = SecureRandom.hex
+ error_case = create_test_case_java_error(case_name)
+ success_case = create_test_case_java_success(case_name)
+ base_suite.add_test_case(error_case)
+ head_suite.add_test_case(success_case)
+ end
end
end
end