diff options
author | danielsdeleo <dan@chef.io> | 2016-10-24 18:13:24 -0700 |
---|---|---|
committer | danielsdeleo <dan@chef.io> | 2016-11-02 08:06:38 -0700 |
commit | bc596e0e0e3302dd013565943b1aa91f17fffc8f (patch) | |
tree | 25671021adf88f092c25c7f588dd824573219d79 /spec | |
parent | b95fce9f28693aa09dd0d37742063027596f6847 (diff) | |
download | chef-bc596e0e0e3302dd013565943b1aa91f17fffc8f.tar.gz |
Enable the data collector automatically
Signed-off-by: Daniel DeLeo <dan@chef.io>
Diffstat (limited to 'spec')
-rw-r--r-- | spec/support/shared/context/client.rb | 15 | ||||
-rw-r--r-- | spec/unit/data_collector_spec.rb | 4 |
2 files changed, 14 insertions, 5 deletions
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 |