Class: Gitlab::Ci::Reports::TestSuiteSummary

Inherits:
Object
  • Object
show all
Includes:
Utils::StrongMemoize
Defined in:
lib/gitlab/ci/reports/test_suite_summary.rb

Instance Method Summary collapse

Methods included from Utils::StrongMemoize

#clear_memoization, #strong_memoize, #strong_memoized?

Constructor Details

#initialize(build_report_results) ⇒ TestSuiteSummary

Returns a new instance of TestSuiteSummary.


9
10
11
# File 'lib/gitlab/ci/reports/test_suite_summary.rb', line 9

def initialize(build_report_results)
  @build_report_results = build_report_results
end

Instance Method Details

#build_idsObject

rubocop: disable CodeReuse/ActiveRecord


18
19
20
# File 'lib/gitlab/ci/reports/test_suite_summary.rb', line 18

def build_ids
  @build_report_results.pluck(:build_id)
end

#error_countObject


38
39
40
# File 'lib/gitlab/ci/reports/test_suite_summary.rb', line 38

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

#failed_countObject


30
31
32
# File 'lib/gitlab/ci/reports/test_suite_summary.rb', line 30

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

#nameObject


13
14
15
# File 'lib/gitlab/ci/reports/test_suite_summary.rb', line 13

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

#skipped_countObject


34
35
36
# File 'lib/gitlab/ci/reports/test_suite_summary.rb', line 34

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

#success_countObject


26
27
28
# File 'lib/gitlab/ci/reports/test_suite_summary.rb', line 26

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

#suite_errorObject

rubocop: disable CodeReuse/ActiveRecord


47
48
49
50
51
# File 'lib/gitlab/ci/reports/test_suite_summary.rb', line 47

def suite_error
  strong_memoize(:suite_error) do
    @build_report_results.map(&:suite_error).compact.first
  end
end

#to_hObject


53
54
55
56
57
58
59
60
61
62
63
# File 'lib/gitlab/ci/reports/test_suite_summary.rb', line 53

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

#total_countObject


42
43
44
# File 'lib/gitlab/ci/reports/test_suite_summary.rb', line 42

def total_count
  @total_count ||= [success_count, failed_count, skipped_count, error_count].sum
end

#total_timeObject


22
23
24
# File 'lib/gitlab/ci/reports/test_suite_summary.rb', line 22

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