diff options
Diffstat (limited to 'spec/unit/node')
| -rwxr-xr-x | spec/unit/node/configuration.rb | 40 |
1 files changed, 29 insertions, 11 deletions
diff --git a/spec/unit/node/configuration.rb b/spec/unit/node/configuration.rb index 7fda4e9a8..44b98dddb 100755 --- a/spec/unit/node/configuration.rb +++ b/spec/unit/node/configuration.rb @@ -301,9 +301,9 @@ end describe Puppet::Node::Configuration, " when functioning as a resource container" do before do @config = Puppet::Node::Configuration.new("host") - @one = stub 'resource1', :ref => "Me[one]", :configuration= => nil - @two = stub 'resource2', :ref => "Me[two]", :configuration= => nil - @dupe = stub 'resource3', :ref => "Me[one]", :configuration= => nil + @one = stub 'resource1', :ref => "Me[one]", :configuration= => nil, :title => "one", :name => "one" + @two = stub 'resource2', :ref => "Me[two]", :configuration= => nil, :title => "two", :name => "two" + @dupe = stub 'resource3', :ref => "Me[one]", :configuration= => nil, :title => "one", :name => "one" end it "should provide a method to add one or more resources" do @@ -412,6 +412,25 @@ describe Puppet::Node::Configuration, " when functioning as a resource container @config.remove_resource(@one) @config.resource("me", "other").should be_nil end + + it "should alias resources whose names are not equal to their titles" do + resource = stub("resource", :name => "one", :title => "two", :ref => "Me[two]", :configuration= => nil) + @config.expects(:alias).with(resource, "one") + @config.add_resource resource + end + + it "should fail to add resources whose names conflict with an existing resource even when the title does not conflict" do + conflict = stub("resource", :name => "one", :ref => "Me[one]", :configuration= => nil) + resource = stub("resource", :name => "one", :title => "other", :ref => "Me[other]", :configuration= => nil) + @config.expects(:alias).with(resource, "one") + @config.add_resource resource + end + + it "should not alias components whose names do not match their titles" do + comp = Puppet::Type::Component.create :name => "one", :title => "two" + @config.expects(:alias).never + @config.add_resource comp + end end module ApplyingConfigurations @@ -538,19 +557,18 @@ end describe Puppet::Node::Configuration, " when creating a relationship graph" do before do @config = Puppet::Node::Configuration.new("host") - @compone = Puppet::Type::Component.create :name => "one" - @comptwo = Puppet::Type::Component.create :name => "two", :require => ["class", "one"] + @compone = @config.create_resource :component, :name => "one" + @comptwo = @config.create_resource :component, :name => "two", :require => ["class", "one"] @file = Puppet::Type.type(:file) - @one = @file.create :path => "/one" - @two = @file.create :path => "/two" + @one = @config.create_resource :file, :path => "/one" + @two = @config.create_resource :file, :path => "/two" @config.add_edge! @compone, @one @config.add_edge! @comptwo, @two - @three = @file.create :path => "/three" - @four = @file.create :path => "/four", :require => ["file", "/three"] - @five = @file.create :path => "/five" - @config.add_resource @compone, @comptwo, @one, @two, @three, @four, @five + @three = @config.create_resource :file, :path => "/three" + @four = @config.create_resource :file, :path => "/four", :require => ["file", "/three"] + @five = @config.create_resource :file, :path => "/five" @relationships = @config.relationship_graph end |
