diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2021-10-22 14:03:16 -0700 |
---|---|---|
committer | Tim Smith <tsmith84@gmail.com> | 2021-10-27 12:38:25 -0700 |
commit | 4600606675d223f82a763ffd6f2df01e68c54f3f (patch) | |
tree | 87dbd9eb3ab566d078214f0db5326e1f22fb8cc7 /spec/unit/data_collector_spec.rb | |
parent | d61840ae9c1d0e089e927b2761242bdf219e61cc (diff) | |
download | chef-reporting.tar.gz |
Fix reporting/data_collector for @recipe_filesreporting
When individual recipes are invoked like 'chef-client ./whatever.rb'
those files get a cookbook_name of `@recipe_files` which is a magic
value that nees to be handled specially to avoid the reporting
classes from blowing up.
Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
Diffstat (limited to 'spec/unit/data_collector_spec.rb')
-rw-r--r-- | spec/unit/data_collector_spec.rb | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/spec/unit/data_collector_spec.rb b/spec/unit/data_collector_spec.rb index 24f8807d2e..eb698d6661 100644 --- a/spec/unit/data_collector_spec.rb +++ b/spec/unit/data_collector_spec.rb @@ -164,7 +164,7 @@ describe Chef::DataCollector do "after" => after_resource&.state_for_resource_reporter || {}, "before" => before_resource&.state_for_resource_reporter || {}, "cookbook_name" => cookbook_name, - "cookbook_version" => cookbook_version.version, + "cookbook_version" => cookbook_version&.version, "delta" => resource_has_diff(new_resource, status) ? new_resource.diff : "", "duration" => duration, "id" => new_resource.identity, @@ -567,6 +567,29 @@ describe Chef::DataCollector do it_behaves_like "sends a converge message" end + context "when the run contains a file resource that is up-to-date from a @recipe_files, returns nil for the version" do + let(:total_resource_count) { 1 } + let(:updated_resource_count) { 0 } + let(:cookbook_name) { "@recipe_files" } + let(:resource_record) { [ resource_record_for(new_resource, current_resource, after_resource, :create, "up-to-date", "1234") ] } + let(:status) { "success" } + let(:cookbook_version) { nil } + + before do + allow(new_resource).to receive(:cookbook_version).and_call_original + events.resource_action_start(new_resource, :create) + events.resource_current_state_loaded(new_resource, :create, current_resource) + events.resource_up_to_date(new_resource, :create) + events.resource_after_state_loaded(new_resource, :create, after_resource) + new_resource.instance_variable_set(:@elapsed_time, 1.2345) + events.resource_completed(new_resource) + events.converge_complete + run_status.stop_clock + end + + it_behaves_like "sends a converge message" + end + context "when the run contains a file resource that is updated" do let(:total_resource_count) { 1 } let(:updated_resource_count) { 1 } |