Class: Datadog::CI::TestManagement::TestsProperties::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/datadog/ci/test_management/tests_properties.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.from_http_response(http_response) ⇒ Object



18
19
20
# File 'lib/datadog/ci/test_management/tests_properties.rb', line 18

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

.from_json(json) ⇒ Object



22
23
24
# File 'lib/datadog/ci/test_management/tests_properties.rb', line 22

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

Instance Method Details

#ok?Boolean

Returns:

  • (Boolean)


26
27
28
29
# File 'lib/datadog/ci/test_management/tests_properties.rb', line 26

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

#testsObject



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/datadog/ci/test_management/tests_properties.rb', line 31

def tests
  tests_map = {}

  payload
    .fetch("data", {})
    .fetch("attributes", {})
    .fetch("modules", {})
    .each do |_test_module, module_hash|
      module_hash
        .fetch("suites", {})
        .each do |test_suite, suite_hash|
          suite_hash.fetch("tests", {})
            .each do |test_name, properties_hash|
              properties = properties_hash.fetch("properties", {})
              properties.transform_values! { |v| Utils::Parsing.convert_to_bool(v) }

              tests_map[Utils::TestRun.datadog_test_id(test_name, test_suite)] = properties
            end
        end
    end

  tests_map
end