Class: Datadog::CI::TestVisibility::Store::Local

Inherits:
Object
  • Object
show all
Defined in:
lib/datadog/ci/test_visibility/store/local.rb

Instance Method Summary collapse

Constructor Details

#initializeLocal

Returns a new instance of Local.



8
9
10
11
12
# File 'lib/datadog/ci/test_visibility/store/local.rb', line 8

def initialize
  @key = :datadog_ci_active_test

  self.active_test = nil
end

Instance Method Details

#activate_test(test) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/datadog/ci/test_visibility/store/local.rb', line 14

def activate_test(test)
  raise "Nested tests are not supported. Currently active test: #{active_test}" unless active_test.nil?

  if block_given?
    begin
      self.active_test = test
      yield
    ensure
      self.active_test = nil
    end
  else
    self.active_test = test
  end
end

#active_testObject



33
34
35
# File 'lib/datadog/ci/test_visibility/store/local.rb', line 33

def active_test
  Thread.current[@key]
end

#deactivate_testObject



29
30
31
# File 'lib/datadog/ci/test_visibility/store/local.rb', line 29

def deactivate_test
  self.active_test = nil
end