diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-05-20 17:34:42 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-05-20 17:34:42 +0300 |
commit | 9f46488805e86b1bc341ea1620b866016c2ce5ed (patch) | |
tree | f9748c7e287041e37d6da49e0a29c9511dc34768 /spec/serializers/test_suite_entity_spec.rb | |
parent | dfc92d081ea0332d69c8aca2f0e745cb48ae5e6d (diff) |
Add latest changes from gitlab-org/gitlab@13-0-stable-ee
Diffstat (limited to 'spec/serializers/test_suite_entity_spec.rb')
-rw-r--r-- | spec/serializers/test_suite_entity_spec.rb | 50 |
1 files changed, 44 insertions, 6 deletions
diff --git a/spec/serializers/test_suite_entity_spec.rb b/spec/serializers/test_suite_entity_spec.rb index 6a9653954f3..bd88d235013 100644 --- a/spec/serializers/test_suite_entity_spec.rb +++ b/spec/serializers/test_suite_entity_spec.rb @@ -3,27 +3,65 @@ require 'spec_helper' describe TestSuiteEntity do - let(:pipeline) { create(:ci_pipeline, :with_test_reports) } - let(:entity) { described_class.new(pipeline.test_reports.test_suites.each_value.first) } + let(:pipeline) { create(:ci_pipeline, :with_test_reports) } + let(:test_suite) { pipeline.test_reports.test_suites.each_value.first } + let(:entity) { described_class.new(test_suite) } describe '#as_json' do subject(:as_json) { entity.as_json } it 'contains the suite name' do - expect(as_json).to include(:name) + expect(as_json[:name]).to be_present end it 'contains the total time' do - expect(as_json).to include(:total_time) + expect(as_json[:total_time]).to be_present end it 'contains the counts' do - expect(as_json).to include(:total_count, :success_count, :failed_count, :skipped_count, :error_count) + expect(as_json[:total_count]).to eq(4) + expect(as_json[:success_count]).to eq(2) + expect(as_json[:failed_count]).to eq(2) + expect(as_json[:skipped_count]).to eq(0) + expect(as_json[:error_count]).to eq(0) end it 'contains the test cases' do - expect(as_json).to include(:test_cases) expect(as_json[:test_cases].count).to eq(4) end + + it 'contains an empty error message' do + expect(as_json[:suite_error]).to be_nil + end + + context 'with a suite error' do + before do + test_suite.set_suite_error('a really bad error') + end + + it 'contains the suite name' do + expect(as_json[:name]).to be_present + end + + it 'contains the total time' do + expect(as_json[:total_time]).to be_present + end + + it 'returns all the counts as 0' do + expect(as_json[:total_count]).to eq(0) + expect(as_json[:success_count]).to eq(0) + expect(as_json[:failed_count]).to eq(0) + expect(as_json[:skipped_count]).to eq(0) + expect(as_json[:error_count]).to eq(0) + end + + it 'returns no test cases' do + expect(as_json[:test_cases]).to be_empty + end + + it 'returns a suite error' do + expect(as_json[:suite_error]).to eq('a really bad error') + end + end end end |