2020-06-23 00:09:42 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Ci
|
2021-10-27 15:23:28 +05:30
|
|
|
class BuildReportResult < Ci::ApplicationRecord
|
2020-06-23 00:09:42 +05:30
|
|
|
self.primary_key = :build_id
|
|
|
|
|
|
|
|
belongs_to :build, class_name: "Ci::Build", inverse_of: :report_results
|
|
|
|
belongs_to :project, class_name: "Project", inverse_of: :build_report_results
|
|
|
|
|
|
|
|
validates :build, :project, presence: true
|
|
|
|
validates :data, json_schema: { filename: "build_report_result_data" }
|
|
|
|
|
|
|
|
store_accessor :data, :tests
|
|
|
|
|
|
|
|
def tests_name
|
|
|
|
tests.dig("name")
|
|
|
|
end
|
|
|
|
|
|
|
|
def tests_duration
|
|
|
|
tests.dig("duration")
|
|
|
|
end
|
|
|
|
|
|
|
|
def tests_success
|
|
|
|
tests.dig("success").to_i
|
|
|
|
end
|
|
|
|
|
|
|
|
def tests_failed
|
|
|
|
tests.dig("failed").to_i
|
|
|
|
end
|
|
|
|
|
|
|
|
def tests_errored
|
|
|
|
tests.dig("errored").to_i
|
|
|
|
end
|
|
|
|
|
|
|
|
def tests_skipped
|
|
|
|
tests.dig("skipped").to_i
|
|
|
|
end
|
|
|
|
|
2021-04-17 20:07:23 +05:30
|
|
|
def suite_error
|
|
|
|
tests.dig("suite_error")
|
|
|
|
end
|
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
def tests_total
|
|
|
|
[tests_success, tests_failed, tests_errored, tests_skipped].sum
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|