From b26de0f9635c3ac6bb6d9eef6359c298374d6d55 Mon Sep 17 00:00:00 2001 From: Andrey Marchenko Date: Mon, 22 Apr 2024 11:35:01 +0200 Subject: [PATCH] rename TestRun.test_full_name to TestRun.skippable_test_id --- lib/datadog/ci/itr/runner.rb | 2 +- lib/datadog/ci/itr/skippable.rb | 2 +- lib/datadog/ci/utils/test_run.rb | 2 +- sig/datadog/ci/utils/test_run.rbs | 2 +- spec/datadog/ci/utils/test_run_spec.rb | 28 ++++++++++++++++++++++++++ 5 files changed, 32 insertions(+), 4 deletions(-) diff --git a/lib/datadog/ci/itr/runner.rb b/lib/datadog/ci/itr/runner.rb index 54b5ca66..abd1f68f 100644 --- a/lib/datadog/ci/itr/runner.rb +++ b/lib/datadog/ci/itr/runner.rb @@ -125,7 +125,7 @@ def stop_coverage(test) def mark_if_skippable(test) return if !enabled? || !skipping_tests? - skippable_test_id = Utils::TestRun.test_full_name(test.name, test.test_suite_name, test.parameters) + skippable_test_id = Utils::TestRun.skippable_test_id(test.name, test.test_suite_name, test.parameters) if @skippable_tests.include?(skippable_test_id) test.set_tag(Ext::Test::TAG_ITR_SKIPPED_BY_ITR, "true") diff --git a/lib/datadog/ci/itr/skippable.rb b/lib/datadog/ci/itr/skippable.rb index 648b7842..a1382ad0 100644 --- a/lib/datadog/ci/itr/skippable.rb +++ b/lib/datadog/ci/itr/skippable.rb @@ -33,7 +33,7 @@ def tests next unless test_data["type"] == Ext::Test::ITR_TEST_SKIPPING_MODE attrs = test_data["attributes"] || {} - res << Utils::TestRun.test_full_name(attrs["name"], attrs["suite"], attrs["parameters"]) + res << Utils::TestRun.skippable_test_id(attrs["name"], attrs["suite"], attrs["parameters"]) end res diff --git a/lib/datadog/ci/utils/test_run.rb b/lib/datadog/ci/utils/test_run.rb index abf83b1f..eb494182 100644 --- a/lib/datadog/ci/utils/test_run.rb +++ b/lib/datadog/ci/utils/test_run.rb @@ -10,7 +10,7 @@ def self.command @command = "#{$0} #{ARGV.join(" ")}" end - def self.test_full_name(test_name, suite, parameters = nil) + def self.skippable_test_id(test_name, suite, parameters = nil) "#{suite}.#{test_name}.#{parameters}" end diff --git a/sig/datadog/ci/utils/test_run.rbs b/sig/datadog/ci/utils/test_run.rbs index 5bce9fd3..71287469 100644 --- a/sig/datadog/ci/utils/test_run.rbs +++ b/sig/datadog/ci/utils/test_run.rbs @@ -6,7 +6,7 @@ module Datadog def self.command: () -> String - def self.test_full_name: (String test_name, String? test_suite, ?String? parameters) -> String + def self.skippable_test_id: (String test_name, String? test_suite, ?String? parameters) -> String def self.test_parameters: (?arguments: Hash[untyped, untyped], ?metadata: Hash[untyped, untyped]) -> String end diff --git a/spec/datadog/ci/utils/test_run_spec.rb b/spec/datadog/ci/utils/test_run_spec.rb index 7f84b65e..b2e7b93d 100644 --- a/spec/datadog/ci/utils/test_run_spec.rb +++ b/spec/datadog/ci/utils/test_run_spec.rb @@ -6,4 +6,32 @@ it { is_expected.to eq("#{$0} #{ARGV.join(" ")}") } end + + describe ".skippable_test_id" do + subject { described_class.skippable_test_id(test_name, suite, parameters) } + + let(:test_name) { "test_name" } + let(:suite) { "suite" } + let(:parameters) { "parameters" } + + it { is_expected.to eq("suite.test_name.parameters") } + end + + describe ".test_parameters" do + subject { described_class.test_parameters(arguments: arguments, metadata: metadata) } + + let(:arguments) { {} } + let(:metadata) { {} } + + it "returns a JSON string" do + is_expected.to eq( + JSON.generate( + { + arguments: arguments, + metadata: metadata + } + ) + ) + end + end end