debian-mirror-gitlab/lib/gitlab/ci/reports/test_reports_comparer.rb

43 lines
1.2 KiB
Ruby
Raw Normal View History

2018-12-13 13:39:08 +05:30
# frozen_string_literal: true
2018-11-18 11:00:15 +05:30
module Gitlab
module Ci
module Reports
class TestReportsComparer
include Gitlab::Utils::StrongMemoize
attr_reader :base_reports, :head_reports
def initialize(base_reports, head_reports)
@base_reports = base_reports || TestReports.new
@head_reports = head_reports
end
def suite_comparers
strong_memoize(:suite_comparers) do
head_reports.test_suites.map do |name, test_suite|
TestSuiteComparer.new(name, base_reports.get_suite(name), test_suite)
end
end
end
def total_status
if suite_comparers.any? { |suite| suite.total_status == TestCase::STATUS_FAILED }
TestCase::STATUS_FAILED
else
TestCase::STATUS_SUCCESS
end
end
2020-03-09 13:42:32 +05:30
%w(total_count resolved_count failed_count error_count).each do |method|
2018-11-18 11:00:15 +05:30
define_method(method) do
2018-12-05 23:21:45 +05:30
# rubocop: disable CodeReuse/ActiveRecord
2018-11-18 11:00:15 +05:30
suite_comparers.sum { |suite| suite.public_send(method) } # rubocop:disable GitlabSecurity/PublicSend
2018-12-05 23:21:45 +05:30
# rubocop: enable CodeReuse/ActiveRecord
2018-11-18 11:00:15 +05:30
end
end
end
end
end
end