From bc596e0e0e3302dd013565943b1aa91f17fffc8f Mon Sep 17 00:00:00 2001 From: danielsdeleo Date: Mon, 24 Oct 2016 18:13:24 -0700 Subject: Enable the data collector automatically Signed-off-by: Daniel DeLeo --- spec/support/shared/context/client.rb | 15 ++++++++++++--- spec/unit/data_collector_spec.rb | 4 ++-- 2 files changed, 14 insertions(+), 5 deletions(-) (limited to 'spec') diff --git a/spec/support/shared/context/client.rb b/spec/support/shared/context/client.rb index b0530ab497..295bd6ce5f 100644 --- a/spec/support/shared/context/client.rb +++ b/spec/support/shared/context/client.rb @@ -68,9 +68,10 @@ shared_context "a client run" do let(:api_client_exists?) { false } let(:enable_fork) { false } - let(:http_cookbook_sync) { double("Chef::ServerAPI (cookbook sync)") } - let(:http_node_load) { double("Chef::ServerAPI (node)") } - let(:http_node_save) { double("Chef::ServerAPI (node save)") } + let(:http_data_collector) { double("Chef::ServerAPI (data collector)") } + let(:http_cookbook_sync) { double("Chef::ServerAPI (cookbook sync)") } + let(:http_node_load) { double("Chef::ServerAPI (node)") } + let(:http_node_save) { double("Chef::ServerAPI (node save)") } let(:reporting_rest_client) { double("Chef::ServerAPI (reporting client)") } let(:runner) { instance_double("Chef::Runner") } @@ -92,6 +93,13 @@ shared_context "a client run" do end end + def stub_for_data_collector_init + expect(Chef::ServerAPI).to receive(:new). + with(Chef::Config[:data_collector][:server_url]). + exactly(:once). + and_return(http_data_collector) + end + def stub_for_node_load # Client.register will then turn around create another # Chef::ServerAPI object, this time with the client key it got from the @@ -154,6 +162,7 @@ shared_context "a client run" do stub_rest_clean stub_for_register + stub_for_data_collector_init stub_for_node_load stub_for_sync_cookbooks stub_for_converge diff --git a/spec/unit/data_collector_spec.rb b/spec/unit/data_collector_spec.rb index 25de91864a..3d79c386fe 100644 --- a/spec/unit/data_collector_spec.rb +++ b/spec/unit/data_collector_spec.rb @@ -557,9 +557,9 @@ describe Chef::DataCollector::Reporter do end context "when raise-on-failure is disabled" do - it "logs a warning and does not raise an exception" do + it "logs an info message and does not raise an exception" do Chef::Config[:data_collector][:raise_on_failure] = false - expect(Chef::Log).to receive(:warn) + expect(Chef::Log).to receive(:info) expect { reporter.send(:disable_reporter_on_error) { raise exception_class.new("bummer") } }.not_to raise_error end end -- cgit v1.2.1