Skip to content

Commit

Permalink
simplify TestSession's serializer test
Browse files Browse the repository at this point in the history
  • Loading branch information
anmarchenko committed Dec 19, 2024
1 parent cd9f8d8 commit 1e97219
Showing 1 changed file with 8 additions and 18 deletions.
26 changes: 8 additions & 18 deletions spec/datadog/ci/test_visibility/serializers/test_session_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@
produce_test_session_trace
end

let(:logical_test_session_name) { "logical_test_session_name" }
before do
expect_any_instance_of(Datadog::CI::TestVisibility::Component).to(
receive(:logical_test_session_name).and_return(logical_test_session_name)
)
end

it "serializes test event to messagepack" do
expect_event_header(type: Datadog::CI::Ext::AppTypes::TYPE_TEST_SESSION)

Expand All @@ -22,7 +29,7 @@
"name" => "rspec.test_session",
"service" => "rspec-test-suite",
"type" => Datadog::CI::Ext::AppTypes::TYPE_TEST_SESSION,
"resource" => "rspec.test_session.#{test_command}"
"resource" => "rspec.test_session.#{logical_test_session_name}"
}
)

Expand All @@ -38,23 +45,6 @@

expect(meta["_test.session_id"]).to be_nil
end

context "logical test session name is provided" do
let(:logical_test_session_name) { "logical_test_session_name" }
before do
expect_any_instance_of(Datadog::CI::TestVisibility::Component).to(
receive(:logical_test_session_name).and_return(logical_test_session_name)
)
end

it "uses logical test session name as part of span's resource instead of command" do
expect(content).to include(
{
"resource" => "rspec.test_session.#{logical_test_session_name}"
}
)
end
end
end

context "trace a failed test" do
Expand Down

0 comments on commit 1e97219

Please sign in to comment.