Module: TestBench::Telemetry::Controls::Event::Random

Defined in:
lib/test_bench/telemetry/controls/event.rb

Class Method Summary collapse

Class Method Details

.event_classObject



99
100
101
102
103
104
105
# File 'lib/test_bench/telemetry/controls/event.rb', line 99

def self.event_class
  if Controls::Random.boolean
    SomeEvent
  else
    SomeOtherEvent
  end
end

.event_dataObject



119
120
121
122
# File 'lib/test_bench/telemetry/controls/event.rb', line 119

def self.event_data
  event = self.example
  Telemetry::Event::Export.(event)
end

.example(some_attribute: nil, some_other_attribute: nil, event_class: nil, metadata: nil, process_id: nil, time: nil) ⇒ Object



90
91
92
93
94
95
96
97
# File 'lib/test_bench/telemetry/controls/event.rb', line 90

def self.example(some_attribute: nil, some_other_attribute: nil, event_class: nil, metadata: nil, process_id: nil, time: nil)
  some_attribute ||= self.some_attribute
  some_other_attribute ||= self.some_other_attribute
  event_class ||= self.event_class
   ||= Metadata::Random.example(process_id:, time:)

  Event.example(some_attribute:, some_other_attribute:, event_class:, metadata:)
end

.some_attributeObject



107
108
109
110
111
# File 'lib/test_bench/telemetry/controls/event.rb', line 107

def self.some_attribute
  suffix = Controls::Random.string

  "#{Event.some_attribute}-#{suffix}"
end

.some_other_attributeObject



113
114
115
116
117
# File 'lib/test_bench/telemetry/controls/event.rb', line 113

def self.some_other_attribute
  suffix = Controls::Random.string

  "#{Event.some_other_attribute}-#{suffix}"
end