diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2015-01-12 15:13:40 -0800 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2015-01-12 15:13:59 -0800 |
commit | 5a2f19a85fbee9f4517aa471378e40cf32d030e0 (patch) | |
tree | 6c1824aee7a5f9de882e1e8096d9b6c7e050b663 /spec/unit/recipe_spec.rb | |
parent | 153764d26ed639dfd58945fdc5c4cc5ae51ef5e2 (diff) | |
download | chef-5a2f19a85fbee9f4517aa471378e40cf32d030e0.tar.gz |
Skip 3694 warnings on trivial resource cloning
Turns the 3694 warning into a debug message if the prior resource is
identical to the current resource. Suggestion for opscode/chef-rfc#76
This also moves resource building out to its own class.
Diffstat (limited to 'spec/unit/recipe_spec.rb')
-rw-r--r-- | spec/unit/recipe_spec.rb | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/spec/unit/recipe_spec.rb b/spec/unit/recipe_spec.rb index e8c1358ba2..22389a1a82 100644 --- a/spec/unit/recipe_spec.rb +++ b/spec/unit/recipe_spec.rb @@ -161,7 +161,82 @@ describe Chef::Recipe do zm_resource # force let binding evaluation expect { run_context.resource_collection.resources(:zen_master => "klopp") }.to raise_error(Chef::Exceptions::ResourceNotFound) end + end + + describe "when cloning resources" do + def expect_warning + expect(Chef::Log).to receive(:warn).with(/3694/) + expect(Chef::Log).to receive(:warn).with(/Previous/) + expect(Chef::Log).to receive(:warn).with(/Current/) + end + + it "should emit a 3694 warning when attributes change" do + recipe.zen_master "klopp" do + something "bvb" + end + expect_warning + recipe.zen_master "klopp" do + something "vbv" + end + end + + it "should emit a 3694 warning when attributes change" do + recipe.zen_master "klopp" do + something "bvb" + end + expect_warning + recipe.zen_master "klopp" do + something "bvb" + peace true + end + end + it "should emit a 3694 warning when attributes change" do + recipe.zen_master "klopp" do + something "bvb" + peace true + end + expect_warning + recipe.zen_master "klopp" do + something "bvb" + end + end + + it "should emit a 3694 warning for non-trivial attributes (unfortunately)" do + recipe.zen_master "klopp" do + something "bvb" + end + expect_warning + recipe.zen_master "klopp" do + something "bvb" + end + end + + it "should not emit a 3694 warning for completely trivial resource cloning" do + recipe.zen_master "klopp" + expect(Chef::Log).to_not receive(:warn) + recipe.zen_master "klopp" + end + + it "should not emit a 3694 warning when attributes do not change and the first action is :nothing" do + recipe.zen_master "klopp" do + action :nothing + end + expect(Chef::Log).to_not receive(:warn) + recipe.zen_master "klopp" do + action :score + end + end + + it "should not emit a 3694 warning when attributes do not change and the second action is :nothing" do + recipe.zen_master "klopp" do + action :score + end + expect(Chef::Log).to_not receive(:warn) + recipe.zen_master "klopp" do + action :nothing + end + end end describe "creating resources via declare_resource" do |