Class: Datadog::CI::TestOptimisation::Skippable::Response
- Inherits:
-
Object
- Object
- Datadog::CI::TestOptimisation::Skippable::Response
- Defined in:
- lib/datadog/ci/test_optimisation/skippable.rb
Instance Method Summary collapse
- #correlation_id ⇒ Object
- #error_message ⇒ Object
-
#initialize(http_response) ⇒ Response
constructor
A new instance of Response.
- #ok? ⇒ Boolean
- #tests ⇒ Object
Constructor Details
#initialize(http_response) ⇒ Response
Returns a new instance of Response.
17 18 19 20 |
# File 'lib/datadog/ci/test_optimisation/skippable.rb', line 17 def initialize(http_response) @http_response = http_response @json = nil end |
Instance Method Details
#correlation_id ⇒ Object
27 28 29 |
# File 'lib/datadog/ci/test_optimisation/skippable.rb', line 27 def correlation_id payload.dig("meta", "correlation_id") end |
#error_message ⇒ Object
45 46 47 48 49 |
# File 'lib/datadog/ci/test_optimisation/skippable.rb', line 45 def return nil if ok? "Status code: #{@http_response&.code}, response: #{@http_response&.payload}" end |
#ok? ⇒ Boolean
22 23 24 25 |
# File 'lib/datadog/ci/test_optimisation/skippable.rb', line 22 def ok? resp = @http_response !resp.nil? && resp.ok? end |
#tests ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/datadog/ci/test_optimisation/skippable.rb', line 31 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 |