mirror of
https://github.com/inspec/inspec
synced 2024-11-29 08:00:33 +00:00
Added failure and passed conditions in enhanced_outcomes
Signed-off-by: Nikita Mathur <nikita.mathur@chef.io>
This commit is contained in:
parent
4e83f395c8
commit
9d531b68de
2 changed files with 21 additions and 10 deletions
|
@ -120,14 +120,16 @@ module Inspec::Formatters
|
|||
|
||||
def determine_control_enhanced_outcome(control)
|
||||
if control_has_error(control)
|
||||
return { name: "Error", abbrev: "ERR" }
|
||||
{ name: "Error", abbrev: "ERR" }
|
||||
elsif control[:impact].to_f == 0.0
|
||||
return { name: "Not Applicable", abbrev: "N/A" }
|
||||
{ name: "Not Applicable", abbrev: "N/A" }
|
||||
elsif control_has_all_tests_skipped(control)
|
||||
return { name: "Not Reviewed", abbrev: "N/R" }
|
||||
{ name: "Not Reviewed", abbrev: "N/R" }
|
||||
elsif control[:results].any? { |r| r[:status] == "failed" }
|
||||
{ name: "Failed", abbrev: "fail"}
|
||||
else
|
||||
{ name: "Passed", abbrev: "pass"}
|
||||
end
|
||||
|
||||
{}
|
||||
end
|
||||
|
||||
def control_has_all_tests_skipped(control)
|
||||
|
|
|
@ -56,15 +56,17 @@ module Inspec::Plugin::V2::PluginType
|
|||
end
|
||||
|
||||
def add_enhanced_outcomes(control_id)
|
||||
enhanced_outcomes = {}
|
||||
if control_has_error(@notifications[control_id])
|
||||
enhanced_outcomes = { name: "Error", abbrev: "ERR" }
|
||||
{ name: "Error", abbrev: "ERR" }
|
||||
elsif control_has_impact_zero(@notifications[control_id])
|
||||
enhanced_outcomes = { name: "Not Applicable", abbrev: "N/A" }
|
||||
{ name: "Not Applicable", abbrev: "N/A" }
|
||||
elsif control_has_all_tests_skipped(@notifications[control_id])
|
||||
enhanced_outcomes = { name: "Not Reviewed", abbrev: "N/R" }
|
||||
{ name: "Not Reviewed", abbrev: "N/R" }
|
||||
elsif control_has_any_tests_failed(@notifications[control_id])
|
||||
{ name: "Failed", abbrev: "fail" }
|
||||
else
|
||||
{ name: "Passed", abbrev: "pass" }
|
||||
end
|
||||
enhanced_outcomes
|
||||
end
|
||||
|
||||
def control_has_error(notifications)
|
||||
|
@ -81,6 +83,13 @@ module Inspec::Plugin::V2::PluginType
|
|||
end
|
||||
end
|
||||
|
||||
def control_has_any_tests_failed(notifications)
|
||||
notifications.any? do |notification_data|
|
||||
_notification, status = notification_data
|
||||
status == "failed"
|
||||
end
|
||||
end
|
||||
|
||||
def control_has_impact_zero(notifications)
|
||||
notification_data = notifications.first
|
||||
notification_impact = notification_data.first.example.metadata[:impact]
|
||||
|
|
Loading…
Reference in a new issue