summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPete Higgins <pete@peterhiggins.org>2020-12-11 12:43:46 -0800
committerPete Higgins <pete@peterhiggins.org>2020-12-11 12:44:08 -0800
commit380a173a92aa80f6fbd2466b31d8ec4cefb06b1d (patch)
tree66b59a608c0b7b27f3c3fe262ef25a900b6404cb
parent3495764911ccac898f599baa22cbcd1f9224013a (diff)
downloadchef-380a173a92aa80f6fbd2466b31d8ec4cefb06b1d.tar.gz
Instead of silently failing, raise an exception for bad reporter types.
Signed-off-by: Pete Higgins <pete@peterhiggins.org>
-rw-r--r--lib/chef/compliance/runner.rb3
-rw-r--r--spec/unit/compliance/runner_spec.rb6
2 files changed, 3 insertions, 6 deletions
diff --git a/lib/chef/compliance/runner.rb b/lib/chef/compliance/runner.rb
index 978dc33b32..8948d9c895 100644
--- a/lib/chef/compliance/runner.rb
+++ b/lib/chef/compliance/runner.rb
@@ -239,8 +239,7 @@ class Chef
when "audit-enforcer"
Chef::Compliance::Reporter::ComplianceEnforcer.new
else
- logger.warn "'#{reporter_type}' is not a supported reporter for Compliance Phase."
- nil
+ raise "'#{reporter_type}' is not a supported reporter for Compliance Phase."
end
end
diff --git a/spec/unit/compliance/runner_spec.rb b/spec/unit/compliance/runner_spec.rb
index e1ca1c5d3a..f9f3d61dd2 100644
--- a/spec/unit/compliance/runner_spec.rb
+++ b/spec/unit/compliance/runner_spec.rb
@@ -133,10 +133,8 @@ describe Chef::Compliance::Runner do
end
end
- it "returns nil for unexpected reporter value" do
- expect(logger).to receive(:warn).with("'tacos' is not a supported reporter for Chef Infra Client's Compliance Phase")
-
- expect(runner.reporter("tacos")).to be_nil
+ it "fails with unexpected reporter value" do
+ expect { runner.reporter("tacos") }.to raise_error(/'tacos' is not a supported reporter for Compliance Phase/)
end
end
end