summaryrefslogtreecommitdiff
path: root/spec/lib/gitlab/ci/reports
diff options
context:
space:
mode:
Diffstat (limited to 'spec/lib/gitlab/ci/reports')
-rw-r--r--spec/lib/gitlab/ci/reports/accessibility_reports_comparer_spec.rb2
-rw-r--r--spec/lib/gitlab/ci/reports/accessibility_reports_spec.rb2
-rw-r--r--spec/lib/gitlab/ci/reports/coverage_reports_spec.rb2
-rw-r--r--spec/lib/gitlab/ci/reports/terraform_reports_spec.rb2
-rw-r--r--spec/lib/gitlab/ci/reports/test_case_spec.rb2
-rw-r--r--spec/lib/gitlab/ci/reports/test_report_summary_spec.rb90
-rw-r--r--spec/lib/gitlab/ci/reports/test_reports_comparer_spec.rb2
-rw-r--r--spec/lib/gitlab/ci/reports/test_reports_spec.rb2
-rw-r--r--spec/lib/gitlab/ci/reports/test_suite_comparer_spec.rb2
-rw-r--r--spec/lib/gitlab/ci/reports/test_suite_spec.rb37
-rw-r--r--spec/lib/gitlab/ci/reports/test_suite_summary_spec.rb89
11 files changed, 223 insertions, 9 deletions
diff --git a/spec/lib/gitlab/ci/reports/accessibility_reports_comparer_spec.rb b/spec/lib/gitlab/ci/reports/accessibility_reports_comparer_spec.rb
index 31a330f46b1..240ede790e0 100644
--- a/spec/lib/gitlab/ci/reports/accessibility_reports_comparer_spec.rb
+++ b/spec/lib/gitlab/ci/reports/accessibility_reports_comparer_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-describe Gitlab::Ci::Reports::AccessibilityReportsComparer do
+RSpec.describe Gitlab::Ci::Reports::AccessibilityReportsComparer do
let(:comparer) { described_class.new(base_reports, head_reports) }
let(:base_reports) { Gitlab::Ci::Reports::AccessibilityReports.new }
let(:head_reports) { Gitlab::Ci::Reports::AccessibilityReports.new }
diff --git a/spec/lib/gitlab/ci/reports/accessibility_reports_spec.rb b/spec/lib/gitlab/ci/reports/accessibility_reports_spec.rb
index 0dc13b464b1..8c35b2a34cf 100644
--- a/spec/lib/gitlab/ci/reports/accessibility_reports_spec.rb
+++ b/spec/lib/gitlab/ci/reports/accessibility_reports_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-describe Gitlab::Ci::Reports::AccessibilityReports do
+RSpec.describe Gitlab::Ci::Reports::AccessibilityReports do
let(:accessibility_report) { described_class.new }
let(:url) { 'https://gitlab.com' }
let(:data) do
diff --git a/spec/lib/gitlab/ci/reports/coverage_reports_spec.rb b/spec/lib/gitlab/ci/reports/coverage_reports_spec.rb
index 7cf43ceab32..41ebae863ee 100644
--- a/spec/lib/gitlab/ci/reports/coverage_reports_spec.rb
+++ b/spec/lib/gitlab/ci/reports/coverage_reports_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-describe Gitlab::Ci::Reports::CoverageReports do
+RSpec.describe Gitlab::Ci::Reports::CoverageReports do
let(:coverage_report) { described_class.new }
it { expect(coverage_report.files).to eq({}) }
diff --git a/spec/lib/gitlab/ci/reports/terraform_reports_spec.rb b/spec/lib/gitlab/ci/reports/terraform_reports_spec.rb
index bfab30543ed..5e94fe2bb3d 100644
--- a/spec/lib/gitlab/ci/reports/terraform_reports_spec.rb
+++ b/spec/lib/gitlab/ci/reports/terraform_reports_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-describe Gitlab::Ci::Reports::TerraformReports do
+RSpec.describe Gitlab::Ci::Reports::TerraformReports do
it 'initializes plans with and empty hash' do
expect(subject.plans).to eq({})
end
diff --git a/spec/lib/gitlab/ci/reports/test_case_spec.rb b/spec/lib/gitlab/ci/reports/test_case_spec.rb
index b5883867983..8882defbd9e 100644
--- a/spec/lib/gitlab/ci/reports/test_case_spec.rb
+++ b/spec/lib/gitlab/ci/reports/test_case_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-describe Gitlab::Ci::Reports::TestCase do
+RSpec.describe Gitlab::Ci::Reports::TestCase do
describe '#initialize' do
let(:test_case) { described_class.new(params)}
diff --git a/spec/lib/gitlab/ci/reports/test_report_summary_spec.rb b/spec/lib/gitlab/ci/reports/test_report_summary_spec.rb
new file mode 100644
index 00000000000..70d82851125
--- /dev/null
+++ b/spec/lib/gitlab/ci/reports/test_report_summary_spec.rb
@@ -0,0 +1,90 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe Gitlab::Ci::Reports::TestReportSummary do
+ let(:build_report_result_1) { build(:ci_build_report_result) }
+ let(:build_report_result_2) { build(:ci_build_report_result, :with_junit_success) }
+ let(:test_report_summary) { described_class.new([build_report_result_1, build_report_result_2]) }
+
+ describe '#total' do
+ subject { test_report_summary.total }
+
+ context 'when test report summary has several build report results' do
+ it 'returns test suite summary object' do
+ expect(subject).to be_a_kind_of(Gitlab::Ci::Reports::TestSuiteSummary)
+ end
+ end
+ end
+
+ describe '#total_time' do
+ subject { test_report_summary.total_time }
+
+ context 'when test report summary has several build report results' do
+ it 'returns the total' do
+ expect(subject).to eq(0.84)
+ end
+ end
+ end
+
+ describe '#total_count' do
+ subject { test_report_summary.total_count }
+
+ context 'when test report summary has several build report results' do
+ it 'returns the total count' do
+ expect(subject).to eq(4)
+ end
+ end
+ end
+
+ describe '#success_count' do
+ subject { test_report_summary.success_count }
+
+ context 'when test suite summary has several build report results' do
+ it 'returns the total success' do
+ expect(subject).to eq(2)
+ end
+ end
+ end
+
+ describe '#failed_count' do
+ subject { test_report_summary.failed_count }
+
+ context 'when test suite summary has several build report results' do
+ it 'returns the total failed' do
+ expect(subject).to eq(0)
+ end
+ end
+ end
+
+ describe '#error_count' do
+ subject { test_report_summary.error_count }
+
+ context 'when test suite summary has several build report results' do
+ it 'returns the total errored' do
+ expect(subject).to eq(2)
+ end
+ end
+ end
+
+ describe '#skipped_count' do
+ subject { test_report_summary.skipped_count }
+
+ context 'when test suite summary has several build report results' do
+ it 'returns the total skipped' do
+ expect(subject).to eq(0)
+ end
+ end
+ end
+
+ describe '#test_suites' do
+ subject { test_report_summary.test_suites }
+
+ context 'when test report summary has several build report results' do
+ it 'returns test suites grouped by name' do
+ expect(subject.keys).to eq(["rspec"])
+ expect(subject.keys.size).to eq(1)
+ end
+ end
+ end
+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 d731afe1fff..3483dddca3a 100644
--- a/spec/lib/gitlab/ci/reports/test_reports_comparer_spec.rb
+++ b/spec/lib/gitlab/ci/reports/test_reports_comparer_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-describe Gitlab::Ci::Reports::TestReportsComparer do
+RSpec.describe Gitlab::Ci::Reports::TestReportsComparer do
include TestReportsHelper
let(:comparer) { described_class.new(base_reports, head_reports) }
diff --git a/spec/lib/gitlab/ci/reports/test_reports_spec.rb b/spec/lib/gitlab/ci/reports/test_reports_spec.rb
index e51728496e1..502859852f2 100644
--- a/spec/lib/gitlab/ci/reports/test_reports_spec.rb
+++ b/spec/lib/gitlab/ci/reports/test_reports_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-describe Gitlab::Ci::Reports::TestReports do
+RSpec.describe Gitlab::Ci::Reports::TestReports do
include TestReportsHelper
let(:test_reports) { described_class.new }
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 2d2179a690b..6bb6771678a 100644
--- a/spec/lib/gitlab/ci/reports/test_suite_comparer_spec.rb
+++ b/spec/lib/gitlab/ci/reports/test_suite_comparer_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-describe Gitlab::Ci::Reports::TestSuiteComparer do
+RSpec.describe Gitlab::Ci::Reports::TestSuiteComparer do
include TestReportsHelper
let(:comparer) { described_class.new(name, base_suite, head_suite) }
diff --git a/spec/lib/gitlab/ci/reports/test_suite_spec.rb b/spec/lib/gitlab/ci/reports/test_suite_spec.rb
index e0b2593353a..c4c4d2c3704 100644
--- a/spec/lib/gitlab/ci/reports/test_suite_spec.rb
+++ b/spec/lib/gitlab/ci/reports/test_suite_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-describe Gitlab::Ci::Reports::TestSuite do
+RSpec.describe Gitlab::Ci::Reports::TestSuite do
include TestReportsHelper
let(:test_suite) { described_class.new('Rspec') }
@@ -139,6 +139,41 @@ describe Gitlab::Ci::Reports::TestSuite do
end
end
+ describe '#+' do
+ let(:test_suite_2) { described_class.new('Rspec') }
+
+ subject { test_suite + test_suite_2 }
+
+ context 'when adding multiple suites together' do
+ before do
+ test_suite.add_test_case(test_case_success)
+ test_suite.add_test_case(test_case_failed)
+ end
+
+ it 'returns a new test suite' do
+ expect(subject).to be_an_instance_of(described_class)
+ end
+
+ it 'returns the suite name' do
+ expect(subject.name).to eq('Rspec')
+ end
+
+ it 'returns the sum for total_time' do
+ expect(subject.total_time).to eq(3.33)
+ end
+
+ it 'merges tests cases hash', :aggregate_failures do
+ test_suite_2.add_test_case(create_test_case_java_success)
+
+ failed_keys = test_suite.test_cases['failed'].keys
+ success_keys = test_suite.test_cases['success'].keys + test_suite_2.test_cases['success'].keys
+
+ expect(subject.test_cases['failed'].keys).to contain_exactly(*failed_keys)
+ expect(subject.test_cases['success'].keys).to contain_exactly(*success_keys)
+ end
+ end
+ end
+
Gitlab::Ci::Reports::TestCase::STATUS_TYPES.each do |status_type|
describe "##{status_type}" do
subject { test_suite.public_send("#{status_type}") }
diff --git a/spec/lib/gitlab/ci/reports/test_suite_summary_spec.rb b/spec/lib/gitlab/ci/reports/test_suite_summary_spec.rb
new file mode 100644
index 00000000000..12c96acdcf3
--- /dev/null
+++ b/spec/lib/gitlab/ci/reports/test_suite_summary_spec.rb
@@ -0,0 +1,89 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe Gitlab::Ci::Reports::TestSuiteSummary do
+ let(:build_report_result_1) { build(:ci_build_report_result) }
+ let(:build_report_result_2) { build(:ci_build_report_result, :with_junit_success) }
+ let(:test_suite_summary) { described_class.new([build_report_result_1, build_report_result_2]) }
+
+ describe '#name' do
+ subject { test_suite_summary.name }
+
+ context 'when test suite summary has several build report results' do
+ it 'returns the suite name' do
+ expect(subject).to eq("rspec")
+ end
+ end
+ end
+
+ describe '#build_ids' do
+ subject { test_suite_summary.build_ids }
+
+ context 'when test suite summary has several build report results' do
+ it 'returns the build ids' do
+ expect(subject).to contain_exactly(build_report_result_1.build_id, build_report_result_2.build_id)
+ end
+ end
+ end
+
+ describe '#total_time' do
+ subject { test_suite_summary.total_time }
+
+ context 'when test suite summary has several build report results' do
+ it 'returns the total time' do
+ expect(subject).to eq(0.84)
+ end
+ end
+ end
+
+ describe '#success_count' do
+ subject { test_suite_summary.success_count }
+
+ context 'when test suite summary has several build report results' do
+ it 'returns the total success' do
+ expect(subject).to eq(2)
+ end
+ end
+ end
+
+ describe '#failed_count' do
+ subject { test_suite_summary.failed_count }
+
+ context 'when test suite summary has several build report results' do
+ it 'returns the total failed' do
+ expect(subject).to eq(0)
+ end
+ end
+ end
+
+ describe '#error_count' do
+ subject { test_suite_summary.error_count }
+
+ context 'when test suite summary has several build report results' do
+ it 'returns the total errored' do
+ expect(subject).to eq(2)
+ end
+ end
+ end
+
+ describe '#skipped_count' do
+ subject { test_suite_summary.skipped_count }
+
+ context 'when test suite summary has several build report results' do
+ it 'returns the total skipped' do
+ expect(subject).to eq(0)
+ end
+ end
+ end
+
+ describe '#total_count' do
+ subject { test_suite_summary.total_count }
+
+ context 'when test suite summary has several build report results' do
+ it 'returns the total count' do
+ expect(subject).to eq(4)
+ end
+ end
+ end
+end