gitlab-org--gitlab-foss/lib/gitlab/ci/reports/test_reports.rb
gfyoung 06892e88f5 Enable frozen string for lib/gitlab/ci
Enables frozen string for the following:

* lib/gitlab/ci/*.rb
* lib/gitlab/ci/build/**/*.rb
* lib/gitlab/ci/config/**/*.rb
* lib/gitlab/ci/pipeline/**/*.rb
* lib/gitlab/ci/reports/**/*.rb

Partially addresses #47424.
2018-10-26 16:36:42 -07:00

47 lines
1.2 KiB
Ruby

# frozen_string_literal: true
module Gitlab
module Ci
module Reports
class TestReports
attr_reader :test_suites
def initialize
@test_suites = {}
end
def get_suite(suite_name)
test_suites[suite_name] ||= TestSuite.new(suite_name)
end
# rubocop: disable CodeReuse/ActiveRecord
def total_time
test_suites.values.sum(&:total_time)
end
# rubocop: enable CodeReuse/ActiveRecord
# rubocop: disable CodeReuse/ActiveRecord
def total_count
test_suites.values.sum(&:total_count)
end
# rubocop: enable CodeReuse/ActiveRecord
def total_status
if failed_count > 0 || error_count > 0
TestCase::STATUS_FAILED
else
TestCase::STATUS_SUCCESS
end
end
TestCase::STATUS_TYPES.each do |status_type|
define_method("#{status_type}_count") do
# rubocop: disable CodeReuse/ActiveRecord
test_suites.values.sum { |suite| suite.public_send("#{status_type}_count") } # rubocop:disable GitlabSecurity/PublicSend
# rubocop: enable CodeReuse/ActiveRecord
end
end
end
end
end
end