Welcome to mirror list, hosted at ThFree Co, Russian Federation.

test_suite_summary.rb « reports « ci « gitlab « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 32b06d0ad490b0876fe0823f10c357c696828cc6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# frozen_string_literal: true

module Gitlab
  module Ci
    module Reports
      class TestSuiteSummary
        def initialize(build_report_results)
          @build_report_results = build_report_results
        end

        def name
          @name ||= @build_report_results.first.tests_name
        end

        # rubocop: disable CodeReuse/ActiveRecord
        def build_ids
          @build_report_results.pluck(:build_id)
        end

        def total_time
          @total_time ||= @build_report_results.sum(&:tests_duration)
        end

        def success_count
          @success_count ||= @build_report_results.sum(&:tests_success)
        end

        def failed_count
          @failed_count ||= @build_report_results.sum(&:tests_failed)
        end

        def skipped_count
          @skipped_count ||= @build_report_results.sum(&:tests_skipped)
        end

        def error_count
          @error_count ||= @build_report_results.sum(&:tests_errored)
        end

        def total_count
          @total_count ||= [success_count, failed_count, skipped_count, error_count].sum
        end
        # rubocop: disable CodeReuse/ActiveRecord

        def to_h
          {
            time: total_time,
            count: total_count,
            success: success_count,
            failed: failed_count,
            skipped: skipped_count,
            error: error_count
          }
        end
      end
    end
  end
end