gitlab-org--gitlab-foss/lib/gitlab/ci/reports/test_suite_comparer.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

59 lines
1.3 KiB
Ruby

# frozen_string_literal: true
module Gitlab
module Ci
module Reports
class TestSuiteComparer
include Gitlab::Utils::StrongMemoize
attr_reader :name, :base_suite, :head_suite
def initialize(name, base_suite, head_suite)
@name = name
@base_suite = base_suite || TestSuite.new
@head_suite = head_suite
end
def new_failures
strong_memoize(:new_failures) do
head_suite.failed.reject do |key, _|
base_suite.failed.include?(key)
end.values
end
end
def existing_failures
strong_memoize(:existing_failures) do
head_suite.failed.select do |key, _|
base_suite.failed.include?(key)
end.values
end
end
def resolved_failures
strong_memoize(:resolved_failures) do
head_suite.success.select do |key, _|
base_suite.failed.include?(key)
end.values
end
end
def total_count
head_suite.total_count
end
def total_status
head_suite.total_status
end
def resolved_count
resolved_failures.count
end
def failed_count
new_failures.count + existing_failures.count
end
end
end
end
end