diff options
author | Brice Figureau <brice-puppet@daysofwonder.com> | 2009-09-15 21:01:48 +0200 |
---|---|---|
committer | James Turnbull <james@lovedthanlost.net> | 2009-09-17 13:54:55 +1000 |
commit | 361c50210172ffe484550a19db3a8d10d86edc09 (patch) | |
tree | 24b43a67b76164a852c195cb9b05bc27c6a56a49 /spec | |
parent | 2283605ba63b39deec30bd71b5d0879630f63e6d (diff) | |
download | puppet-361c50210172ffe484550a19db3a8d10d86edc09.tar.gz puppet-361c50210172ffe484550a19db3a8d10d86edc09.tar.xz puppet-361c50210172ffe484550a19db3a8d10d86edc09.zip |
Fix #2638 - Allow creating several nodes with matching names
When we are checking if a node exists before creating a new one
we were also trying to match with regex node names, finding matches
where in fact there is no equality.
Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
Diffstat (limited to 'spec')
-rw-r--r-- | spec/unit/parser/loaded_code.rb | 19 | ||||
-rwxr-xr-x | spec/unit/parser/parser.rb | 2 |
2 files changed, 19 insertions, 2 deletions
diff --git a/spec/unit/parser/loaded_code.rb b/spec/unit/parser/loaded_code.rb index ca4b0aaca..75f2bc7e2 100644 --- a/spec/unit/parser/loaded_code.rb +++ b/spec/unit/parser/loaded_code.rb @@ -156,7 +156,24 @@ describe Puppet::Parser::LoadedCode do nameout = Puppet::Parser::AST::HostName.new(:value => "foo") @loader.add_node(namein, "bar") - @loader.node(nameout) == "bar" + @loader.node(nameout).should == "bar" + end + + it "should be able to find node by HostName strict equality" do + namein = Puppet::Parser::AST::HostName.new(:value => "foo") + nameout = Puppet::Parser::AST::HostName.new(:value => "foo") + + @loader.add_node(namein, "bar") + @loader.node_exists?(nameout).should == "bar" + end + + it "should not use node name matching when finding with strict node HostName" do + name1 = Puppet::Parser::AST::HostName.new(:value => "foo") + name2 = Puppet::Parser::AST::HostName.new(:value => Puppet::Parser::AST::Regex.new(:value => /foo/)) + + @loader.add_node(name1, "bar") + @loader.add_node(name2, "baz") + @loader.node_exists?(name1).should == "bar" end it "should return the first matching regex nodename" do diff --git a/spec/unit/parser/parser.rb b/spec/unit/parser/parser.rb index 9127599df..842dc1904 100755 --- a/spec/unit/parser/parser.rb +++ b/spec/unit/parser/parser.rb @@ -253,7 +253,7 @@ describe Puppet::Parser do end it "should raise an error if the node already exists" do - @loaded_code.stubs(:node).with(@nodename).returns(@node) + @loaded_code.stubs(:node_exists?).with(@nodename).returns(@node) lambda { @parser.newnode(@nodename) }.should raise_error end |