2020-06-19 14:08:39 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Gitlab
|
|
|
|
module Ci
|
|
|
|
module Reports
|
|
|
|
class TestSuiteSummary
|
2021-03-12 16:09:12 -05:00
|
|
|
include Gitlab::Utils::StrongMemoize
|
|
|
|
|
2020-08-11 17:10:09 -04:00
|
|
|
def initialize(build_report_results)
|
|
|
|
@build_report_results = build_report_results
|
2020-06-19 14:08:39 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def name
|
2020-08-11 17:10:09 -04:00
|
|
|
@name ||= @build_report_results.first.tests_name
|
2020-06-19 14:08:39 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
# rubocop: disable CodeReuse/ActiveRecord
|
2020-07-09 11:08:59 -04:00
|
|
|
def build_ids
|
2020-08-11 17:10:09 -04:00
|
|
|
@build_report_results.pluck(:build_id)
|
2020-07-09 11:08:59 -04:00
|
|
|
end
|
|
|
|
|
2020-06-19 14:08:39 -04:00
|
|
|
def total_time
|
2020-08-11 17:10:09 -04:00
|
|
|
@total_time ||= @build_report_results.sum(&:tests_duration)
|
2020-06-19 14:08:39 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def success_count
|
2020-08-11 17:10:09 -04:00
|
|
|
@success_count ||= @build_report_results.sum(&:tests_success)
|
2020-06-19 14:08:39 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def failed_count
|
2020-08-11 17:10:09 -04:00
|
|
|
@failed_count ||= @build_report_results.sum(&:tests_failed)
|
2020-06-19 14:08:39 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def skipped_count
|
2020-08-11 17:10:09 -04:00
|
|
|
@skipped_count ||= @build_report_results.sum(&:tests_skipped)
|
2020-06-19 14:08:39 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def error_count
|
2020-08-11 17:10:09 -04:00
|
|
|
@error_count ||= @build_report_results.sum(&:tests_errored)
|
2020-06-19 14:08:39 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def total_count
|
|
|
|
@total_count ||= [success_count, failed_count, skipped_count, error_count].sum
|
|
|
|
end
|
|
|
|
# rubocop: disable CodeReuse/ActiveRecord
|
2020-08-11 17:10:09 -04:00
|
|
|
|
2021-03-12 16:09:12 -05:00
|
|
|
def suite_error
|
|
|
|
strong_memoize(:suite_error) do
|
|
|
|
@build_report_results.map(&:suite_error).compact.first
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-08-11 17:10:09 -04:00
|
|
|
def to_h
|
|
|
|
{
|
|
|
|
time: total_time,
|
|
|
|
count: total_count,
|
|
|
|
success: success_count,
|
|
|
|
failed: failed_count,
|
|
|
|
skipped: skipped_count,
|
2021-03-12 16:09:12 -05:00
|
|
|
error: error_count,
|
|
|
|
suite_error: suite_error
|
2020-08-11 17:10:09 -04:00
|
|
|
}
|
|
|
|
end
|
2020-06-19 14:08:39 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|