Class: Datadog::CI::TestOptimisation::Coverage::Event
- Inherits:
-
Object
- Object
- Datadog::CI::TestOptimisation::Coverage::Event
- Defined in:
- lib/datadog/ci/test_optimisation/coverage/event.rb
Instance Attribute Summary collapse
-
#coverage ⇒ Object
readonly
Returns the value of attribute coverage.
-
#test_id ⇒ Object
readonly
Returns the value of attribute test_id.
-
#test_session_id ⇒ Object
readonly
Returns the value of attribute test_session_id.
-
#test_suite_id ⇒ Object
readonly
Returns the value of attribute test_suite_id.
Instance Method Summary collapse
-
#initialize(test_id:, test_suite_id:, test_session_id:, coverage:) ⇒ Event
constructor
A new instance of Event.
-
#pretty_print(q) ⇒ Object
Return a human readable version of the event.
- #to_msgpack(packer = nil) ⇒ Object
- #to_s ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(test_id:, test_suite_id:, test_session_id:, coverage:) ⇒ Event
Returns a new instance of Event.
14 15 16 17 18 19 |
# File 'lib/datadog/ci/test_optimisation/coverage/event.rb', line 14 def initialize(test_id:, test_suite_id:, test_session_id:, coverage:) @test_id = test_id @test_suite_id = test_suite_id @test_session_id = test_session_id @coverage = coverage end |
Instance Attribute Details
#coverage ⇒ Object (readonly)
Returns the value of attribute coverage.
12 13 14 |
# File 'lib/datadog/ci/test_optimisation/coverage/event.rb', line 12 def coverage @coverage end |
#test_id ⇒ Object (readonly)
Returns the value of attribute test_id.
12 13 14 |
# File 'lib/datadog/ci/test_optimisation/coverage/event.rb', line 12 def test_id @test_id end |
#test_session_id ⇒ Object (readonly)
Returns the value of attribute test_session_id.
12 13 14 |
# File 'lib/datadog/ci/test_optimisation/coverage/event.rb', line 12 def test_session_id @test_session_id end |
#test_suite_id ⇒ Object (readonly)
Returns the value of attribute test_suite_id.
12 13 14 |
# File 'lib/datadog/ci/test_optimisation/coverage/event.rb', line 12 def test_suite_id @test_suite_id end |
Instance Method Details
#pretty_print(q) ⇒ Object
Return a human readable version of the event
64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/datadog/ci/test_optimisation/coverage/event.rb', line 64 def pretty_print(q) q.group 0 do q.breakable q.text "Test ID: #{@test_id}\n" q.text "Test Suite ID: #{@test_suite_id}\n" q.text "Test Session ID: #{@test_session_id}\n" q.group(2, "Files: [", "]\n") do q.seplist @coverage.keys.each do |key| q.text key end end end end |
#to_msgpack(packer = nil) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/datadog/ci/test_optimisation/coverage/event.rb', line 34 def to_msgpack(packer = nil) packer ||= MessagePack::Packer.new packer.write_map_header(4) packer.write("test_session_id") packer.write(test_session_id.to_i) packer.write("test_suite_id") packer.write(test_suite_id.to_i) packer.write("span_id") packer.write(test_id.to_i) files = coverage.keys packer.write("files") packer.write_array_header(files.size) files.each do |filename| packer.write_map_header(1) packer.write("filename") packer.write(Git::LocalRepository.relative_to_root(filename)) end end |
#to_s ⇒ Object
59 60 61 |
# File 'lib/datadog/ci/test_optimisation/coverage/event.rb', line 59 def to_s "Coverage::Event[test_id=#{test_id}, test_suite_id=#{test_suite_id}, test_session_id=#{test_session_id}, coverage=#{coverage}]" end |
#valid? ⇒ Boolean
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/datadog/ci/test_optimisation/coverage/event.rb', line 21 def valid? valid = true %i[test_id test_suite_id test_session_id coverage].each do |key| next unless send(key).nil? Datadog.logger.warn("citestcov event is invalid: [#{key}] is nil. Event: #{self}") valid = false end valid end |