diff --git a/lib/datadog/ci/itr/skippable.rb b/lib/datadog/ci/itr/skippable.rb index 3613e51c..28b3c1b6 100644 --- a/lib/datadog/ci/itr/skippable.rb +++ b/lib/datadog/ci/itr/skippable.rb @@ -4,24 +4,12 @@ require_relative "../ext/transport" require_relative "../ext/test" +require_relative "../utils/test_run" module Datadog module CI module ITR class Skippable - class Test - attr_reader :name, :suite - - def initialize(name:, suite:) - @name = name - @suite = suite - end - - def ==(other) - name == other.name && suite == other.suite - end - end - class Response def initialize(http_response) @http_response = http_response @@ -38,13 +26,17 @@ def correlation_id end def tests + res = Set.new + payload.fetch("data", []) - .filter_map do |test_data| + .each do |test_data| next unless test_data["type"] == Ext::Test::ITR_TEST_SKIPPING_MODE attrs = test_data["attributes"] || {} - Test.new(name: attrs["name"], suite: attrs["suite"]) + res << Utils::TestRun.test_full_name(attrs["name"], attrs["suite"]) end + + res end private diff --git a/lib/datadog/ci/utils/test_run.rb b/lib/datadog/ci/utils/test_run.rb index 1e41715e..65a4c0e3 100644 --- a/lib/datadog/ci/utils/test_run.rb +++ b/lib/datadog/ci/utils/test_run.rb @@ -9,6 +9,10 @@ def self.command @command = "#{$0} #{ARGV.join(" ")}" end + + def self.test_full_name(test_name, suite) + "#{suite}.#{test_name}" + end end end end diff --git a/sig/datadog/ci/itr/skippable.rbs b/sig/datadog/ci/itr/skippable.rbs index 04528e2d..15c81922 100644 --- a/sig/datadog/ci/itr/skippable.rbs +++ b/sig/datadog/ci/itr/skippable.rbs @@ -5,18 +5,6 @@ module Datadog @api: Datadog::CI::Transport::Api::Base? @dd_env: String? - class Test - @name: String? - - @suite: String? - - attr_reader name: String? - - attr_reader suite: String? - - def initialize: (name: String?, suite: String?) -> void - end - class Response @http_response: Datadog::Core::Transport::HTTP::Adapters::Net::Response? @json: Hash[String, untyped]? @@ -27,7 +15,7 @@ module Datadog def correlation_id: () -> String? - def tests: () -> Array[Test] + def tests: () -> Set[String] private diff --git a/sig/datadog/ci/utils/test_run.rbs b/sig/datadog/ci/utils/test_run.rbs index c985f99b..66fef457 100644 --- a/sig/datadog/ci/utils/test_run.rbs +++ b/sig/datadog/ci/utils/test_run.rbs @@ -5,6 +5,8 @@ module Datadog self.@command: String def self.command: () -> String + + def self.test_full_name: (String test_name, String test_suite) -> String end end end diff --git a/spec/datadog/ci/itr/skippable_spec.rb b/spec/datadog/ci/itr/skippable_spec.rb index 196fa7f5..e224b386 100644 --- a/spec/datadog/ci/itr/skippable_spec.rb +++ b/spec/datadog/ci/itr/skippable_spec.rb @@ -96,9 +96,7 @@ it "parses the response" do expect(response.ok?).to be true expect(response.correlation_id).to eq("correlation_id_123") - expect(response.tests.first).to eq( - Datadog::CI::ITR::Skippable::Test.new(name: "test_name", suite: "test_suite_name") - ) + expect(response.tests.first).to eq("test_suite_name.test_name") end end