Class: Datadog::CI::TestOptimisation::Skippable::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/datadog/ci/test_optimisation/skippable.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.from_http_response(http_response) ⇒ Object



17
18
19
# File 'lib/datadog/ci/test_optimisation/skippable.rb', line 17

def self.from_http_response(http_response)
  new(http_response, nil)
end

.from_json(json) ⇒ Object



21
22
23
# File 'lib/datadog/ci/test_optimisation/skippable.rb', line 21

def self.from_json(json)
  new(nil, json)
end

Instance Method Details

#correlation_idObject



30
31
32
# File 'lib/datadog/ci/test_optimisation/skippable.rb', line 30

def correlation_id
  payload.dig("meta", "correlation_id")
end

#error_messageObject



48
49
50
51
52
# File 'lib/datadog/ci/test_optimisation/skippable.rb', line 48

def error_message
  return nil if ok?

  "Status code: #{@http_response&.code}, response: #{@http_response&.payload}"
end

#ok?Boolean

Returns:

  • (Boolean)


25
26
27
28
# File 'lib/datadog/ci/test_optimisation/skippable.rb', line 25

def ok?
  resp = @http_response
  !resp.nil? && resp.ok?
end

#testsObject



34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/datadog/ci/test_optimisation/skippable.rb', line 34

def tests
  res = Set.new

  payload.fetch("data", [])
    .each do |test_data|
      next unless test_data["type"] == Ext::Test::ITR_TEST_SKIPPING_MODE

      attrs = test_data["attributes"] || {}
      res << Utils::TestRun.datadog_test_id(attrs["name"], attrs["suite"], attrs["parameters"])
    end

  res
end