diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2019-05-07 14:25:12 -0700 |
---|---|---|
committer | Tim Smith <tsmith@chef.io> | 2019-05-17 12:10:43 -0700 |
commit | be0fc336d7bcfcaea53fc119450bacfb6b031ee5 (patch) | |
tree | 8acd7bb3d283014c8289789c7cd1267e8c7c65da /spec | |
parent | 51deebd1b78520c0d4113c0da37b7a19697c19b7 (diff) | |
download | chef-be0fc336d7bcfcaea53fc119450bacfb6b031ee5.tar.gz |
Remove resource collision deprecations
Switch to only doing warnings. Remove the features in the node_map that
we never used.
Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
Diffstat (limited to 'spec')
-rw-r--r-- | spec/unit/node_map_spec.rb | 59 | ||||
-rw-r--r-- | spec/unit/resource_spec.rb | 14 |
2 files changed, 20 insertions, 53 deletions
diff --git a/spec/unit/node_map_spec.rb b/spec/unit/node_map_spec.rb index 9c161f3893..0f3c51ef37 100644 --- a/spec/unit/node_map_spec.rb +++ b/spec/unit/node_map_spec.rb @@ -1,6 +1,6 @@ # # Author:: Lamont Granquist (<lamont@chef.io>) -# Copyright:: Copyright 2014-2018, Chef Software Inc. +# Copyright:: Copyright 2014-2019, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -145,14 +145,22 @@ describe Chef::NodeMap do describe "deleting classes" do it "deletes a class and removes the mapping completely" do node_map.set(:thing, Bar) +<<<<<<< HEAD expect( node_map.delete_class(Bar) ).to include({ thing: [{ klass: Bar, cookbook_override: false, core_override: false }] }) +======= + expect( node_map.delete_class(Bar) ).to include({ thing: [{ klass: Bar, target_mode: nil }] }) +>>>>>>> 896c67a9d... Remove resource collision deprecations expect( node_map.get(node, :thing) ).to eql(nil) end it "deletes a class and leaves the mapping that still has an entry" do node_map.set(:thing, Bar) node_map.set(:thing, Foo) +<<<<<<< HEAD expect( node_map.delete_class(Bar) ).to eql({ thing: [{ klass: Bar, cookbook_override: false, core_override: false }] }) +======= + expect( node_map.delete_class(Bar) ).to eql({ thing: [{ klass: Bar, target_mode: nil }] }) +>>>>>>> 896c67a9d... Remove resource collision deprecations expect( node_map.get(node, :thing) ).to eql(Foo) end @@ -160,7 +168,11 @@ describe Chef::NodeMap do node_map.set(:thing1, Bar) node_map.set(:thing2, Bar) node_map.set(:thing2, Foo) +<<<<<<< HEAD expect( node_map.delete_class(Bar) ).to eql({ thing1: [{ klass: Bar, cookbook_override: false, core_override: false }], thing2: [{ klass: Bar, cookbook_override: false, core_override: false }] }) +======= + expect( node_map.delete_class(Bar) ).to eql({ thing1: [{ klass: Bar, target_mode: nil }], thing2: [{ klass: Bar, target_mode: nil }] }) +>>>>>>> 896c67a9d... Remove resource collision deprecations expect( node_map.get(node, :thing1) ).to eql(nil) expect( node_map.get(node, :thing2) ).to eql(Foo) end @@ -213,7 +225,7 @@ describe Chef::NodeMap do describe "locked mode" do context "while unlocked" do it "allows setting the same key twice" do - expect(Chef).to_not receive(:deprecated) + expect(Chef::Log).to_not receive(:warn) node_map.set(:foo, FooResource) node_map.set(:foo, BarResource) expect(node_map.get(node, :foo)).to eql(BarResource) @@ -221,53 +233,20 @@ describe Chef::NodeMap do end context "while locked" do - # Uncomment the commented `expect`s in 15.0. - it "rejects setting the same key twice" do - expect(Chef).to receive(:deprecated).with(:map_collision, /Resource foo/) + it "warns on setting the same key twice" do + expect(Chef::Log).to receive(:warn).with(/Resource foo/) node_map.set(:foo, FooResource) node_map.lock! node_map.set(:foo, BarResource) - # expect(node_map.get(node, :foo)).to eql(FooResource) - end - - it "allows setting the same key twice when the first has allow_cookbook_override" do - expect(Chef).to_not receive(:deprecated) - node_map.set(:foo, FooResource, allow_cookbook_override: true) - node_map.lock! - node_map.set(:foo, BarResource) - expect(node_map.get(node, :foo)).to eql(BarResource) - end - - it "allows setting the same key twice when the first has allow_cookbook_override with a future version" do - expect(Chef).to_not receive(:deprecated) - node_map.set(:foo, FooResource, allow_cookbook_override: "< 100") - node_map.lock! - node_map.set(:foo, BarResource) - expect(node_map.get(node, :foo)).to eql(BarResource) - end - - it "rejects setting the same key twice when the first has allow_cookbook_override with a past version" do - expect(Chef).to receive(:deprecated).with(:map_collision, /Resource foo/) - node_map.set(:foo, FooResource, allow_cookbook_override: "< 1") - node_map.lock! - node_map.set(:foo, BarResource) - # expect(node_map.get(node, :foo)).to eql(FooResource) - end - - it "allows setting the same key twice when the second has __core_override__" do - expect(Chef).to_not receive(:deprecated) - node_map.set(:foo, FooResource) - node_map.lock! - node_map.set(:foo, BarResource, __core_override__: true) expect(node_map.get(node, :foo)).to eql(BarResource) end - it "rejects setting the same key twice for a provider" do - expect(Chef).to receive(:deprecated).with(:map_collision, /Provider foo/) + it "warns on setting the same key twice for a provider" do + expect(Chef::Log).to receive(:warn).with(/Provider foo/) node_map.set(:foo, FooProvider) node_map.lock! node_map.set(:foo, BarProvider) - # expect(node_map.get(node, :foo)).to eql(FooProvider) + expect(node_map.get(node, :foo)).to eql(BarProvider) end end end diff --git a/spec/unit/resource_spec.rb b/spec/unit/resource_spec.rb index 921ca6d33e..b1b639d823 100644 --- a/spec/unit/resource_spec.rb +++ b/spec/unit/resource_spec.rb @@ -867,7 +867,7 @@ describe Chef::Resource do snitch_var1 = snitch_var2 = 0 runner = Chef::Runner.new(run_context) - Chef::Provider::SnakeOil.provides :cat, __core_override__: true + Chef::Provider::SnakeOil.provides :cat resource1.only_if { snitch_var1 = 1 } resource1.not_if { snitch_var2 = 2 } @@ -1191,17 +1191,5 @@ describe Chef::Resource do expect(Chef.resource_handler_map).to receive(:set).with(:test_resource, klass, { canonical: true }) klass.resource_name(:test_resource) end - - it "adds allow_cookbook_override when true" do - expect(Chef.resource_handler_map).to receive(:set).with(:test_resource, klass, { canonical: true, allow_cookbook_override: true }) - klass.preview_resource(true) - klass.resource_name(:test_resource) - end - - it "allows manually overriding back to false" do - expect(Chef.resource_handler_map).to receive(:set).with(:test_resource, klass, { allow_cookbook_override: false }) - klass.preview_resource(true) - klass.provides(:test_resource, allow_cookbook_override: false) - end end end |