summaryrefslogtreecommitdiff
path: root/spec/serializers/test_reports_comparer_serializer_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/serializers/test_reports_comparer_serializer_spec.rb')
-rw-r--r--spec/serializers/test_reports_comparer_serializer_spec.rb62
1 files changed, 62 insertions, 0 deletions
diff --git a/spec/serializers/test_reports_comparer_serializer_spec.rb b/spec/serializers/test_reports_comparer_serializer_spec.rb
new file mode 100644
index 00000000000..9ea86c0dd83
--- /dev/null
+++ b/spec/serializers/test_reports_comparer_serializer_spec.rb
@@ -0,0 +1,62 @@
+require 'spec_helper'
+
+describe TestReportsComparerSerializer do
+ include TestReportsHelper
+
+ let(:project) { double(:project) }
+ let(:serializer) { described_class.new(project: project).represent(comparer) }
+ let(:comparer) { Gitlab::Ci::Reports::TestReportsComparer.new(base_reports, head_reports) }
+ let(:base_reports) { Gitlab::Ci::Reports::TestReports.new }
+ let(:head_reports) { Gitlab::Ci::Reports::TestReports.new }
+
+ describe '#to_json' do
+ subject { serializer.to_json }
+
+ context 'when head and base reports include two test suites' do
+ context 'when the status of head report is success' 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_success)
+ 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 'matches the schema' do
+ expect(subject).to match_schema('entities/test_reports_comparer')
+ end
+ end
+
+ context 'when the status of head report is failed' 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_success)
+ 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_failed)
+ end
+
+ it 'matches the schema' do
+ expect(subject).to match_schema('entities/test_reports_comparer')
+ end
+ end
+
+ context 'when the status of head report is resolved' 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)
+ 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_resolved)
+ end
+
+ let(:create_test_case_java_resolved) do
+ create_test_case_java_failed.tap do |test_case|
+ test_case.instance_variable_set("@status", Gitlab::Ci::Reports::TestCase::STATUS_SUCCESS)
+ end
+ end
+
+ it 'matches the schema' do
+ expect(subject).to match_schema('entities/test_reports_comparer')
+ end
+ end
+ end
+ end
+end