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

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

68 lines
1.6 KiB
Ruby
Raw Normal View History

2020-07-28 23:09:34 +05:30
# frozen_string_literal: true
module Gitlab
module Ci
module Reports
class TestSuiteSummary
2021-04-17 20:07:23 +05:30
include Gitlab::Utils::StrongMemoize
2020-10-24 23:57:45 +05:30
def initialize(build_report_results)
@build_report_results = build_report_results
2020-07-28 23:09:34 +05:30
end
def name
2020-10-24 23:57:45 +05:30
@name ||= @build_report_results.first.tests_name
2020-07-28 23:09:34 +05:30
end
# rubocop: disable CodeReuse/ActiveRecord
def build_ids
2020-10-24 23:57:45 +05:30
@build_report_results.pluck(:build_id)
2020-07-28 23:09:34 +05:30
end
def total_time
2020-10-24 23:57:45 +05:30
@total_time ||= @build_report_results.sum(&:tests_duration)
2020-07-28 23:09:34 +05:30
end
def success_count
2020-10-24 23:57:45 +05:30
@success_count ||= @build_report_results.sum(&:tests_success)
2020-07-28 23:09:34 +05:30
end
def failed_count
2020-10-24 23:57:45 +05:30
@failed_count ||= @build_report_results.sum(&:tests_failed)
2020-07-28 23:09:34 +05:30
end
def skipped_count
2020-10-24 23:57:45 +05:30
@skipped_count ||= @build_report_results.sum(&:tests_skipped)
2020-07-28 23:09:34 +05:30
end
def error_count
2020-10-24 23:57:45 +05:30
@error_count ||= @build_report_results.sum(&:tests_errored)
2020-07-28 23:09:34 +05:30
end
def total_count
@total_count ||= [success_count, failed_count, skipped_count, error_count].sum
end
# rubocop: disable CodeReuse/ActiveRecord
2020-10-24 23:57:45 +05:30
2021-04-17 20:07:23 +05:30
def suite_error
strong_memoize(:suite_error) do
@build_report_results.map(&:suite_error).compact.first
end
end
2020-10-24 23:57:45 +05:30
def to_h
{
time: total_time,
count: total_count,
success: success_count,
failed: failed_count,
skipped: skipped_count,
2021-04-17 20:07:23 +05:30
error: error_count,
suite_error: suite_error
2020-10-24 23:57:45 +05:30
}
end
2020-07-28 23:09:34 +05:30
end
end
end
end