Class: CemAcpt::Bolt::Tests::TestResult
- Inherits:
-
Object
- Object
- CemAcpt::Bolt::Tests::TestResult
- Defined in:
- lib/cem_acpt/bolt/tests.rb
Overview
Contains the results of a single Bolt task test
Instance Attribute Summary collapse
-
#command_result ⇒ Object
readonly
Returns the value of attribute command_result.
-
#details ⇒ Object
readonly
Returns the value of attribute details.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#validation_results ⇒ Object
readonly
Returns the value of attribute validation_results.
Instance Method Summary collapse
- #action ⇒ Object
- #error ⇒ Object
- #error? ⇒ Boolean
- #failed_validation_results ⇒ Object
-
#initialize(name, command_result, validation_results, **details) ⇒ TestResult
constructor
A new instance of TestResult.
- #object ⇒ Object
- #skipped_validation_results ⇒ Object
- #status ⇒ Object
- #success? ⇒ Boolean
- #success_validation_results ⇒ Object
- #target ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize(name, command_result, validation_results, **details) ⇒ TestResult
Returns a new instance of TestResult.
103 104 105 106 107 108 |
# File 'lib/cem_acpt/bolt/tests.rb', line 103 def initialize(name, command_result, validation_results, **details) @name = name @command_result = command_result @validation_results = validation_results @details = details end |
Instance Attribute Details
#command_result ⇒ Object (readonly)
Returns the value of attribute command_result.
101 102 103 |
# File 'lib/cem_acpt/bolt/tests.rb', line 101 def command_result @command_result end |
#details ⇒ Object (readonly)
Returns the value of attribute details.
101 102 103 |
# File 'lib/cem_acpt/bolt/tests.rb', line 101 def details @details end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
101 102 103 |
# File 'lib/cem_acpt/bolt/tests.rb', line 101 def name @name end |
#validation_results ⇒ Object (readonly)
Returns the value of attribute validation_results.
101 102 103 |
# File 'lib/cem_acpt/bolt/tests.rb', line 101 def validation_results @validation_results end |
Instance Method Details
#action ⇒ Object
122 123 124 125 126 127 128 129 130 |
# File 'lib/cem_acpt/bolt/tests.rb', line 122 def action @action ||= if @command_result.is_a?(CemAcpt::Bolt::BoltActionError) @command_result.bolt_action elsif @command_result.respond_to?(:action) @command_result.action else 'unknown' end end |
#error ⇒ Object
164 165 166 |
# File 'lib/cem_acpt/bolt/tests.rb', line 164 def error @command_result.error if error? end |
#error? ⇒ Boolean
160 161 162 |
# File 'lib/cem_acpt/bolt/tests.rb', line 160 def error? @command_result.error? end |
#failed_validation_results ⇒ Object
110 111 112 |
# File 'lib/cem_acpt/bolt/tests.rb', line 110 def failed_validation_results @failed_validation_results ||= validation_results.select { |vr| vr[:result] == 'failure' } end |
#object ⇒ Object
142 143 144 145 146 147 148 149 150 |
# File 'lib/cem_acpt/bolt/tests.rb', line 142 def object @object ||= if @command_result.is_a?(CemAcpt::Bolt::BoltActionError) @command_result.bolt_object elsif @command_result.respond_to?(:object) @command_result.object else 'unknown' end end |
#skipped_validation_results ⇒ Object
114 115 116 |
# File 'lib/cem_acpt/bolt/tests.rb', line 114 def skipped_validation_results @skipped_validation_results ||= validation_results.select { |vr| vr[:result] == 'skipped' } end |
#status ⇒ Object
156 157 158 |
# File 'lib/cem_acpt/bolt/tests.rb', line 156 def status @status ||= success? ? 'success' : 'failure' end |
#success? ⇒ Boolean
152 153 154 |
# File 'lib/cem_acpt/bolt/tests.rb', line 152 def success? @validation_results.none? { |vr| vr[:result] == 'failure' } end |
#success_validation_results ⇒ Object
118 119 120 |
# File 'lib/cem_acpt/bolt/tests.rb', line 118 def success_validation_results @success_validation_results ||= validation_results.select { |vr| vr[:result] == 'success' } end |
#target ⇒ Object
132 133 134 135 136 137 138 139 140 |
# File 'lib/cem_acpt/bolt/tests.rb', line 132 def target @target ||= if @command_result.is_a?(CemAcpt::Bolt::BoltActionError) @command_result.bolt_target elsif @command_result.respond_to?(:target) @command_result.target else 'unknown' end end |
#to_h ⇒ Object
168 169 170 171 172 173 174 175 176 |
# File 'lib/cem_acpt/bolt/tests.rb', line 168 def to_h { name: name, success: success?, command_result: command_result.to_h, validation_results: validation_results, details: details, } end |