diff --git a/lib/datadog/ci/test_session.rb b/lib/datadog/ci/test_session.rb index a8ca98cc..0dbd691e 100644 --- a/lib/datadog/ci/test_session.rb +++ b/lib/datadog/ci/test_session.rb @@ -19,6 +19,8 @@ def finish end def inheritable_tags + # this method is not synchronized because it does not iterate over the tags, but rather + # uses synchronized method to get each tag value res = {} Ext::Test::INHERITABLE_TAGS.each do |tag| res[tag] = get_tag(tag) diff --git a/spec/datadog/ci/test_session_spec.rb b/spec/datadog/ci/test_session_spec.rb index e2a6e148..97429d32 100644 --- a/spec/datadog/ci/test_session_spec.rb +++ b/spec/datadog/ci/test_session_spec.rb @@ -8,10 +8,30 @@ before { allow(Datadog::CI).to receive(:deactivate_test_session) } - it "deactivates the test" do + it "deactivates the test session" do ci_test_session.finish expect(Datadog::CI).to have_received(:deactivate_test_session) end end + + describe "#inheritable_tags" do + subject(:inheritable_tags) { ci_test_session.inheritable_tags } + + let(:ci_test_session) { described_class.new(tracer_span) } + + before do + Datadog::CI::Ext::Test::INHERITABLE_TAGS.each do |tag| + allow(tracer_span).to receive(:get_tag).with(tag).and_return("value for #{tag}") + end + end + + it "returns a hash of inheritable tags" do + is_expected.to eq( + Datadog::CI::Ext::Test::INHERITABLE_TAGS.each_with_object({}) do |tag, memo| + memo[tag] = "value for #{tag}" + end + ) + end + end end