-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1ab459c
commit cb563bc
Showing
7 changed files
with
114 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
module Datadog | ||
module CI | ||
module Context | ||
class Global | ||
@mutex: Thread::Mutex | ||
|
||
@test_session: Datadog::CI::TestSession? | ||
|
||
def initialize: () -> void | ||
|
||
def active_test_session: () -> Datadog::CI::TestSession? | ||
|
||
def activate_test_session!: (Datadog::CI::TestSession test_session) -> void | ||
|
||
def deactivate_test_session!: () -> void | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
module Datadog | ||
module CI | ||
class TestSession < Span | ||
@mutex: Thread::Mutex | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
RSpec.describe Datadog::CI::Context::Global do | ||
subject { described_class.new } | ||
|
||
let(:tracer_span) { double(Datadog::Tracing::SpanOperation, name: "test.session") } | ||
let(:session) { Datadog::CI::TestSession.new(tracer_span) } | ||
|
||
describe "#activate_test_session!" do | ||
context "when a test session is already active" do | ||
before do | ||
subject.activate_test_session!(Datadog::CI::TestSession.new(tracer_span)) | ||
end | ||
|
||
it "raises an error" do | ||
expect { subject.activate_test_session!(session) }.to( | ||
raise_error( | ||
RuntimeError, | ||
"Nested test sessions are not supported. Currently active test session: " \ | ||
"#{session}" | ||
) | ||
) | ||
end | ||
end | ||
|
||
context "when no test session is active" do | ||
it "activates the test session" do | ||
subject.activate_test_session!(session) | ||
expect(subject.active_test_session).to be(session) | ||
end | ||
end | ||
end | ||
|
||
describe "#deactivate_test_session!" do | ||
context "when a test session is active" do | ||
before do | ||
subject.activate_test_session!(session) | ||
end | ||
|
||
it "deactivates the test session" do | ||
subject.deactivate_test_session! | ||
expect(subject.active_test_session).to be_nil | ||
end | ||
end | ||
|
||
context "when no test session is active" do | ||
it "does nothing" do | ||
subject.deactivate_test_session! | ||
expect(subject.active_test_session).to be_nil | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters