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

59 lines
1.4 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
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
def to_h
{
time: total_time,
count: total_count,
success: success_count,
failed: failed_count,
skipped: skipped_count,
error: error_count
}
end
2020-07-28 23:09:34 +05:30
end
end
end
end