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

53 lines
1.5 KiB
Ruby
Raw Normal View History

2018-12-13 13:39:08 +05:30
# frozen_string_literal: true
2018-11-18 11:00:15 +05:30
module Gitlab
module Ci
module Reports
class TestCase
2019-12-04 20:38:33 +05:30
STATUS_SUCCESS = 'success'
STATUS_FAILED = 'failed'
STATUS_SKIPPED = 'skipped'
STATUS_ERROR = 'error'
2020-11-24 15:15:51 +05:30
STATUS_TYPES = [STATUS_ERROR, STATUS_FAILED, STATUS_SUCCESS, STATUS_SKIPPED].freeze
2018-11-18 11:00:15 +05:30
2021-01-03 14:25:43 +05:30
attr_reader :suite_name, :name, :classname, :execution_time, :status, :file, :system_output, :stack_trace, :key, :attachment, :job
2020-04-22 19:07:51 +05:30
def initialize(params)
2021-01-03 14:25:43 +05:30
@suite_name = params.fetch(:suite_name)
2020-04-22 19:07:51 +05:30
@name = params.fetch(:name)
@classname = params.fetch(:classname)
@file = params.fetch(:file, nil)
@execution_time = params.fetch(:execution_time).to_f
@status = params.fetch(:status)
@system_output = params.fetch(:system_output, nil)
@stack_trace = params.fetch(:stack_trace, nil)
@attachment = params.fetch(:attachment, nil)
@job = params.fetch(:job, nil)
2021-01-03 14:25:43 +05:30
@key = hash_key("#{suite_name}_#{classname}_#{name}")
2020-04-08 14:13:33 +05:30
end
def has_attachment?
attachment.present?
2018-11-18 11:00:15 +05:30
end
2020-04-22 19:07:51 +05:30
def attachment_url
return unless has_attachment?
Rails.application.routes.url_helpers.file_project_job_artifacts_path(
job.project,
job.id,
attachment
)
end
2018-11-18 11:00:15 +05:30
private
2021-01-03 14:25:43 +05:30
def hash_key(key)
Digest::SHA256.hexdigest(key)
2018-11-18 11:00:15 +05:30
end
end
end
end
end