Skip to content

Commit

Permalink
test for TestSession#inheritable_tags
Browse files Browse the repository at this point in the history
  • Loading branch information
anmarchenko committed Nov 22, 2023
1 parent 2413f61 commit 550d0d3
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 2 additions & 0 deletions lib/datadog/ci/test_session.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
22 changes: 21 additions & 1 deletion spec/datadog/ci/test_session_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 550d0d3

Please sign in to comment.