diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2018-02-13 09:44:37 -0800 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2018-02-13 09:44:37 -0800 |
commit | 4c73efee6f0962f66139bc54ed1dca2d20803b9e (patch) | |
tree | 97b4a44f6bf46a06c9b67d5313560b91f04c605f /spec/unit/node_map_spec.rb | |
parent | 4aa6f211880a840721104592c0b65b6959cec88d (diff) | |
download | chef-4c73efee6f0962f66139bc54ed1dca2d20803b9e.tar.gz |
add specs
Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
Diffstat (limited to 'spec/unit/node_map_spec.rb')
-rw-r--r-- | spec/unit/node_map_spec.rb | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/spec/unit/node_map_spec.rb b/spec/unit/node_map_spec.rb index 67bb741ec5..27ec4d5f1a 100644 --- a/spec/unit/node_map_spec.rb +++ b/spec/unit/node_map_spec.rb @@ -19,6 +19,9 @@ require "spec_helper" require "chef/node_map" +class Foo; end +class Bar; end + describe Chef::NodeMap do let(:node_map) { Chef::NodeMap.new } @@ -120,8 +123,6 @@ describe Chef::NodeMap do end describe "ordering classes" do - class Foo; end - class Bar; end it "last writer wins when its reverse alphabetic order" do node_map.set(:thing, Foo) node_map.set(:thing, Bar) @@ -135,6 +136,30 @@ describe Chef::NodeMap do end end + describe "deleting classes" do + it "deletes a class and removes the mapping completely" do + node_map.set(:thing, Bar) + expect( node_map.delete_class(Bar) ).to eql({:thing=>[{:klass=>Bar}]}) + 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) + expect( node_map.delete_class(Bar) ).to eql({:thing=>[{:klass=>Bar}]}) + expect( node_map.get(node, :thing) ).to eql(Foo) + end + + it "handles deleting classes from multiple keys" do + node_map.set(:thing1, Bar) + node_map.set(:thing2, Bar) + node_map.set(:thing2, Foo) + expect( node_map.delete_class(Bar) ).to eql({:thing1=>[{:klass=>Bar}], :thing2=>[{:klass=>Bar}]}) + expect( node_map.get(node, :thing1) ).to eql(nil) + expect( node_map.get(node, :thing2) ).to eql(Foo) + end + end + describe "with a block doing platform_version checks" do before do node_map.set(:thing, :foo, platform_family: "rhel") do |node| |