From 74938cb623089ba513e563d83de83a7dd04939c1 Mon Sep 17 00:00:00 2001 From: Alex Pop Date: Mon, 2 Mar 2020 21:48:07 +0000 Subject: [PATCH] Fix test errors --- libraries/helper.rb | 4 ++++ spec/unit/report/fetcher_spec.rb | 6 +++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/libraries/helper.rb b/libraries/helper.rb index d2203469..30dc5962 100644 --- a/libraries/helper.rb +++ b/libraries/helper.rb @@ -136,6 +136,10 @@ def load_audit_handler # taking node['audit'] as parameter so that it can be called from the chef-server fetcher as well # audit['collector'] is the legacy reporter, def get_reporters(audit) + if audit.nil? + Chef::Log.warn("node ['audit'] is not defined") + return [] + end if audit['collector'] Chef::Log.warn("node ['audit']['collector'] is deprecated and will be removed from the next major version of the cookbook. Please use node ['audit']['reporter']") return handle_reporters(audit['collector']) diff --git a/spec/unit/report/fetcher_spec.rb b/spec/unit/report/fetcher_spec.rb index 3fcfae06..6c5d7b2d 100644 --- a/spec/unit/report/fetcher_spec.rb +++ b/spec/unit/report/fetcher_spec.rb @@ -91,10 +91,10 @@ }, 'profile' => ['admin', 'linux-baseline', '2.0'], } - - Fetchers::Url.new('non_profile_url', config).send(:http_opts) + mynode.default['audit']['reporter'] = 'chef-server' + ChefServer::Fetcher.target_url('non_profile_url', config).read } - expect { myproc.call }.to raise_error(RuntimeError) + expect { myproc.call }.to raise_error(Errno::ECONNREFUSED) end end end